| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef _CN0209_H_ |
| 42 |
#define _CN0209_H_ |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
#include "xil_types.h" |
| 48 |
#include "xparameters.h" |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#define AD7193_RDY_PIN (1 << 1) |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
#define ADG1414_CS_PIN (1 << 0) // ADG1414 CS Pin. |
| 59 |
#define ADT7310_CS_PIN (1 << 1) // ADT7310 CS Pin. |
| 60 |
#define AD7193_CS_PIN (1 << 2) // AD7193 CS Pin. |
| 61 |
#define AD7193_INT1_PIN (1 << 3) // INT1 Pin. |
| 62 |
#define AD7193_INT2_PIN (1 << 5) // INT2 Pin. |
| 63 |
#define AD7193_READY_PIN (1 << 7) // Data Ready Pin. |
| 64 |
|
| 65 |
#define AD7193_CS_OUT GPIO2_PIN_OUT |
| 66 |
#define AD7193_CS_LOW GPIO2_LOW |
| 67 |
#define AD7193_CS_HIGH GPIO2_HIGH |
| 68 |
|
| 69 |
#define ADT7310_CS_OUT GPIO1_PIN_OUT |
| 70 |
#define ADT7310_CS_LOW GPIO1_LOW |
| 71 |
#define ADT7310_CS_HIGH GPIO1_HIGH |
| 72 |
|
| 73 |
#define ADG1414_CS_OUT GPIO0_PIN_OUT |
| 74 |
#define ADG1414_CS_LOW GPIO0_LOW |
| 75 |
#define ADG1414_CS_HIGH GPIO0_HIGH |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
#define AD7193_REG_COMM 0 // Communications Register(WO, 8-bit) |
| 82 |
#define AD7193_REG_STAT 0 // Status Register (RO, 8-bit) |
| 83 |
#define AD7193_REG_MODE 1 // Mode Register (RW, 24-bit) |
| 84 |
#define AD7193_REG_CONF 2 // Configuration Register (RW, 24-bit) |
| 85 |
#define AD7193_REG_DATA 3 // Data Register (RO, 24-bit) |
| 86 |
#define AD7193_REG_ID 4 // ID Register (RO, 8-bit) |
| 87 |
#define AD7193_REG_GPOCON 5 // GPOCON Register (RW, 8-bit) |
| 88 |
#define AD7193_REG_OFFSET 6 // Offset Register (RW, 24-bit) |
| 89 |
#define AD7192_REG_FULLSCALE 7 // Full-Scale Register (RW, 24-bit) |
| 90 |
|
| 91 |
|
| 92 |
#define AD7193_COMM_WEN (1 << 7) // Write Enable |
| 93 |
#define AD7193_COMM_WRITE (0 << 6) // Write Operation |
| 94 |
#define AD7193_COMM_READ (1 << 6) // Read Operation |
| 95 |
#define AD7193_COMM_ADDR(x) (((x) & 0x7) << 3) // Register Address |
| 96 |
#define AD7193_COMM_CREAD (1 << 2) // Continuous Read |
| 97 |
|
| 98 |
|
| 99 |
#define AD7193_STAT_RDY (1 << 7) // Ready |
| 100 |
#define AD7193_STAT_ERR (1 << 6) // Error (Overrange, Underrange) |
| 101 |
#define AD7193_STAT_NOREF (1 << 5) // Error no external reference |
| 102 |
#define AD7193_STAT_PARITY (1 << 4) // Parity |
| 103 |
#define AD7193_STAT_CH3 (1 << 2) // Channel 3 |
| 104 |
#define AD7193_STAT_CH2 (1 << 2) // Channel 2 |
| 105 |
#define AD7193_STAT_CH1 (1 << 1) // Channel 1 |
| 106 |
#define AD7193_STAT_CH0 (1 << 0) // Channel 0 |
| 107 |
|
| 108 |
|
| 109 |
#define AD7193_MODE_SEL(x) (((x) & 0x7) << 21) // Operation Mode Select |
| 110 |
#define AD7193_MODE_DAT_STA (1 << 20) // Status Register transmission |
| 111 |
#define AD7193_MODE_CLKSRC(x) (((x) & 0x3) << 18) // Clock Source Select |
| 112 |
#define AD7193_MODE_AVG(x) (((x) & 0x3) << 16) // Fast settling filter |
| 113 |
#define AD7193_MODE_SINC3 (1 << 15) // SINC3 Filter Select |
| 114 |
#define AD7193_MODE_ENPAR (1 << 13) // Parity Enable |
| 115 |
#define AD7193_MODE_CLKDIV (1 << 12) // Clock divide by 2 |
| 116 |
#define AD7193_MODE_SCYCLE (1 << 11) // Single cycle conversion |
| 117 |
#define AD7193_MODE_REJ60 (1 << 10) // 50/60Hz notch filter |
| 118 |
#define AD7193_MODE_RATE(x) ((x) & 0x3FF) // Filter Update Rate Select |
| 119 |
|
| 120 |
|
| 121 |
#define AD7193_MODE_CONT 0 // Continuous Conversion Mode |
| 122 |
#define AD7193_MODE_SINGLE 1 // Single Conversion Mode |
| 123 |
#define AD7193_MODE_IDLE 2 // Idle Mode |
| 124 |
#define AD7193_MODE_PWRDN 3 // Power-Down Mode |
| 125 |
#define AD7193_MODE_CAL_INT_ZERO 4 // Internal Zero-Scale Calibration |
| 126 |
#define AD7193_MODE_CAL_INT_FULL 5 // Internal Full-Scale Calibration |
| 127 |
#define AD7193_MODE_CAL_SYS_ZERO 6 // System Zero-Scale Calibration |
| 128 |
#define AD7193_MODE_CAL_SYS_FULL 7 // System Full-Scale Calibration |
| 129 |
|
| 130 |
|
| 131 |
#define AD7193_MODE_CLK_EXT_MCLK1_2 0 // External 4.92 MHz Clock connected from MCLK1 to MCLK2 |
| 132 |
#define AD7193_MODE_CLK_EXT_MCLK2 1 // External Clock applied to MCLK2 |
| 133 |
#define AD7193_MODE_CLK_INT 2 // Internal 4.92 MHz Clock not available at the MCLK2 pin |
| 134 |
#define AD7193_MODE_CLK_INT_CO 3 // Internal 4.92 MHz Clock available at the MCLK2 pin |
| 135 |
|
| 136 |
|
| 137 |
#define AD7193_CONF_CHOP (1 << 23) // CHOP enable |
| 138 |
#define AD7193_CONF_REFSEL (1 << 20) // REFIN1/REFIN2 Reference Select |
| 139 |
#define AD7193_CONF_PSEUDO (1 << 18) // Pseudo differential analog inputs |
| 140 |
#define AD7193_CONF_SHORT (1 << 17) // Short channel |
| 141 |
#define AD7193_CONF_TEMP (1 << 16) // Temperature sensor |
| 142 |
#define AD7193_CONF_CHAN(x) (((x) & 0xFF) << 8) // Channel select |
| 143 |
#define AD7193_CONF_BURN (1 << 7) // Burnout current enable |
| 144 |
#define AD7193_CONF_REFDET (1 << 6) // Reference detect enable |
| 145 |
#define AD7193_CONF_BUF (1 << 4) // Buffered Mode Enable |
| 146 |
#define AD7193_CONF_UNIPOLAR (1 << 3) // Unipolar/Bipolar Enable |
| 147 |
#define AD7193_CONF_GAIN(x) ((x) & 0x7) // Gain Select |
| 148 |
|
| 149 |
|
| 150 |
#define AD7193_CONF_GAIN_1 0 // Gain 1, ADC Input Range +-2.5 V |
| 151 |
#define AD7193_CONF_GAIN_8 3 // Gain 8, ADC Input Range +-312.5 mV |
| 152 |
#define AD7193_CONF_GAIN_16 4 // Gain 16, ADC Input Range +-156.2 mV |
| 153 |
#define AD7193_CONF_GAIN_32 5 // Gain 32, ADC Input Range +-78.125 mV |
| 154 |
#define AD7193_CONF_GAIN_64 6 // Gain 64, ADC Input Range +-39.06 mV |
| 155 |
#define AD7193_CONF_GAIN_128 7 // Gain 128, ADC Input Range +-19.53 mV |
| 156 |
|
| 157 |
|
| 158 |
#define AD7193_GPOCON_BPDSW (1 << 6) // Bridge power-down switch enable |
| 159 |
#define AD7193_GPOCON_GP32EN (1 << 5) // Digital Output P3 and P2 enable |
| 160 |
#define AD7193_GPOCON_GP10EN (1 << 4) // Digital Output P1 and P0 enable |
| 161 |
#define AD7193_GPOCON_P3DAT (1 << 3) // P3 state |
| 162 |
#define AD7193_GPOCON_P2DAT (1 << 2) // P2 state |
| 163 |
#define AD7193_GPOCON_P1DAT (1 << 1) // P1 state |
| 164 |
#define AD7193_GPOCON_P0DAT (1 << 0) // P0 state |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
#define ADT7310_REG_STATUS 0x00 // Status Register (RO, 8-bit) |
| 171 |
#define ADT7310_REG_CONFIG 0x01 // Configuration Register (RW, 8-bit) |
| 172 |
#define ADT7310_REG_TEMPERATURE 0x02 // Temperature value (RO, 16-bit) |
| 173 |
#define ADT7310_REG_ID 0x03 // ID (RO, 8-bit) |
| 174 |
#define ADT7310_REG_TCRIT 0x04 // TCRIT setpoint (RW, 16-bit) |
| 175 |
#define ADT7310_REG_THYST 0x05 // THYST setpoint (RW, 16-bit) |
| 176 |
#define ADT7310_REG_THIGH 0x06 // THIGH setpoint (RW, 16-bit) |
| 177 |
#define ADT7310_REG_TLOW 0x07 // TLOW setpoint (RW, 16-bit) |
| 178 |
|
| 179 |
|
| 180 |
#define ADT7310_CMD_WRITE (0 << 6) // Write Operation |
| 181 |
#define ADT7310_CMD_READ (1 << 6) // Read Operation |
| 182 |
#define ADT7310_CMD_ADDR(x) (((x) & 0x7) << 3) // Register Address |
| 183 |
#define ADT7310_CMD_CREAD (1 << 2) // Continuous Read |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
unsigned short ADT7310_Read(unsigned char regAddress, |
| 190 |
unsigned char bytesNumber); |
| 191 |
|
| 192 |
|
| 193 |
void ADT7310_Write(unsigned char regAddress, |
| 194 |
unsigned char bytesNumber, |
| 195 |
unsigned short regData); |
| 196 |
|
| 197 |
|
| 198 |
float ADT7310_TemperatureRead(void); |
| 199 |
|
| 200 |
|
| 201 |
void ADT7310_Reset(void); |
| 202 |
|
| 203 |
|
| 204 |
unsigned long AD7193_Read(unsigned char regAddress, |
| 205 |
unsigned char bytesNumber); |
| 206 |
|
| 207 |
|
| 208 |
void AD7193_Write(unsigned char regAddress, |
| 209 |
unsigned char bytesNumber, |
| 210 |
unsigned long regData); |
| 211 |
|
| 212 |
|
| 213 |
unsigned long AD7193_SingleConversion(void); |
| 214 |
|
| 215 |
|
| 216 |
float AD7193_TemperatureRead(void); |
| 217 |
|
| 218 |
|
| 219 |
float AD7193_ConvertToVolts(unsigned long rawData, |
| 220 |
float vRef, |
| 221 |
unsigned char gain, |
| 222 |
unsigned char polarity); |
| 223 |
|
| 224 |
|
| 225 |
void AD7193_Reset(void); |
| 226 |
|
| 227 |
|
| 228 |
void ADG1414_State (unsigned char switches); |
| 229 |
|
| 230 |
|
| 231 |
char CN0209_Init(void); |
| 232 |
|
| 233 |
#endif |