adc13  2.0.0.0
adc13.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef ADC13_H
29 #define ADC13_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
48 #include "spi_specifics.h"
49 #include "math.h"
50 
71 #define ADC13_CMD_NOP 0x00
72 #define ADC13_CMD_RESET 0x06
73 #define ADC13_CMD_START1 0x08
74 #define ADC13_CMD_STOP1 0x0A
75 #define ADC13_CMD_START2 0x0C
76 #define ADC13_CMD_STOP2 0x0E
77 #define ADC13_CMD_RDATA1 0x12
78 #define ADC13_CMD_RDATA2 0x14
79 #define ADC13_CMD_SYOCAL1 0x16
80 #define ADC13_CMD_SYGCAL1 0x17
81 #define ADC13_CMD_SFOCAL1 0x19
82 #define ADC13_CMD_SYOCAL2 0x1B
83 #define ADC13_CMD_SYGCAL2 0x1C
84 #define ADC13_CMD_SFOCAL2 0x1E
85 #define ADC13_CMD_RREG 0x20
86 #define ADC13_CMD_WREG 0x40
87  // adc13_cmd
89 
104 #define ADC13_REG_ID 0x00
105 #define ADC13_REG_POWER 0x01
106 #define ADC13_REG_INTERFACE 0x02
107 #define ADC13_REG_MODE0 0x03
108 #define ADC13_REG_MODE1 0x04
109 #define ADC13_REG_MODE2 0x05
110 #define ADC13_REG_INPMUX 0x06
111 #define ADC13_REG_OFCAL0 0x07
112 #define ADC13_REG_OFCAL1 0x08
113 #define ADC13_REG_OFCAL2 0x09
114 #define ADC13_REG_FSCAL0 0x0A
115 #define ADC13_REG_FSCAL1 0x0B
116 #define ADC13_REG_FSCAL2 0x0C
117 #define ADC13_REG_IDACMUX 0x0D
118 #define ADC13_REG_IDACMAG 0x0E
119 #define ADC13_REG_REFMUX 0x0F
120 #define ADC13_REG_TDACP 0x10
121 #define ADC13_REG_TDACN 0x11
122 #define ADC13_REG_GPIOCON 0x12
123 #define ADC13_REG_GPIODIR 0x13
124 #define ADC13_REG_GPIODAT 0x14
125  // adc13_reg
127 
142 #define ADC13_ID_DEV_MASK 0xE0
143 #define ADC13_ID_REV_MASK 0x1F
144 #define ADC13_POWER_RESET_MASK 0x10
145 #define ADC13_POWER_VBIAS_MASK 0x02
146 #define ADC13_POWER_INTREF_MASK 0x01
147 #define ADC13_INTERFACE_TIMEOUT_MASK 0x08
148 #define ADC13_INTERFACE_STATUS_MASK 0x04
149 #define ADC13_INTERFACE_CRC_MASK 0x03
150 #define ADC13_MODE0_REFREV_MASK 0x80
151 #define ADC13_MODE0_RUN_MODE_MASK 0x40
152 #define ADC13_MODE0_CHOP_MASK 0x30
153 #define ADC13_MODE0_DELAY_MASK 0x0F
154 #define ADC13_MODE1_FILTER_MASK 0xE0
155 #define ADC13_MODE1_SBADC_MASK 0x10
156 #define ADC13_MODE1_SBPOL_MASK 0x08
157 #define ADC13_MODE1_SBMAG_MASK 0x07
158 #define ADC13_MODE2_BYPASS_MASK 0x80
159 #define ADC13_MODE2_GAIN_MASK 0x70
160 #define ADC13_MODE2_DR_MASK 0x0F
161 #define ADC13_INPMUX_MUXP_MASK 0xF0
162 #define ADC13_INPMUX_MUXN_MASK 0x0F
163 #define ADC13_IDACMUX_MUX2_MASK 0xF0
164 #define ADC13_IDACMUX_MUX1_MASK 0x0F
165 #define ADC13_IDACMAG_MAG2_MASK 0xF0
166 #define ADC13_IDACMAG_MAG1_MASK 0x0F
167 #define ADC13_REFMUX_RMUXP_MASK 0x38
168 #define ADC13_REFMUX_RMUXN_MASK 0x07
169 #define ADC13_TDACP_OUTP_MASK 0x80
170 #define ADC13_TDACP_MAGP_MASK 0x1F
171 #define ADC13_TDACN_OUTN_MASK 0x80
172 #define ADC13_TDACN_MAGN_MASK 0x1F
173 #define ADC13_REG_COUNT_MASK 0x1F
174 
179 #define ADC13_STATUS_ADC2_NEW_DATA 0x80
180 #define ADC13_STATUS_ADC1_NEW_DATA 0x40
181 #define ADC13_STATUS_EXTCLK_EXTERNAL 0x20
182 #define ADC13_STATUS_REF_ALM_LOW_REF 0x10
183 #define ADC13_STATUS_PGAL_ALM_LOW_VOLTAGE 0x08
184 #define ADC13_STATUS_PGAH_ALM_HIGH_VOLTAGE 0x04
185 #define ADC13_STATUS_PGAD_ALM_DIFF_RANGE 0x02
186 #define ADC13_STATUS_RESET_OCCURRED 0x01
187 
192 #define ADC13_POWER_RESET_NO_NEW_RESET 0
193 #define ADC13_POWER_RESET_OCCURRED 1
194 #define ADC13_POWER_VBIAS_DISABLE 0
195 #define ADC13_POWER_VBIAS_ENABLE 1
196 #define ADC13_POWER_INTREF_DISABLE 0
197 #define ADC13_POWER_INTREF_ENABLE 1
198 
203 #define ADC13_INTERFACE_TIMEOUT_DISABLE 0
204 #define ADC13_INTERFACE_TIMEOUT_ENABLE 1
205 #define ADC13_INTERFACE_STATUS_DISABLE 0
206 #define ADC13_INTERFACE_STATUS_ENABLE 1
207 #define ADC13_INTERFACE_CRC_DISABLE 0
208 #define ADC13_INTERFACE_CRC_ENABLE_CHECKSUM 1
209 #define ADC13_INTERFACE_CRC_ENABLE_CRC 2
210 
215 #define ADC13_MODE0_REFREV_NORMAL 0
216 #define ADC13_MODE0_REFREV_REVERSE 1
217 #define ADC13_MODE0_RUN_MODE_CONTINUOUS 0
218 #define ADC13_MODE0_RUN_MODE_ONE_SHOT 1
219 #define ADC13_MODE0_CHOP_DISABLE 0
220 #define ADC13_MODE0_CHOP_ENABLE 1
221 #define ADC13_MODE0_CHOP_IDAC_ENABLE 2
222 #define ADC13_MODE0_CHOP_AND_IDAC_ENABLE 3
223 #define ADC13_MODE0_DELAY_NO_DELAY 0
224 #define ADC13_MODE0_DELAY_8p7uS 1
225 #define ADC13_MODE0_DELAY_17uS 2
226 #define ADC13_MODE0_DELAY_35uS 3
227 #define ADC13_MODE0_DELAY_69uS 4
228 #define ADC13_MODE0_DELAY_139uS 5
229 #define ADC13_MODE0_DELAY_278uS 6
230 #define ADC13_MODE0_DELAY_555uS 7
231 #define ADC13_MODE0_DELAY_1p1mS 8
232 #define ADC13_MODE0_DELAY_2p2mS 9
233 #define ADC13_MODE0_DELAY_4p4mS 10
234 #define ADC13_MODE0_DELAY_8p8mS 11
235 
240 #define ADC13_MODE1_FILTER_SINC1_MODE 0
241 #define ADC13_MODE1_FILTER_SINC2_MODE 1
242 #define ADC13_MODE1_FILTER_SINC3_MODE 2
243 #define ADC13_MODE1_FILTER_SINC4_MODE 3
244 #define ADC13_MODE1_FILTER_FIR_MODE 4
245 #define ADC13_MODE1_SBADC_ADC1_OUT 0
246 #define ADC13_MODE1_SBADC_ADC2_OUT 1
247 #define ADC13_MODE1_SBPOL_PULLUP_MODE 0
248 #define ADC13_MODE1_SBPOL_PULLDOWN_MODE 1
249 #define ADC13_MODE1_SBMAG_NO_CURR_NO_RES 0
250 #define ADC13_MODE1_SBMAG_0p5uA_CURR 1
251 #define ADC13_MODE1_SBMAG_2uA_CURR 2
252 #define ADC13_MODE1_SBMAG_10uA_CURR 3
253 #define ADC13_MODE1_SBMAG_50uA_CURR 4
254 #define ADC13_MODE1_SBMAG_200uA_CURR 5
255 #define ADC13_MODE1_SBMAG_10MOHM_RES 6
256 
261 #define ADC13_MODE2_BYPASS_PGA_ENABLED 0
262 #define ADC13_MODE2_BYPASS_PGA_BYPASSED 1
263 #define ADC13_MODE2_GAIN_1 0
264 #define ADC13_MODE2_GAIN_2 1
265 #define ADC13_MODE2_GAIN_4 2
266 #define ADC13_MODE2_GAIN_8 3
267 #define ADC13_MODE2_GAIN_16 4
268 #define ADC13_MODE2_GAIN_32 5
269 #define ADC13_MODE2_DR_2p5SPS 0
270 #define ADC13_MODE2_DR_5SPS 1
271 #define ADC13_MODE2_DR_10SPS 2
272 #define ADC13_MODE2_DR_16p6SPS 3
273 #define ADC13_MODE2_DR_20SPS 4
274 #define ADC13_MODE2_DR_50SPS 5
275 #define ADC13_MODE2_DR_60SPS 6
276 #define ADC13_MODE2_DR_100SPS 7
277 #define ADC13_MODE2_DR_400SPS 8
278 #define ADC13_MODE2_DR_1200SPS 9
279 #define ADC13_MODE2_DR_2400SPS 10
280 #define ADC13_MODE2_DR_4800SPS 11
281 #define ADC13_MODE2_DR_7200SPS 12
282 #define ADC13_MODE2_DR_14400SPS 13
283 #define ADC13_MODE2_DR_19200SPS 14
284 #define ADC13_MODE2_DR_38400SPS 15
285 
290 #define ADC13_INPMUX_MUXP_AIN0 0
291 #define ADC13_INPMUX_MUXP_AIN1 1
292 #define ADC13_INPMUX_MUXP_AIN2 2
293 #define ADC13_INPMUX_MUXP_AIN3 3
294 #define ADC13_INPMUX_MUXP_AIN4 4
295 #define ADC13_INPMUX_MUXP_AIN5 5
296 #define ADC13_INPMUX_MUXP_AIN6 6
297 #define ADC13_INPMUX_MUXP_AIN7 7
298 #define ADC13_INPMUX_MUXP_AIN8 8
299 #define ADC13_INPMUX_MUXP_AIN9 9
300 #define ADC13_INPMUX_MUXP_AINCOM 10
301 #define ADC13_INPMUX_MUXP_TEMP_SENSOR_POS 11
302 #define ADC13_INPMUX_MUXP_AN_POW_SUPP_POS 12
303 #define ADC13_INPMUX_MUXP_DIG_POW_SUPP_POS 13
304 #define ADC13_INPMUX_MUXP_TDAC_POS 14
305 #define ADC13_INPMUX_MUXP_FLOAT 15
306 #define ADC13_INPMUX_MUXN_AIN0 0
307 #define ADC13_INPMUX_MUXN_AIN1 1
308 #define ADC13_INPMUX_MUXN_AIN2 2
309 #define ADC13_INPMUX_MUXN_AIN3 3
310 #define ADC13_INPMUX_MUXN_AIN4 4
311 #define ADC13_INPMUX_MUXN_AIN5 5
312 #define ADC13_INPMUX_MUXN_AIN6 6
313 #define ADC13_INPMUX_MUXN_AIN7 7
314 #define ADC13_INPMUX_MUXN_AIN8 8
315 #define ADC13_INPMUX_MUXN_AIN9 9
316 #define ADC13_INPMUX_MUXN_AINCOM 10
317 #define ADC13_INPMUX_MUXN_TEMP_SENSOR_NEG 11
318 #define ADC13_INPMUX_MUXN_AN_POW_SUPP_NEG 12
319 #define ADC13_INPMUX_MUXN_DIG_POW_SUPP_NEG 13
320 #define ADC13_INPMUX_MUXN_TDAC_NEG 14
321 #define ADC13_INPMUX_MUXN_FLOAT 15
322 
327 #define ADC13_IDACMUX_MUX2_AIN0 0
328 #define ADC13_IDACMUX_MUX2_AIN1 1
329 #define ADC13_IDACMUX_MUX2_AIN2 2
330 #define ADC13_IDACMUX_MUX2_AIN3 3
331 #define ADC13_IDACMUX_MUX2_AIN4 4
332 #define ADC13_IDACMUX_MUX2_AIN5 5
333 #define ADC13_IDACMUX_MUX2_AIN6 6
334 #define ADC13_IDACMUX_MUX2_AIN7 7
335 #define ADC13_IDACMUX_MUX2_AIN8 8
336 #define ADC13_IDACMUX_MUX2_AIN9 9
337 #define ADC13_IDACMUX_MUX2_AINCOM 10
338 #define ADC13_IDACMUX_MUX2_NO_CONNECTION 11
339 #define ADC13_IDACMUX_MUX1_AIN0 0
340 #define ADC13_IDACMUX_MUX1_AIN1 1
341 #define ADC13_IDACMUX_MUX1_AIN2 2
342 #define ADC13_IDACMUX_MUX1_AIN3 3
343 #define ADC13_IDACMUX_MUX1_AIN4 4
344 #define ADC13_IDACMUX_MUX1_AIN5 5
345 #define ADC13_IDACMUX_MUX1_AIN6 6
346 #define ADC13_IDACMUX_MUX1_AIN7 7
347 #define ADC13_IDACMUX_MUX1_AIN8 8
348 #define ADC13_IDACMUX_MUX1_AIN9 9
349 #define ADC13_IDACMUX_MUX1_AINCOM 10
350 #define ADC13_IDACMUX_MUX1_NO_CONNECTION 11
351 
356 #define ADC13_IDACMAG_MAG2_OFF 0
357 #define ADC13_IDACMAG_MAG2_50uA 1
358 #define ADC13_IDACMAG_MAG2_100uA 2
359 #define ADC13_IDACMAG_MAG2_250uA 3
360 #define ADC13_IDACMAG_MAG2_500uA 4
361 #define ADC13_IDACMAG_MAG2_750uA 5
362 #define ADC13_IDACMAG_MAG2_1000uA 6
363 #define ADC13_IDACMAG_MAG2_1500uA 7
364 #define ADC13_IDACMAG_MAG2_2000uA 8
365 #define ADC13_IDACMAG_MAG2_2500uA 9
366 #define ADC13_IDACMAG_MAG2_3000uA 10
367 #define ADC13_IDACMAG_MAG1_OFF 0
368 #define ADC13_IDACMAG_MAG1_50uA 1
369 #define ADC13_IDACMAG_MAG1_100uA 2
370 #define ADC13_IDACMAG_MAG1_250uA 3
371 #define ADC13_IDACMAG_MAG1_500uA 4
372 #define ADC13_IDACMAG_MAG1_750uA 5
373 #define ADC13_IDACMAG_MAG1_1000uA 6
374 #define ADC13_IDACMAG_MAG1_1500uA 7
375 #define ADC13_IDACMAG_MAG1_2000uA 8
376 #define ADC13_IDACMAG_MAG1_2500uA 9
377 #define ADC13_IDACMAG_MAG1_3000uA 10
378 
383 #define ADC13_REFMUX_RMUXP_INTERNAL 0
384 #define ADC13_REFMUX_RMUXP_EXT_AIN0 1
385 #define ADC13_REFMUX_RMUXP_EXT_AIN2 2
386 #define ADC13_REFMUX_RMUXP_EXT_AIN4 3
387 #define ADC13_REFMUX_RMUXP_INTERNAL_AVDD 4
388 #define ADC13_REFMUX_RMUXN_INTERNAL 0
389 #define ADC13_REFMUX_RMUXN_EXT_AIN1 1
390 #define ADC13_REFMUX_RMUXN_EXT_AIN3 2
391 #define ADC13_REFMUX_RMUXN_EXT_AIN5 3
392 #define ADC13_REFMUX_RMUXN_INTERNAL_AVSS 4
393 
398 #define ADC13_TDACP_OUTP_NO_CONNECTION 0
399 #define ADC13_TDACP_OUTP_AIN6 1
400 #define ADC13_TDACP_MAGP_4p5V 9
401 #define ADC13_TDACP_MAGP_3p5V 8
402 #define ADC13_TDACP_MAGP_3V 7
403 #define ADC13_TDACP_MAGP_2p75V 6
404 #define ADC13_TDACP_MAGP_2p625V 5
405 #define ADC13_TDACP_MAGP_2p5625V 4
406 #define ADC13_TDACP_MAGP_2p53125V 3
407 #define ADC13_TDACP_MAGP_2p515625V 2
408 #define ADC13_TDACP_MAGP_2p5078125V 1
409 #define ADC13_TDACP_MAGP_2p5V 0
410 #define ADC13_TDACP_MAGP_2p4921875V 17
411 #define ADC13_TDACP_MAGP_2p484375V 18
412 #define ADC13_TDACP_MAGP_2p46875V 19
413 #define ADC13_TDACP_MAGP_2p4375V 20
414 #define ADC13_TDACP_MAGP_2p375V 21
415 #define ADC13_TDACP_MAGP_2p25V 22
416 #define ADC13_TDACP_MAGP_2V 23
417 #define ADC13_TDACP_MAGP_1p5V 24
418 #define ADC13_TDACP_MAGP_0p5V 25
419 
424 #define ADC13_TDACN_OUTN_NO_CONNECTION 0
425 #define ADC13_TDACN_OUTN_AIN7 1
426 #define ADC13_TDACN_MAGN_4p5V 9
427 #define ADC13_TDACN_MAGN_3p5V 8
428 #define ADC13_TDACN_MAGN_3V 7
429 #define ADC13_TDACN_MAGN_2p75V 6
430 #define ADC13_TDACN_MAGN_2p625V 5
431 #define ADC13_TDACN_MAGN_2p5625V 4
432 #define ADC13_TDACN_MAGN_2p53125V 3
433 #define ADC13_TDACN_MAGN_2p515625V 2
434 #define ADC13_TDACN_MAGN_2p5078125V 1
435 #define ADC13_TDACN_MAGN_2p5V 0
436 #define ADC13_TDACN_MAGN_2p4921875V 17
437 #define ADC13_TDACN_MAGN_2p484375V 18
438 #define ADC13_TDACN_MAGN_2p46875V 19
439 #define ADC13_TDACN_MAGN_2p4375V 20
440 #define ADC13_TDACN_MAGN_2p375V 21
441 #define ADC13_TDACN_MAGN_2p25V 22
442 #define ADC13_TDACN_MAGN_2V 23
443 #define ADC13_TDACN_MAGN_1p5V 24
444 #define ADC13_TDACN_MAGN_0p5V 25
445 
450 #define ADC13_GPIO0 0x01
451 #define ADC13_GPIO1 0x02
452 #define ADC13_GPIO2 0x04
453 #define ADC13_GPIO3 0x08
454 #define ADC13_GPIO4 0x10
455 #define ADC13_GPIO5 0x20
456 #define ADC13_GPIO6 0x40
457 #define ADC13_GPIO7 0x80
458 
463 #define ADC13_VREF_INTERNAL 2.5
464 #define ADC13_VREF_INTERNAL_AVDD 5
465 #define ADC13_VREF_3V3 3.3
466 #define ADC13_VREF_5V 5
467 
472 #define ADC13_CHECKSUM_CONSTANT 0x9B
473 
478 #define ADC13_TEMP_MILIVOLTS 122.4
479 #define ADC13_TEMP_V_TO_MV 1000
480 #define ADC13_TEMP_COEFF 0.42
481 #define ADC13_TEMP_OFFSET 25.0
482 #define ADC13_TEMP_HEAT_OFFSET 0.7
483 
488 #define GET_RIGHTMOST_SET_BIT( bit_mask ) ( uint8_t )( log10( ( double ) \
489  ( bit_mask & ~( bit_mask - 1 ) ) ) / log10( 2.0 ) )
490 
495 #define SET_REG_BITS( reg_data, bit_mask, in_data ) ( ( reg_data & ~( bit_mask ) ) | \
496  ( ( in_data << GET_RIGHTMOST_SET_BIT( bit_mask ) ) \
497  & bit_mask ) )
498 
503 #define GET_REG_BITS( reg_data, bit_mask ) ( ( reg_data & bit_mask ) >> GET_RIGHTMOST_SET_BIT( bit_mask ) )
504 
513 #define ADC13_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
514 #define ADC13_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
515  // adc13_set
517 
532 #define ADC13_MAP_MIKROBUS( cfg, mikrobus ) \
533  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
534  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
535  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
536  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
537  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
538  cfg.str = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
539  cfg.dtr = MIKROBUS( mikrobus, MIKROBUS_INT )
540  // adc13_map // adc13
543 
548 typedef struct
549 {
550  // Output pins
551  digital_out_t rst;
552  digital_out_t str;
554  // Input pins
555  digital_in_t dtr;
557  // Modules
558  spi_master_t spi;
560  pin_name_t chip_select;
562 } adc13_t;
563 
568 typedef struct
569 {
570  // Communication gpio pins
571  pin_name_t miso;
572  pin_name_t mosi;
573  pin_name_t sck;
574  pin_name_t cs;
576  // Additional gpio pins
577  pin_name_t rst;
578  pin_name_t str;
579  pin_name_t dtr;
581  // static variable
582  uint32_t spi_speed;
583  spi_master_mode_t spi_mode;
584  spi_master_chip_select_polarity_t cs_polarity;
586 } adc13_cfg_t;
587 
592 typedef enum
593 {
594  ADC13_OK = 0,
595  ADC13_ERROR = -1
596 
598 
615 
630 err_t adc13_init ( adc13_t *ctx, adc13_cfg_t *cfg );
631 
645 err_t adc13_default_cfg ( adc13_t *ctx );
646 
662 err_t adc13_generic_write ( adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
663 
679 err_t adc13_generic_read ( adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
680 
694 err_t adc13_send_command ( adc13_t *ctx, uint8_t cmd );
695 
705 void adc13_set_str_pin ( adc13_t *ctx, uint8_t state );
706 
716 void adc13_set_rst_pin ( adc13_t *ctx, uint8_t state );
717 
726 uint8_t adc13_get_dtr_pin ( adc13_t *ctx );
727 
737 
750 
759 void adc13_power_down ( adc13_t *ctx );
760 
769 void adc13_power_up ( adc13_t *ctx );
770 
784 err_t adc13_read_register ( adc13_t *ctx, uint8_t reg, uint8_t *data_out );
785 
799 err_t adc13_write_register ( adc13_t *ctx, uint8_t reg, uint8_t data_in );
800 
816 err_t adc13_read_registers ( adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t count );
817 
833 err_t adc13_write_registers ( adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t count );
834 
850 err_t adc13_set_register_bits ( adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t data_in );
851 
866 err_t adc13_get_register_bits ( adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t *data_out );
867 
880 err_t adc13_read_raw_data ( adc13_t *ctx, int32_t *data_out );
881 
896 err_t adc13_measure_voltage ( adc13_t *ctx, float vref, float *voltage );
897 
910 err_t adc13_measure_temperature ( adc13_t *ctx, float *temperature );
911 
925 err_t adc13_set_input_channel ( adc13_t *ctx, uint8_t pos, uint8_t neg );
926 
940 err_t adc13_set_voltage_reference ( adc13_t *ctx, uint8_t pos, uint8_t neg );
941 
954 err_t adc13_set_gain ( adc13_t *ctx, uint8_t gain );
955 
968 err_t adc13_set_sample_rate ( adc13_t *ctx, uint8_t s_rate );
969 
970 #ifdef __cplusplus
971 }
972 #endif
973 #endif // ADC13_H
974  // adc13
976 
977 // ------------------------------------------------------------------------ END
adc13_return_value_t
adc13_return_value_t
ADC 13 Click return value data.
Definition: adc13.h:593
adc13_power_down
void adc13_power_down(adc13_t *ctx)
ADC 13 power down function.
adc13_set_rst_pin
void adc13_set_rst_pin(adc13_t *ctx, uint8_t state)
ADC 13 set RST pin function.
adc13_t::dtr
digital_in_t dtr
Definition: adc13.h:555
adc13_cfg_t::rst
pin_name_t rst
Definition: adc13.h:577
adc13_cfg_t::cs
pin_name_t cs
Definition: adc13.h:574
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adc13_measure_temperature
err_t adc13_measure_temperature(adc13_t *ctx, float *temperature)
ADC 13 measure temperature function.
adc13_cfg_t::miso
pin_name_t miso
Definition: adc13.h:571
adc13_read_raw_data
err_t adc13_read_raw_data(adc13_t *ctx, int32_t *data_out)
ADC 13 read raw data function.
adc13_write_registers
err_t adc13_write_registers(adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t count)
ADC 13 write registers function.
adc13_init
err_t adc13_init(adc13_t *ctx, adc13_cfg_t *cfg)
ADC 13 initialization function.
adc13_generic_read
err_t adc13_generic_read(adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
ADC 13 data reading function.
adc13_read_registers
err_t adc13_read_registers(adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t count)
ADC 13 read registers function.
adc13_t::chip_select
pin_name_t chip_select
Definition: adc13.h:560
adc13_cfg_t::spi_speed
uint32_t spi_speed
Definition: adc13.h:582
adc13_set_register_bits
err_t adc13_set_register_bits(adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t data_in)
ADC 13 set register bits function.
adc13_read_register
err_t adc13_read_register(adc13_t *ctx, uint8_t reg, uint8_t *data_out)
ADC 13 read register function.
ADC13_OK
@ ADC13_OK
Definition: adc13.h:594
adc13_power_up
void adc13_power_up(adc13_t *ctx)
ADC 13 power up function.
adc13_get_register_bits
err_t adc13_get_register_bits(adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t *data_out)
ADC 13 get register bits function.
adc13_cfg_t
ADC 13 Click configuration object.
Definition: adc13.h:569
adc13_default_cfg
err_t adc13_default_cfg(adc13_t *ctx)
ADC 13 default configuration function.
adc13_cfg_setup
void adc13_cfg_setup(adc13_cfg_t *cfg)
ADC 13 configuration object setup function.
adc13_cfg_t::sck
pin_name_t sck
Definition: adc13.h:573
adc13_cfg_t::dtr
pin_name_t dtr
Definition: adc13.h:579
adc13_reset_by_pin
void adc13_reset_by_pin(adc13_t *ctx)
ADC 13 reset by pin function.
adc13_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adc13.h:583
adc13_t::str
digital_out_t str
Definition: adc13.h:552
adc13_generic_write
err_t adc13_generic_write(adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
ADC 13 data writing function.
adc13_get_dtr_pin
uint8_t adc13_get_dtr_pin(adc13_t *ctx)
ADC 13 get DTR pin function.
adc13_set_input_channel
err_t adc13_set_input_channel(adc13_t *ctx, uint8_t pos, uint8_t neg)
ADC 13 set input channel function.
adc13_set_voltage_reference
err_t adc13_set_voltage_reference(adc13_t *ctx, uint8_t pos, uint8_t neg)
ADC 13 set voltage reference function.
adc13_send_command
err_t adc13_send_command(adc13_t *ctx, uint8_t cmd)
ADC 13 send command function.
ADC13_ERROR
@ ADC13_ERROR
Definition: adc13.h:595
adc13_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adc13.h:584
adc13_cfg_t::mosi
pin_name_t mosi
Definition: adc13.h:572
adc13_t::spi
spi_master_t spi
Definition: adc13.h:558
adc13_measure_voltage
err_t adc13_measure_voltage(adc13_t *ctx, float vref, float *voltage)
ADC 13 measure voltage function.
adc13_set_sample_rate
err_t adc13_set_sample_rate(adc13_t *ctx, uint8_t s_rate)
ADC 13 set sample rate function.
adc13_set_str_pin
void adc13_set_str_pin(adc13_t *ctx, uint8_t state)
ADC 13 set STR pin function.
adc13_cfg_t::str
pin_name_t str
Definition: adc13.h:578
adc13_reset_by_command
err_t adc13_reset_by_command(adc13_t *ctx)
ADC 13 reset by command function.
adc13_t::rst
digital_out_t rst
Definition: adc13.h:551
adc13_write_register
err_t adc13_write_register(adc13_t *ctx, uint8_t reg, uint8_t data_in)
ADC 13 write register function.
adc13_set_gain
err_t adc13_set_gain(adc13_t *ctx, uint8_t gain)
ADC 13 set gain function.
adc13_t
ADC 13 Click context object.
Definition: adc13.h:549