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
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "spi_specifics.h"
53#include "math.h"
54
75#define ADC13_CMD_NOP 0x00
76#define ADC13_CMD_RESET 0x06
77#define ADC13_CMD_START1 0x08
78#define ADC13_CMD_STOP1 0x0A
79#define ADC13_CMD_START2 0x0C
80#define ADC13_CMD_STOP2 0x0E
81#define ADC13_CMD_RDATA1 0x12
82#define ADC13_CMD_RDATA2 0x14
83#define ADC13_CMD_SYOCAL1 0x16
84#define ADC13_CMD_SYGCAL1 0x17
85#define ADC13_CMD_SFOCAL1 0x19
86#define ADC13_CMD_SYOCAL2 0x1B
87#define ADC13_CMD_SYGCAL2 0x1C
88#define ADC13_CMD_SFOCAL2 0x1E
89#define ADC13_CMD_RREG 0x20
90#define ADC13_CMD_WREG 0x40
91
92 // adc13_cmd
93
108#define ADC13_REG_ID 0x00
109#define ADC13_REG_POWER 0x01
110#define ADC13_REG_INTERFACE 0x02
111#define ADC13_REG_MODE0 0x03
112#define ADC13_REG_MODE1 0x04
113#define ADC13_REG_MODE2 0x05
114#define ADC13_REG_INPMUX 0x06
115#define ADC13_REG_OFCAL0 0x07
116#define ADC13_REG_OFCAL1 0x08
117#define ADC13_REG_OFCAL2 0x09
118#define ADC13_REG_FSCAL0 0x0A
119#define ADC13_REG_FSCAL1 0x0B
120#define ADC13_REG_FSCAL2 0x0C
121#define ADC13_REG_IDACMUX 0x0D
122#define ADC13_REG_IDACMAG 0x0E
123#define ADC13_REG_REFMUX 0x0F
124#define ADC13_REG_TDACP 0x10
125#define ADC13_REG_TDACN 0x11
126#define ADC13_REG_GPIOCON 0x12
127#define ADC13_REG_GPIODIR 0x13
128#define ADC13_REG_GPIODAT 0x14
129
130 // adc13_reg
131
146#define ADC13_ID_DEV_MASK 0xE0
147#define ADC13_ID_REV_MASK 0x1F
148#define ADC13_POWER_RESET_MASK 0x10
149#define ADC13_POWER_VBIAS_MASK 0x02
150#define ADC13_POWER_INTREF_MASK 0x01
151#define ADC13_INTERFACE_TIMEOUT_MASK 0x08
152#define ADC13_INTERFACE_STATUS_MASK 0x04
153#define ADC13_INTERFACE_CRC_MASK 0x03
154#define ADC13_MODE0_REFREV_MASK 0x80
155#define ADC13_MODE0_RUN_MODE_MASK 0x40
156#define ADC13_MODE0_CHOP_MASK 0x30
157#define ADC13_MODE0_DELAY_MASK 0x0F
158#define ADC13_MODE1_FILTER_MASK 0xE0
159#define ADC13_MODE1_SBADC_MASK 0x10
160#define ADC13_MODE1_SBPOL_MASK 0x08
161#define ADC13_MODE1_SBMAG_MASK 0x07
162#define ADC13_MODE2_BYPASS_MASK 0x80
163#define ADC13_MODE2_GAIN_MASK 0x70
164#define ADC13_MODE2_DR_MASK 0x0F
165#define ADC13_INPMUX_MUXP_MASK 0xF0
166#define ADC13_INPMUX_MUXN_MASK 0x0F
167#define ADC13_IDACMUX_MUX2_MASK 0xF0
168#define ADC13_IDACMUX_MUX1_MASK 0x0F
169#define ADC13_IDACMAG_MAG2_MASK 0xF0
170#define ADC13_IDACMAG_MAG1_MASK 0x0F
171#define ADC13_REFMUX_RMUXP_MASK 0x38
172#define ADC13_REFMUX_RMUXN_MASK 0x07
173#define ADC13_TDACP_OUTP_MASK 0x80
174#define ADC13_TDACP_MAGP_MASK 0x1F
175#define ADC13_TDACN_OUTN_MASK 0x80
176#define ADC13_TDACN_MAGN_MASK 0x1F
177#define ADC13_REG_COUNT_MASK 0x1F
178
183#define ADC13_STATUS_ADC2_NEW_DATA 0x80
184#define ADC13_STATUS_ADC1_NEW_DATA 0x40
185#define ADC13_STATUS_EXTCLK_EXTERNAL 0x20
186#define ADC13_STATUS_REF_ALM_LOW_REF 0x10
187#define ADC13_STATUS_PGAL_ALM_LOW_VOLTAGE 0x08
188#define ADC13_STATUS_PGAH_ALM_HIGH_VOLTAGE 0x04
189#define ADC13_STATUS_PGAD_ALM_DIFF_RANGE 0x02
190#define ADC13_STATUS_RESET_OCCURRED 0x01
191
196#define ADC13_POWER_RESET_NO_NEW_RESET 0
197#define ADC13_POWER_RESET_OCCURRED 1
198#define ADC13_POWER_VBIAS_DISABLE 0
199#define ADC13_POWER_VBIAS_ENABLE 1
200#define ADC13_POWER_INTREF_DISABLE 0
201#define ADC13_POWER_INTREF_ENABLE 1
202
207#define ADC13_INTERFACE_TIMEOUT_DISABLE 0
208#define ADC13_INTERFACE_TIMEOUT_ENABLE 1
209#define ADC13_INTERFACE_STATUS_DISABLE 0
210#define ADC13_INTERFACE_STATUS_ENABLE 1
211#define ADC13_INTERFACE_CRC_DISABLE 0
212#define ADC13_INTERFACE_CRC_ENABLE_CHECKSUM 1
213#define ADC13_INTERFACE_CRC_ENABLE_CRC 2
214
219#define ADC13_MODE0_REFREV_NORMAL 0
220#define ADC13_MODE0_REFREV_REVERSE 1
221#define ADC13_MODE0_RUN_MODE_CONTINUOUS 0
222#define ADC13_MODE0_RUN_MODE_ONE_SHOT 1
223#define ADC13_MODE0_CHOP_DISABLE 0
224#define ADC13_MODE0_CHOP_ENABLE 1
225#define ADC13_MODE0_CHOP_IDAC_ENABLE 2
226#define ADC13_MODE0_CHOP_AND_IDAC_ENABLE 3
227#define ADC13_MODE0_DELAY_NO_DELAY 0
228#define ADC13_MODE0_DELAY_8p7uS 1
229#define ADC13_MODE0_DELAY_17uS 2
230#define ADC13_MODE0_DELAY_35uS 3
231#define ADC13_MODE0_DELAY_69uS 4
232#define ADC13_MODE0_DELAY_139uS 5
233#define ADC13_MODE0_DELAY_278uS 6
234#define ADC13_MODE0_DELAY_555uS 7
235#define ADC13_MODE0_DELAY_1p1mS 8
236#define ADC13_MODE0_DELAY_2p2mS 9
237#define ADC13_MODE0_DELAY_4p4mS 10
238#define ADC13_MODE0_DELAY_8p8mS 11
239
244#define ADC13_MODE1_FILTER_SINC1_MODE 0
245#define ADC13_MODE1_FILTER_SINC2_MODE 1
246#define ADC13_MODE1_FILTER_SINC3_MODE 2
247#define ADC13_MODE1_FILTER_SINC4_MODE 3
248#define ADC13_MODE1_FILTER_FIR_MODE 4
249#define ADC13_MODE1_SBADC_ADC1_OUT 0
250#define ADC13_MODE1_SBADC_ADC2_OUT 1
251#define ADC13_MODE1_SBPOL_PULLUP_MODE 0
252#define ADC13_MODE1_SBPOL_PULLDOWN_MODE 1
253#define ADC13_MODE1_SBMAG_NO_CURR_NO_RES 0
254#define ADC13_MODE1_SBMAG_0p5uA_CURR 1
255#define ADC13_MODE1_SBMAG_2uA_CURR 2
256#define ADC13_MODE1_SBMAG_10uA_CURR 3
257#define ADC13_MODE1_SBMAG_50uA_CURR 4
258#define ADC13_MODE1_SBMAG_200uA_CURR 5
259#define ADC13_MODE1_SBMAG_10MOHM_RES 6
260
265#define ADC13_MODE2_BYPASS_PGA_ENABLED 0
266#define ADC13_MODE2_BYPASS_PGA_BYPASSED 1
267#define ADC13_MODE2_GAIN_1 0
268#define ADC13_MODE2_GAIN_2 1
269#define ADC13_MODE2_GAIN_4 2
270#define ADC13_MODE2_GAIN_8 3
271#define ADC13_MODE2_GAIN_16 4
272#define ADC13_MODE2_GAIN_32 5
273#define ADC13_MODE2_DR_2p5SPS 0
274#define ADC13_MODE2_DR_5SPS 1
275#define ADC13_MODE2_DR_10SPS 2
276#define ADC13_MODE2_DR_16p6SPS 3
277#define ADC13_MODE2_DR_20SPS 4
278#define ADC13_MODE2_DR_50SPS 5
279#define ADC13_MODE2_DR_60SPS 6
280#define ADC13_MODE2_DR_100SPS 7
281#define ADC13_MODE2_DR_400SPS 8
282#define ADC13_MODE2_DR_1200SPS 9
283#define ADC13_MODE2_DR_2400SPS 10
284#define ADC13_MODE2_DR_4800SPS 11
285#define ADC13_MODE2_DR_7200SPS 12
286#define ADC13_MODE2_DR_14400SPS 13
287#define ADC13_MODE2_DR_19200SPS 14
288#define ADC13_MODE2_DR_38400SPS 15
289
294#define ADC13_INPMUX_MUXP_AIN0 0
295#define ADC13_INPMUX_MUXP_AIN1 1
296#define ADC13_INPMUX_MUXP_AIN2 2
297#define ADC13_INPMUX_MUXP_AIN3 3
298#define ADC13_INPMUX_MUXP_AIN4 4
299#define ADC13_INPMUX_MUXP_AIN5 5
300#define ADC13_INPMUX_MUXP_AIN6 6
301#define ADC13_INPMUX_MUXP_AIN7 7
302#define ADC13_INPMUX_MUXP_AIN8 8
303#define ADC13_INPMUX_MUXP_AIN9 9
304#define ADC13_INPMUX_MUXP_AINCOM 10
305#define ADC13_INPMUX_MUXP_TEMP_SENSOR_POS 11
306#define ADC13_INPMUX_MUXP_AN_POW_SUPP_POS 12
307#define ADC13_INPMUX_MUXP_DIG_POW_SUPP_POS 13
308#define ADC13_INPMUX_MUXP_TDAC_POS 14
309#define ADC13_INPMUX_MUXP_FLOAT 15
310#define ADC13_INPMUX_MUXN_AIN0 0
311#define ADC13_INPMUX_MUXN_AIN1 1
312#define ADC13_INPMUX_MUXN_AIN2 2
313#define ADC13_INPMUX_MUXN_AIN3 3
314#define ADC13_INPMUX_MUXN_AIN4 4
315#define ADC13_INPMUX_MUXN_AIN5 5
316#define ADC13_INPMUX_MUXN_AIN6 6
317#define ADC13_INPMUX_MUXN_AIN7 7
318#define ADC13_INPMUX_MUXN_AIN8 8
319#define ADC13_INPMUX_MUXN_AIN9 9
320#define ADC13_INPMUX_MUXN_AINCOM 10
321#define ADC13_INPMUX_MUXN_TEMP_SENSOR_NEG 11
322#define ADC13_INPMUX_MUXN_AN_POW_SUPP_NEG 12
323#define ADC13_INPMUX_MUXN_DIG_POW_SUPP_NEG 13
324#define ADC13_INPMUX_MUXN_TDAC_NEG 14
325#define ADC13_INPMUX_MUXN_FLOAT 15
326
331#define ADC13_IDACMUX_MUX2_AIN0 0
332#define ADC13_IDACMUX_MUX2_AIN1 1
333#define ADC13_IDACMUX_MUX2_AIN2 2
334#define ADC13_IDACMUX_MUX2_AIN3 3
335#define ADC13_IDACMUX_MUX2_AIN4 4
336#define ADC13_IDACMUX_MUX2_AIN5 5
337#define ADC13_IDACMUX_MUX2_AIN6 6
338#define ADC13_IDACMUX_MUX2_AIN7 7
339#define ADC13_IDACMUX_MUX2_AIN8 8
340#define ADC13_IDACMUX_MUX2_AIN9 9
341#define ADC13_IDACMUX_MUX2_AINCOM 10
342#define ADC13_IDACMUX_MUX2_NO_CONNECTION 11
343#define ADC13_IDACMUX_MUX1_AIN0 0
344#define ADC13_IDACMUX_MUX1_AIN1 1
345#define ADC13_IDACMUX_MUX1_AIN2 2
346#define ADC13_IDACMUX_MUX1_AIN3 3
347#define ADC13_IDACMUX_MUX1_AIN4 4
348#define ADC13_IDACMUX_MUX1_AIN5 5
349#define ADC13_IDACMUX_MUX1_AIN6 6
350#define ADC13_IDACMUX_MUX1_AIN7 7
351#define ADC13_IDACMUX_MUX1_AIN8 8
352#define ADC13_IDACMUX_MUX1_AIN9 9
353#define ADC13_IDACMUX_MUX1_AINCOM 10
354#define ADC13_IDACMUX_MUX1_NO_CONNECTION 11
355
360#define ADC13_IDACMAG_MAG2_OFF 0
361#define ADC13_IDACMAG_MAG2_50uA 1
362#define ADC13_IDACMAG_MAG2_100uA 2
363#define ADC13_IDACMAG_MAG2_250uA 3
364#define ADC13_IDACMAG_MAG2_500uA 4
365#define ADC13_IDACMAG_MAG2_750uA 5
366#define ADC13_IDACMAG_MAG2_1000uA 6
367#define ADC13_IDACMAG_MAG2_1500uA 7
368#define ADC13_IDACMAG_MAG2_2000uA 8
369#define ADC13_IDACMAG_MAG2_2500uA 9
370#define ADC13_IDACMAG_MAG2_3000uA 10
371#define ADC13_IDACMAG_MAG1_OFF 0
372#define ADC13_IDACMAG_MAG1_50uA 1
373#define ADC13_IDACMAG_MAG1_100uA 2
374#define ADC13_IDACMAG_MAG1_250uA 3
375#define ADC13_IDACMAG_MAG1_500uA 4
376#define ADC13_IDACMAG_MAG1_750uA 5
377#define ADC13_IDACMAG_MAG1_1000uA 6
378#define ADC13_IDACMAG_MAG1_1500uA 7
379#define ADC13_IDACMAG_MAG1_2000uA 8
380#define ADC13_IDACMAG_MAG1_2500uA 9
381#define ADC13_IDACMAG_MAG1_3000uA 10
382
387#define ADC13_REFMUX_RMUXP_INTERNAL 0
388#define ADC13_REFMUX_RMUXP_EXT_AIN0 1
389#define ADC13_REFMUX_RMUXP_EXT_AIN2 2
390#define ADC13_REFMUX_RMUXP_EXT_AIN4 3
391#define ADC13_REFMUX_RMUXP_INTERNAL_AVDD 4
392#define ADC13_REFMUX_RMUXN_INTERNAL 0
393#define ADC13_REFMUX_RMUXN_EXT_AIN1 1
394#define ADC13_REFMUX_RMUXN_EXT_AIN3 2
395#define ADC13_REFMUX_RMUXN_EXT_AIN5 3
396#define ADC13_REFMUX_RMUXN_INTERNAL_AVSS 4
397
402#define ADC13_TDACP_OUTP_NO_CONNECTION 0
403#define ADC13_TDACP_OUTP_AIN6 1
404#define ADC13_TDACP_MAGP_4p5V 9
405#define ADC13_TDACP_MAGP_3p5V 8
406#define ADC13_TDACP_MAGP_3V 7
407#define ADC13_TDACP_MAGP_2p75V 6
408#define ADC13_TDACP_MAGP_2p625V 5
409#define ADC13_TDACP_MAGP_2p5625V 4
410#define ADC13_TDACP_MAGP_2p53125V 3
411#define ADC13_TDACP_MAGP_2p515625V 2
412#define ADC13_TDACP_MAGP_2p5078125V 1
413#define ADC13_TDACP_MAGP_2p5V 0
414#define ADC13_TDACP_MAGP_2p4921875V 17
415#define ADC13_TDACP_MAGP_2p484375V 18
416#define ADC13_TDACP_MAGP_2p46875V 19
417#define ADC13_TDACP_MAGP_2p4375V 20
418#define ADC13_TDACP_MAGP_2p375V 21
419#define ADC13_TDACP_MAGP_2p25V 22
420#define ADC13_TDACP_MAGP_2V 23
421#define ADC13_TDACP_MAGP_1p5V 24
422#define ADC13_TDACP_MAGP_0p5V 25
423
428#define ADC13_TDACN_OUTN_NO_CONNECTION 0
429#define ADC13_TDACN_OUTN_AIN7 1
430#define ADC13_TDACN_MAGN_4p5V 9
431#define ADC13_TDACN_MAGN_3p5V 8
432#define ADC13_TDACN_MAGN_3V 7
433#define ADC13_TDACN_MAGN_2p75V 6
434#define ADC13_TDACN_MAGN_2p625V 5
435#define ADC13_TDACN_MAGN_2p5625V 4
436#define ADC13_TDACN_MAGN_2p53125V 3
437#define ADC13_TDACN_MAGN_2p515625V 2
438#define ADC13_TDACN_MAGN_2p5078125V 1
439#define ADC13_TDACN_MAGN_2p5V 0
440#define ADC13_TDACN_MAGN_2p4921875V 17
441#define ADC13_TDACN_MAGN_2p484375V 18
442#define ADC13_TDACN_MAGN_2p46875V 19
443#define ADC13_TDACN_MAGN_2p4375V 20
444#define ADC13_TDACN_MAGN_2p375V 21
445#define ADC13_TDACN_MAGN_2p25V 22
446#define ADC13_TDACN_MAGN_2V 23
447#define ADC13_TDACN_MAGN_1p5V 24
448#define ADC13_TDACN_MAGN_0p5V 25
449
454#define ADC13_GPIO0 0x01
455#define ADC13_GPIO1 0x02
456#define ADC13_GPIO2 0x04
457#define ADC13_GPIO3 0x08
458#define ADC13_GPIO4 0x10
459#define ADC13_GPIO5 0x20
460#define ADC13_GPIO6 0x40
461#define ADC13_GPIO7 0x80
462
467#define ADC13_VREF_INTERNAL 2.5
468#define ADC13_VREF_INTERNAL_AVDD 5
469#define ADC13_VREF_3V3 3.3
470#define ADC13_VREF_5V 5
471
476#define ADC13_CHECKSUM_CONSTANT 0x9B
477
482#define ADC13_TEMP_MILIVOLTS 122.4
483#define ADC13_TEMP_V_TO_MV 1000
484#define ADC13_TEMP_COEFF 0.42
485#define ADC13_TEMP_OFFSET 25.0
486#define ADC13_TEMP_HEAT_OFFSET 0.7
487
492#define GET_RIGHTMOST_SET_BIT( bit_mask ) ( uint8_t )( log10( ( double ) \
493 ( bit_mask & ~( bit_mask - 1 ) ) ) / log10( 2.0 ) )
494
499#define SET_REG_BITS( reg_data, bit_mask, in_data ) ( ( reg_data & ~( bit_mask ) ) | \
500 ( ( in_data << GET_RIGHTMOST_SET_BIT( bit_mask ) ) \
501 & bit_mask ) )
502
507#define GET_REG_BITS( reg_data, bit_mask ) ( ( reg_data & bit_mask ) >> GET_RIGHTMOST_SET_BIT( bit_mask ) )
508
517#define ADC13_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
518#define ADC13_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
519
520 // adc13_set
521
536#define ADC13_MAP_MIKROBUS( cfg, mikrobus ) \
537 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
538 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
539 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
540 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
541 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
542 cfg.str = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
543 cfg.dtr = MIKROBUS( mikrobus, MIKROBUS_INT )
544
545 // adc13_map
546 // adc13
547
552typedef struct
553{
554 // Output pins
555 digital_out_t rst;
556 digital_out_t str;
558 // Input pins
559 digital_in_t dtr;
561 // Modules
562 spi_master_t spi;
564 pin_name_t chip_select;
566} adc13_t;
567
572typedef struct
573{
574 // Communication gpio pins
575 pin_name_t miso;
576 pin_name_t mosi;
577 pin_name_t sck;
578 pin_name_t cs;
580 // Additional gpio pins
581 pin_name_t rst;
582 pin_name_t str;
583 pin_name_t dtr;
585 // static variable
586 uint32_t spi_speed;
587 spi_master_mode_t spi_mode;
588 spi_master_chip_select_polarity_t cs_polarity;
591
596typedef enum
597{
599 ADC13_ERROR = -1
600
602
619
634err_t adc13_init ( adc13_t *ctx, adc13_cfg_t *cfg );
635
650
666err_t adc13_generic_write ( adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
667
683err_t adc13_generic_read ( adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
684
698err_t adc13_send_command ( adc13_t *ctx, uint8_t cmd );
699
709void adc13_set_str_pin ( adc13_t *ctx, uint8_t state );
710
720void adc13_set_rst_pin ( adc13_t *ctx, uint8_t state );
721
730uint8_t adc13_get_dtr_pin ( adc13_t *ctx );
731
741
754
764
774
788err_t adc13_read_register ( adc13_t *ctx, uint8_t reg, uint8_t *data_out );
789
803err_t adc13_write_register ( adc13_t *ctx, uint8_t reg, uint8_t data_in );
804
820err_t adc13_read_registers ( adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t count );
821
837err_t adc13_write_registers ( adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t count );
838
854err_t adc13_set_register_bits ( adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t data_in );
855
870err_t adc13_get_register_bits ( adc13_t *ctx, uint8_t reg, uint8_t bit_mask, uint8_t *data_out );
871
884err_t adc13_read_raw_data ( adc13_t *ctx, int32_t *data_out );
885
900err_t adc13_measure_voltage ( adc13_t *ctx, float vref, float *voltage );
901
914err_t adc13_measure_temperature ( adc13_t *ctx, float *temperature );
915
929err_t adc13_set_input_channel ( adc13_t *ctx, uint8_t pos, uint8_t neg );
930
944err_t adc13_set_voltage_reference ( adc13_t *ctx, uint8_t pos, uint8_t neg );
945
958err_t adc13_set_gain ( adc13_t *ctx, uint8_t gain );
959
972err_t adc13_set_sample_rate ( adc13_t *ctx, uint8_t s_rate );
973
974#ifdef __cplusplus
975}
976#endif
977#endif // ADC13_H
978
979 // adc13
980
981// ------------------------------------------------------------------------ END
adc13_return_value_t
ADC 13 Click return value data.
Definition adc13.h:597
@ ADC13_OK
Definition adc13.h:598
@ ADC13_ERROR
Definition adc13.h:599
err_t adc13_set_voltage_reference(adc13_t *ctx, uint8_t pos, uint8_t neg)
ADC 13 set voltage reference function.
void adc13_cfg_setup(adc13_cfg_t *cfg)
ADC 13 configuration object setup function.
err_t adc13_generic_write(adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
ADC 13 data writing function.
err_t adc13_read_register(adc13_t *ctx, uint8_t reg, uint8_t *data_out)
ADC 13 read register function.
void adc13_power_up(adc13_t *ctx)
ADC 13 power up function.
err_t adc13_measure_voltage(adc13_t *ctx, float vref, float *voltage)
ADC 13 measure voltage function.
err_t adc13_read_raw_data(adc13_t *ctx, int32_t *data_out)
ADC 13 read raw data function.
uint8_t adc13_get_dtr_pin(adc13_t *ctx)
ADC 13 get DTR pin function.
err_t adc13_set_input_channel(adc13_t *ctx, uint8_t pos, uint8_t neg)
ADC 13 set input channel function.
void adc13_set_rst_pin(adc13_t *ctx, uint8_t state)
ADC 13 set RST pin function.
void adc13_set_str_pin(adc13_t *ctx, uint8_t state)
ADC 13 set STR pin function.
void adc13_power_down(adc13_t *ctx)
ADC 13 power down function.
err_t adc13_write_register(adc13_t *ctx, uint8_t reg, uint8_t data_in)
ADC 13 write register function.
err_t adc13_measure_temperature(adc13_t *ctx, float *temperature)
ADC 13 measure temperature function.
err_t adc13_write_registers(adc13_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t count)
ADC 13 write registers function.
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.
err_t adc13_read_registers(adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t count)
ADC 13 read registers function.
err_t adc13_set_gain(adc13_t *ctx, uint8_t gain)
ADC 13 set gain function.
void adc13_reset_by_pin(adc13_t *ctx)
ADC 13 reset by pin function.
err_t adc13_send_command(adc13_t *ctx, uint8_t cmd)
ADC 13 send command function.
err_t adc13_set_sample_rate(adc13_t *ctx, uint8_t s_rate)
ADC 13 set sample rate function.
err_t adc13_init(adc13_t *ctx, adc13_cfg_t *cfg)
ADC 13 initialization function.
err_t adc13_generic_read(adc13_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
ADC 13 data reading function.
err_t adc13_default_cfg(adc13_t *ctx)
ADC 13 default configuration function.
err_t adc13_reset_by_command(adc13_t *ctx)
ADC 13 reset by command function.
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.
This file contains SPI specific macros, functions, etc.
ADC 13 Click configuration object.
Definition adc13.h:573
pin_name_t dtr
Definition adc13.h:583
spi_master_chip_select_polarity_t cs_polarity
Definition adc13.h:588
pin_name_t sck
Definition adc13.h:577
spi_master_mode_t spi_mode
Definition adc13.h:587
pin_name_t mosi
Definition adc13.h:576
uint32_t spi_speed
Definition adc13.h:586
pin_name_t miso
Definition adc13.h:575
pin_name_t str
Definition adc13.h:582
pin_name_t rst
Definition adc13.h:581
pin_name_t cs
Definition adc13.h:578
ADC 13 Click context object.
Definition adc13.h:553
spi_master_t spi
Definition adc13.h:562
digital_out_t rst
Definition adc13.h:555
digital_out_t str
Definition adc13.h:556
digital_in_t dtr
Definition adc13.h:559
pin_name_t chip_select
Definition adc13.h:564