808
Dependents: Chromatograph_Mobile
ads1248.h@0:1b92bdad27f6, 2020-08-08 (annotated)
- Committer:
- nikmaos
- Date:
- Sat Aug 08 18:29:32 2020 +0000
- Revision:
- 0:1b92bdad27f6
- Child:
- 1:54015254fc18
808
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nikmaos | 0:1b92bdad27f6 | 1 | #ifndef ADS1248_H |
nikmaos | 0:1b92bdad27f6 | 2 | #define ADS1248_H |
nikmaos | 0:1b92bdad27f6 | 3 | #include "PerifConfig.h" |
nikmaos | 0:1b92bdad27f6 | 4 | |
nikmaos | 0:1b92bdad27f6 | 5 | #define DS1248_CS Cs |
nikmaos | 0:1b92bdad27f6 | 6 | #define DS1248_START Reset |
nikmaos | 0:1b92bdad27f6 | 7 | #define DS1248_DRDY CrdyA |
nikmaos | 0:1b92bdad27f6 | 8 | |
nikmaos | 0:1b92bdad27f6 | 9 | #define DS1248_WAKEUP_COMMAND 0x00 |
nikmaos | 0:1b92bdad27f6 | 10 | #define DS1248_SLEEP_COMMAND 0x02 |
nikmaos | 0:1b92bdad27f6 | 11 | #define DS1248_SYNC_COMMAND 0x04 |
nikmaos | 0:1b92bdad27f6 | 12 | #define DS1248_RESET_COMMAND 0x06 |
nikmaos | 0:1b92bdad27f6 | 13 | #define DS1248_NOP_COMMAND 0xFF |
nikmaos | 0:1b92bdad27f6 | 14 | #define DS1248_RDATA_COMMAND 0x12 |
nikmaos | 0:1b92bdad27f6 | 15 | #define DS1248_RDATAC_COMMAND 0x14 |
nikmaos | 0:1b92bdad27f6 | 16 | #define DS1248_SDATAC_COMMAND 0x16 |
nikmaos | 0:1b92bdad27f6 | 17 | |
nikmaos | 0:1b92bdad27f6 | 18 | #define DS1248_RREG_COMMAND 0x20 |
nikmaos | 0:1b92bdad27f6 | 19 | #define DS1248_WREG_COMMAND 0x40 |
nikmaos | 0:1b92bdad27f6 | 20 | |
nikmaos | 0:1b92bdad27f6 | 21 | #define DS1248_SYSOCAL_COMMAND 0x60 |
nikmaos | 0:1b92bdad27f6 | 22 | #define DS1248_SYSGCAL_COMMAND 0x61 |
nikmaos | 0:1b92bdad27f6 | 23 | #define DS1248_SELFOCAL_COMMAND 0x62 |
nikmaos | 0:1b92bdad27f6 | 24 | |
nikmaos | 0:1b92bdad27f6 | 25 | #define DS1248_RESTRICTED_COMMAND 0xF1 |
nikmaos | 0:1b92bdad27f6 | 26 | |
nikmaos | 0:1b92bdad27f6 | 27 | // Регистры |
nikmaos | 0:1b92bdad27f6 | 28 | |
nikmaos | 0:1b92bdad27f6 | 29 | #define DS1248_REGISTER_MUX0 0x00 |
nikmaos | 0:1b92bdad27f6 | 30 | #define DS1248_REGISTER_VBIAS 0x01 |
nikmaos | 0:1b92bdad27f6 | 31 | #define DS1248_REGISTER_MUX1 0x02 |
nikmaos | 0:1b92bdad27f6 | 32 | #define DS1248_REGISTER_SYS0 0x03 |
nikmaos | 0:1b92bdad27f6 | 33 | #define DS1248_REGISTER_OFC0 0x04 |
nikmaos | 0:1b92bdad27f6 | 34 | #define DS1248_REGISTER_OFC1 0x05 |
nikmaos | 0:1b92bdad27f6 | 35 | #define DS1248_REGISTER_OFC2 0x06 |
nikmaos | 0:1b92bdad27f6 | 36 | #define DS1248_REGISTER_FSC0 0x07 |
nikmaos | 0:1b92bdad27f6 | 37 | #define DS1248_REGISTER_FSC1 0x08 |
nikmaos | 0:1b92bdad27f6 | 38 | #define DS1248_REGISTER_FSC2 0x09 |
nikmaos | 0:1b92bdad27f6 | 39 | #define DS1248_REGISTER_IDAC0 0x0A |
nikmaos | 0:1b92bdad27f6 | 40 | #define DS1248_REGISTER_IDAC1 0x0B |
nikmaos | 0:1b92bdad27f6 | 41 | #define DS1248_REGISTER_GPIOCFG 0x0C |
nikmaos | 0:1b92bdad27f6 | 42 | #define DS1248_REGISTER_GPIOCDIR 0x0D |
nikmaos | 0:1b92bdad27f6 | 43 | #define DS1248_REGISTER_GPIODAT 0x0E |
nikmaos | 0:1b92bdad27f6 | 44 | |
nikmaos | 0:1b92bdad27f6 | 45 | // Настройки регисторов |
nikmaos | 0:1b92bdad27f6 | 46 | |
nikmaos | 0:1b92bdad27f6 | 47 | #define SET_REGISTER_MUX0 0x01 |
nikmaos | 0:1b92bdad27f6 | 48 | #define SET_REGISTER_MUX1 0x30 |
nikmaos | 0:1b92bdad27f6 | 49 | #define SET_REGISTER_SYS0 0x08 |
nikmaos | 0:1b92bdad27f6 | 50 | #define SET_REGISTER_IDAC0 0x04 |
nikmaos | 0:1b92bdad27f6 | 51 | #define SET_REGISTER_IDAC1 0xF9 |
nikmaos | 0:1b92bdad27f6 | 52 | #define SET_REGISTER_GPIOCFG 0x00 |
nikmaos | 0:1b92bdad27f6 | 53 | |
nikmaos | 0:1b92bdad27f6 | 54 | #define DR5 0 |
nikmaos | 0:1b92bdad27f6 | 55 | #define DR10 1 |
nikmaos | 0:1b92bdad27f6 | 56 | #define DR20 2 |
nikmaos | 0:1b92bdad27f6 | 57 | #define DR40 3 |
nikmaos | 0:1b92bdad27f6 | 58 | #define DR80 4 |
nikmaos | 0:1b92bdad27f6 | 59 | #define DR160 5 |
nikmaos | 0:1b92bdad27f6 | 60 | #define DR320 6 |
nikmaos | 0:1b92bdad27f6 | 61 | #define DR640 7 |
nikmaos | 0:1b92bdad27f6 | 62 | #define DR1000 8 |
nikmaos | 0:1b92bdad27f6 | 63 | #define DR2000 9 |
nikmaos | 0:1b92bdad27f6 | 64 | |
nikmaos | 0:1b92bdad27f6 | 65 | #define PGA_1 0 |
nikmaos | 0:1b92bdad27f6 | 66 | #define PGA_2 1 |
nikmaos | 0:1b92bdad27f6 | 67 | #define PGA_4 2 |
nikmaos | 0:1b92bdad27f6 | 68 | #define PGA_8 3 |
nikmaos | 0:1b92bdad27f6 | 69 | #define PGA_16 4 |
nikmaos | 0:1b92bdad27f6 | 70 | #define PGA_32 5 |
nikmaos | 0:1b92bdad27f6 | 71 | #define PGA_64 6 |
nikmaos | 0:1b92bdad27f6 | 72 | #define PGA_128 7 |
nikmaos | 0:1b92bdad27f6 | 73 | |
nikmaos | 0:1b92bdad27f6 | 74 | |
nikmaos | 0:1b92bdad27f6 | 75 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 76 | struct{ |
nikmaos | 0:1b92bdad27f6 | 77 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 78 | MUX_SN:3, |
nikmaos | 0:1b92bdad27f6 | 79 | MUX_SP:3, |
nikmaos | 0:1b92bdad27f6 | 80 | BCS:2; |
nikmaos | 0:1b92bdad27f6 | 81 | }; |
nikmaos | 0:1b92bdad27f6 | 82 | struct{ |
nikmaos | 0:1b92bdad27f6 | 83 | |
nikmaos | 0:1b92bdad27f6 | 84 | }; |
nikmaos | 0:1b92bdad27f6 | 85 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 86 | }MUX0_t; |
nikmaos | 0:1b92bdad27f6 | 87 | |
nikmaos | 0:1b92bdad27f6 | 88 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 89 | struct{ |
nikmaos | 0:1b92bdad27f6 | 90 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 91 | VBIAS0:1, |
nikmaos | 0:1b92bdad27f6 | 92 | VBIAS1:1, |
nikmaos | 0:1b92bdad27f6 | 93 | VBIAS2:1, |
nikmaos | 0:1b92bdad27f6 | 94 | VBIAS3:1, |
nikmaos | 0:1b92bdad27f6 | 95 | VBIAS4:1, |
nikmaos | 0:1b92bdad27f6 | 96 | VBIAS5:1, |
nikmaos | 0:1b92bdad27f6 | 97 | VBIAS6:1, |
nikmaos | 0:1b92bdad27f6 | 98 | VBIAS7:1; |
nikmaos | 0:1b92bdad27f6 | 99 | }; |
nikmaos | 0:1b92bdad27f6 | 100 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 101 | }VBIAS_t; |
nikmaos | 0:1b92bdad27f6 | 102 | |
nikmaos | 0:1b92bdad27f6 | 103 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 104 | struct{ |
nikmaos | 0:1b92bdad27f6 | 105 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 106 | MUXCAL:3, |
nikmaos | 0:1b92bdad27f6 | 107 | REFSELT:2, |
nikmaos | 0:1b92bdad27f6 | 108 | VREFCON:2, |
nikmaos | 0:1b92bdad27f6 | 109 | CLKSTAT:1; |
nikmaos | 0:1b92bdad27f6 | 110 | }; |
nikmaos | 0:1b92bdad27f6 | 111 | struct{ |
nikmaos | 0:1b92bdad27f6 | 112 | |
nikmaos | 0:1b92bdad27f6 | 113 | }; |
nikmaos | 0:1b92bdad27f6 | 114 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 115 | }MUX1_t; |
nikmaos | 0:1b92bdad27f6 | 116 | |
nikmaos | 0:1b92bdad27f6 | 117 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 118 | struct{ |
nikmaos | 0:1b92bdad27f6 | 119 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 120 | DR:4, |
nikmaos | 0:1b92bdad27f6 | 121 | PGA:3, |
nikmaos | 0:1b92bdad27f6 | 122 | :1; |
nikmaos | 0:1b92bdad27f6 | 123 | }; |
nikmaos | 0:1b92bdad27f6 | 124 | struct{ |
nikmaos | 0:1b92bdad27f6 | 125 | |
nikmaos | 0:1b92bdad27f6 | 126 | }; |
nikmaos | 0:1b92bdad27f6 | 127 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 128 | }SYS0_t; |
nikmaos | 0:1b92bdad27f6 | 129 | |
nikmaos | 0:1b92bdad27f6 | 130 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 131 | struct{ |
nikmaos | 0:1b92bdad27f6 | 132 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 133 | OFC0, |
nikmaos | 0:1b92bdad27f6 | 134 | OFC1, |
nikmaos | 0:1b92bdad27f6 | 135 | OFC2; |
nikmaos | 0:1b92bdad27f6 | 136 | }; |
nikmaos | 0:1b92bdad27f6 | 137 | uint32_t all; |
nikmaos | 0:1b92bdad27f6 | 138 | }OFC_t; |
nikmaos | 0:1b92bdad27f6 | 139 | |
nikmaos | 0:1b92bdad27f6 | 140 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 141 | struct{ |
nikmaos | 0:1b92bdad27f6 | 142 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 143 | FSC0, |
nikmaos | 0:1b92bdad27f6 | 144 | FSC1, |
nikmaos | 0:1b92bdad27f6 | 145 | FSC2; |
nikmaos | 0:1b92bdad27f6 | 146 | }; |
nikmaos | 0:1b92bdad27f6 | 147 | uint32_t all; |
nikmaos | 0:1b92bdad27f6 | 148 | }FSC_t; |
nikmaos | 0:1b92bdad27f6 | 149 | |
nikmaos | 0:1b92bdad27f6 | 150 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 151 | struct{ |
nikmaos | 0:1b92bdad27f6 | 152 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 153 | IMAG:3, |
nikmaos | 0:1b92bdad27f6 | 154 | DRDY_MODE:1, |
nikmaos | 0:1b92bdad27f6 | 155 | ID:4; |
nikmaos | 0:1b92bdad27f6 | 156 | }; |
nikmaos | 0:1b92bdad27f6 | 157 | struct{ |
nikmaos | 0:1b92bdad27f6 | 158 | |
nikmaos | 0:1b92bdad27f6 | 159 | }; |
nikmaos | 0:1b92bdad27f6 | 160 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 161 | }IDAC0_t; |
nikmaos | 0:1b92bdad27f6 | 162 | |
nikmaos | 0:1b92bdad27f6 | 163 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 164 | struct{ |
nikmaos | 0:1b92bdad27f6 | 165 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 166 | I2DIR:4, |
nikmaos | 0:1b92bdad27f6 | 167 | I1DIR:4; |
nikmaos | 0:1b92bdad27f6 | 168 | }; |
nikmaos | 0:1b92bdad27f6 | 169 | struct{ |
nikmaos | 0:1b92bdad27f6 | 170 | |
nikmaos | 0:1b92bdad27f6 | 171 | }; |
nikmaos | 0:1b92bdad27f6 | 172 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 173 | }IDAC1_t; |
nikmaos | 0:1b92bdad27f6 | 174 | |
nikmaos | 0:1b92bdad27f6 | 175 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 176 | struct{ |
nikmaos | 0:1b92bdad27f6 | 177 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 178 | IOCFG0:1, |
nikmaos | 0:1b92bdad27f6 | 179 | IOCFG1:1, |
nikmaos | 0:1b92bdad27f6 | 180 | IOCFG2:1, |
nikmaos | 0:1b92bdad27f6 | 181 | IOCFG3:1, |
nikmaos | 0:1b92bdad27f6 | 182 | IOCFG4:1, |
nikmaos | 0:1b92bdad27f6 | 183 | IOCFG5:1, |
nikmaos | 0:1b92bdad27f6 | 184 | IOCFG6:1, |
nikmaos | 0:1b92bdad27f6 | 185 | IOCFG7:1; |
nikmaos | 0:1b92bdad27f6 | 186 | }; |
nikmaos | 0:1b92bdad27f6 | 187 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 188 | }GPIOCFG_t; |
nikmaos | 0:1b92bdad27f6 | 189 | |
nikmaos | 0:1b92bdad27f6 | 190 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 191 | struct{ |
nikmaos | 0:1b92bdad27f6 | 192 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 193 | IODIR0:1, |
nikmaos | 0:1b92bdad27f6 | 194 | IODIR1:1, |
nikmaos | 0:1b92bdad27f6 | 195 | IODIR2:1, |
nikmaos | 0:1b92bdad27f6 | 196 | IODIR3:1, |
nikmaos | 0:1b92bdad27f6 | 197 | IODIR4:1, |
nikmaos | 0:1b92bdad27f6 | 198 | IODIR5:1, |
nikmaos | 0:1b92bdad27f6 | 199 | IODIR6:1, |
nikmaos | 0:1b92bdad27f6 | 200 | IODIR7:1; |
nikmaos | 0:1b92bdad27f6 | 201 | }; |
nikmaos | 0:1b92bdad27f6 | 202 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 203 | }GPIODIR_t; |
nikmaos | 0:1b92bdad27f6 | 204 | |
nikmaos | 0:1b92bdad27f6 | 205 | typedef union{ |
nikmaos | 0:1b92bdad27f6 | 206 | struct{ |
nikmaos | 0:1b92bdad27f6 | 207 | uint8_t |
nikmaos | 0:1b92bdad27f6 | 208 | IODAT0:1, |
nikmaos | 0:1b92bdad27f6 | 209 | IODAT1:1, |
nikmaos | 0:1b92bdad27f6 | 210 | IODAT2:1, |
nikmaos | 0:1b92bdad27f6 | 211 | IODAT3:1, |
nikmaos | 0:1b92bdad27f6 | 212 | IODAT4:1, |
nikmaos | 0:1b92bdad27f6 | 213 | IODAT5:1, |
nikmaos | 0:1b92bdad27f6 | 214 | IODAT6:1, |
nikmaos | 0:1b92bdad27f6 | 215 | IODAT7:1; |
nikmaos | 0:1b92bdad27f6 | 216 | }; |
nikmaos | 0:1b92bdad27f6 | 217 | uint8_t all; |
nikmaos | 0:1b92bdad27f6 | 218 | }GPIODAT_t; |
nikmaos | 0:1b92bdad27f6 | 219 | |
nikmaos | 0:1b92bdad27f6 | 220 | //архетип устройства |
nikmaos | 0:1b92bdad27f6 | 221 | typedef struct{ |
nikmaos | 0:1b92bdad27f6 | 222 | MUX0_t MUX0; |
nikmaos | 0:1b92bdad27f6 | 223 | VBIAS_t VBIAS; |
nikmaos | 0:1b92bdad27f6 | 224 | MUX1_t MUX1; |
nikmaos | 0:1b92bdad27f6 | 225 | SYS0_t SYS0; |
nikmaos | 0:1b92bdad27f6 | 226 | OFC_t OFC; |
nikmaos | 0:1b92bdad27f6 | 227 | FSC_t FSC; |
nikmaos | 0:1b92bdad27f6 | 228 | IDAC0_t IDAC0; |
nikmaos | 0:1b92bdad27f6 | 229 | IDAC1_t IDAC1; |
nikmaos | 0:1b92bdad27f6 | 230 | GPIOCFG_t GPIOCFG; |
nikmaos | 0:1b92bdad27f6 | 231 | GPIODIR_t GPIODIR; |
nikmaos | 0:1b92bdad27f6 | 232 | GPIODAT_t GPIODAT; |
nikmaos | 0:1b92bdad27f6 | 233 | }ADS1248_t; |
nikmaos | 0:1b92bdad27f6 | 234 | |
nikmaos | 0:1b92bdad27f6 | 235 | unsigned char ADS1248SleepCommand( void ); |
nikmaos | 0:1b92bdad27f6 | 236 | |
nikmaos | 0:1b92bdad27f6 | 237 | unsigned char ADS1248WakeupCommand( void ); |
nikmaos | 0:1b92bdad27f6 | 238 | |
nikmaos | 0:1b92bdad27f6 | 239 | unsigned char ADS1248ReadRegister( unsigned char reg, unsigned char num ); |
nikmaos | 0:1b92bdad27f6 | 240 | |
nikmaos | 0:1b92bdad27f6 | 241 | unsigned char ADS1248WriteRegister( unsigned char reg, unsigned char num, unsigned char data ); |
nikmaos | 0:1b92bdad27f6 | 242 | |
nikmaos | 0:1b92bdad27f6 | 243 | unsigned char ADS1248StartConversion( void ); |
nikmaos | 0:1b92bdad27f6 | 244 | |
nikmaos | 0:1b92bdad27f6 | 245 | unsigned long ADS1248ReadData( ADS1248_t * ads ); |
nikmaos | 0:1b92bdad27f6 | 246 | |
nikmaos | 0:1b92bdad27f6 | 247 | unsigned char ADS1248SettingReg ( ADS1248_t * ads ); |
nikmaos | 0:1b92bdad27f6 | 248 | |
nikmaos | 0:1b92bdad27f6 | 249 | #endif /*ADS1248_H*/ |
nikmaos | 0:1b92bdad27f6 | 250 |