adswio3  2.1.0.0
adswio3.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 ADSWIO3_H
29 #define ADSWIO3_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
38 #include "spi_specifics.h"
39 
60 #define ADSWIO3_REG_NOP 0x00
61 #define ADSWIO3_REG_CH_FUNC_SETUP 0x01
62 #define ADSWIO3_REG_ADC_CONFIG 0x02
63 #define ADSWIO3_REG_PWR_OPTIM_CONFIG 0x03
64 #define ADSWIO3_REG_DIN_CONFIG1 0x04
65 #define ADSWIO3_REG_DIN_CONFIG2 0x05
66 #define ADSWIO3_REG_OUTPUT_CONFIG 0x06
67 #define ADSWIO3_REG_RTD3W4W_CONFIG 0x07
68 #define ADSWIO3_REG_DO_INT_CONFIG 0x08
69 #define ADSWIO3_REG_DO_EXT_CONFIG 0x09
70 #define ADSWIO3_REG_I_BURNOUT_CONFIG 0x0A
71 #define ADSWIO3_REG_DAC_CODE 0x0B
72 #define ADSWIO3_REG_DAC_ACTIVE 0x0D
73 #define ADSWIO3_REG_GPIO_CONFIG0 0x35
74 #define ADSWIO3_REG_GPIO_CONFIG1 0x36
75 #define ADSWIO3_REG_GPIO_CONFIG2 0x37
76 #define ADSWIO3_REG_GPIO_CONFIG3 0x38
77 #define ADSWIO3_REG_FET_LKG_COMP 0x39
78 #define ADSWIO3_REG_CHARGE_PUMP 0x3A
79 #define ADSWIO3_REG_ADC_CONV_CTRL 0x3B
80 #define ADSWIO3_REG_DIAG_ASSIGN 0x3C
81 #define ADSWIO3_REG_DIN_COMP_OUT 0x40
82 #define ADSWIO3_REG_ALERT_STATUS 0x41
83 #define ADSWIO3_REG_LIVE_STATUS 0x42
84 #define ADSWIO3_REG_ADC_RESULT1 0x44
85 #define ADSWIO3_REG_ADC_RESULT2 0x46
86 #define ADSWIO3_REG_ADC_DIAG_RESULT0 0x53
87 #define ADSWIO3_REG_ADC_DIAG_RESULT1 0x54
88 #define ADSWIO3_REG_ADC_DIAG_RESULT2 0x55
89 #define ADSWIO3_REG_ADC_DIAG_RESULT3 0x56
90 #define ADSWIO3_REG_DIN_COUNTER 0x57
91 #define ADSWIO3_REG_SUPPLY_ALERT_STATUS 0x5B
92 #define ADSWIO3_REG_ALERT_MASK 0x5F
93 #define ADSWIO3_REG_SUPPLY_ALERT_MASK 0x60
94 #define ADSWIO3_REG_READ_SELECT 0x64
95 #define ADSWIO3_REG_BURST_READ_SEL 0x65
96 #define ADSWIO3_REG_PPC_TX 0x66
97 #define ADSWIO3_REG_PPC_ACTIVE 0x6E
98 #define ADSWIO3_REG_THERM_RST 0x77
99 #define ADSWIO3_REG_CMD_KEY 0x78
100 #define ADSWIO3_REG_SCRATCH_0 0x79
101 #define ADSWIO3_REG_SCRATCH_1 0x7A
102 #define ADSWIO3_REG_SILICON_REV 0x7B
103 #define ADSWIO3_REG_SILICON_ID0 0x7C
104 #define ADSWIO3_REG_SILICON_ID1 0x7D
105 #define ADSWIO3_REG_SILICON_ID2 0x7E
106 #define ADSWIO3_REG_SILICON_ID3 0x7F
107 #define ADSWIO3_REG_HART_ALERT_STATUS 0x80
108 #define ADSWIO3_REG_HART_RX 0x81
109 #define ADSWIO3_REG_HART_TX 0x82
110 #define ADSWIO3_REG_HART_FCR 0x83
111 #define ADSWIO3_REG_HART_MCR 0x84
112 #define ADSWIO3_REG_HART_RFC 0x85
113 #define ADSWIO3_REG_HART_TFC 0x86
114 #define ADSWIO3_REG_HART_ALERT_MASK 0x87
115 #define ADSWIO3_REG_HART_CONFIG 0x88
116 #define ADSWIO3_REG_HART_EVDET_COUNT 0x89
117  // adswio3_reg
119 
134 #define ADSWIO3_CH_FUNC_SETUP_ADC 0x00
135 #define ADSWIO3_CH_FUNC_SETUP_VTG_OUT 0x01
136 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT 0x02
137 #define ADSWIO3_CH_FUNC_SETUP_VTG_IN 0x03
138 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_EXT 0x04
139 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_LOOP 0x05
140 #define ADSWIO3_CH_FUNC_SETUP_2WIRE_RES_MEASURE 0x06
141 #define ADSWIO3_CH_FUNC_SETUP_3WIRE_RES_MEASURE 0x07
142 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOG 0x08
143 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOOP 0x09
144 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT_HART 0x0A
145 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_EXT 0x0B
146 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_LOOP 0x0C
147 
152 #define ADSWIO3_DIAG_ASSIGN_AGND 0x00
153 #define ADSWIO3_DIAG_ASSIGN_TEMP_SENS 0x01
154 #define ADSWIO3_DIAG_ASSIGN_DVCC 0x02
155 #define ADSWIO3_DIAG_ASSIGN_AVCC 0x03
156 #define ADSWIO3_DIAG_ASSIGN_ALDO1V8 0x04
157 #define ADSWIO3_DIAG_ASSIGN_DLDO1V8 0x05
158 #define ADSWIO3_DIAG_ASSIGN_REFOUT 0x06
159 #define ADSWIO3_DIAG_ASSIGN_AVDD 0x07
160 #define ADSWIO3_DIAG_ASSIGN_AVSS 0x08
161 #define ADSWIO3_DIAG_ASSIGN_LVIN 0x09
162 #define ADSWIO3_DIAG_ASSIGN_SENSEL 0x0A
163 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT1 0x0B
164 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT2 0x0C
165 #define ADSWIO3_DIAG_ASSIGN_DO_VDD 0x0D
166 #define ADSWIO3_DIAG_ASSIGN_AGND0 0x0E
167 #define ADSWIO3_DIAG_ASSIGN_CURRENT_EXT 0x0F
168 #define ADSWIO3_DIAG_RESULT_SEL_0 0x00
169 #define ADSWIO3_DIAG_RESULT_SEL_1 0x01
170 #define ADSWIO3_DIAG_RESULT_SEL_2 0x02
171 #define ADSWIO3_DIAG_RESULT_SEL_3 0x03
172 
177 #define ADSWIO3_READ_SELECT_SPI_RD_RET_INFO 0x01
178 #define ADSWIO3_READ_SELECT_AUTO_RD_EN 0x02
179 #define ADSWIO3_READ_REG_STATUS_BIT 0x7F
180 
185 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT1 0x00
186 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT2 0x01
187 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_HF 0x02
188 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_LF 0x03
189 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_AGND 0x04
190 #define ADSWIO3_PWR_OPTIM_CONFIG_LOW_PWR 0x00
191 #define ADSWIO3_PWR_OPTIM_CONFIG_FULL_PWR 0x01
192 
197 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_250UA 0x00
198 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_500UA 0x01
199 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_750UA 0x02
200 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_1MA 0x03
201 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC 0x00
202 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC_SWAP 0x01
203 #define ADSWIO3_RTD3W4W_CONFIG_RTD_3_WIRE 0x00
204 #define ADSWIO3_RTD3W4W_CONFIG_RTD_4_WIRE 0x01
205 #define ADSWIO3_RTD3W4W_CONFIG_BIT_MASK 0xFFF0u
206 
211 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
212 #define ADSWIO3_ADC_CONV_CTRL_CONV_EN 0x01
213 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
214 #define ADSWIO3_ADC_CONV_DIAG_DIS 0x00
215 #define ADSWIO3_ADC_CONV_DIAG_EN 0x01
216 #define ADSWIO3_ADC_CONV_SEQ_MODE_STBY 0x00
217 #define ADSWIO3_ADC_CONV_SEQ_START_SGL_CNV 0x01
218 #define ADSWIO3_ADC_CONV_SEQ_START_CONT_CNV 0x02
219 #define ADSWIO3_ADC_CONV_SEQ_STOP_CONT_CNV 0x03
220 #define ADSWIO3_ADC_CONV_RATE_DIAG_20_SPS 0x00
221 #define ADSWIO3_ADC_CONV_RATE_DIAG_4_8K_SPS 0x01
222 #define ADSWIO3_ADC_CONV_RATE_DIAG_9_6K_SPS 0x02
223 
228 #define ADSWIO3_ADC_CONFIG_CNV_RATE_10_SPS 0x00
229 #define ADSWIO3_ADC_CONFIG_CNV_RATE_20_SPS 0x01
230 #define ADSWIO3_ADC_CONFIG_CNV_RATE_1_2K_SPS 0x02
231 #define ADSWIO3_ADC_CONFIG_CNV_RATE_4_8K_SPS 0x03
232 #define ADSWIO3_ADC_CONFIG_CNV_RATE_9_6K_SPS 0x04
233 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_12V 0x00
234 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_12V 0x01
235 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_2_5V 0x02
236 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_M_2_5V 0x03
237 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_2_5V 0x04
238 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_0_625V 0x05
239 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_0_104V 0x06
240 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_AGND_SEN 0x00
241 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSELF 0x01
242 #define ADSWIO3_ADC_CONFIG_CNV1_SENSE_EXT2_EXT1 0x02
243 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSE_EXT1 0x03
244 #define ADSWIO3_ADC_CONFIG_CNV2_EXT1_AGND_SEN 0x00
245 #define ADSWIO3_ADC_CONFIG_CNV2_EXT2_AGND_SEN 0x01
246 #define ADSWIO3_ADC_CONFIG_CNV2_SENSE_EXT2_EXT1 0x02
247 #define ADSWIO3_ADC_CONFIG_CNV2_AGND_AGND 0x03
248 
253 #define ADSWIO3_DAC_CODE_RESOLUTION 0x3FFFu
254 
259 #define ADSWIO3_GPIO_CONFIG_SEL_A 0x00
260 #define ADSWIO3_GPIO_CONFIG_SEL_B 0x01
261 #define ADSWIO3_GPIO_CONFIG_SEL_C 0x02
262 #define ADSWIO3_GPIO_CONFIG_SEL_D 0x03
263 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_LOW 0x00
264 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_HIGH 0x01
265 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_DIS 0x00
266 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_EN 0x01
267 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_LOW 0x00
268 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_HIGH 0x01
269 #define ADSWIO3_GPIO_CONFIG_MODE_HI 0x00
270 #define ADSWIO3_GPIO_CONFIG_MODE_OUT 0x01
271 #define ADSWIO3_GPIO_CONFIG_MODE_OUT_IN 0x02
272 #define ADSWIO3_GPIO_CONFIG_MODE_IN 0x03
273 #define ADSWIO3_GPIO_CONFIG_MODE_FET 0x04
274 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_IN 0x05
275 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_OUT 0x06
276 #define ADSWIO3_GPIO_CONFIG_MODE_TX_COM 0x07
277 
282 #define ADSWIO3_ADC_RESULT_SEL_1 0x00
283 #define ADSWIO3_ADC_RESULT_SEL_2 0x01
284 #define ADSWIO3_ADC_RESULT_RESOLUTION 65536.0f
285 #define ADSWIO3_ADC_RESULT_RANGE 12.0f
286 
291 #define ADSWIO3_NTC_VTG_AT_25_C 1.0f
292 #define ADSWIO3_NTC_TABLE_POS_CALC_N 0.2f
293 #define ADSWIO3_NTC_TABLE_POS_CALC_P 0.5f
294 #define ADSWIO3_NTC_TABLE_POS_MAX 9
295 #define ADSWIO3_NTC_TABLE_NEG_MAX 13
296 #define ADSWIO3_NTC_TEMP_AT_1_V 25.0f
297 
302 #define ADSWIO3_ALERT_SPI_ERR_MASK 0x0004u
303 #define ADSWIO3_ALERT_PPC_ERR_MASK 0x0008u
304 #define ADSWIO3_ALERT_TEMP_ALERT_MASK 0x0010u
305 #define ADSWIO3_ALERT_ADC_ERR_MASK 0x0020u
306 #define ADSWIO3_ALERT_DI_SC_ERR_MASK 0x0040u
307 #define ADSWIO3_ALERT_DI_OC_ERR_MASK 0x0080u
308 #define ADSWIO3_ALERT_DO_THERM_RESET_MASK 0x0100u
309 #define ADSWIO3_ALERT_DO_EXT_SC_MASK 0x0200u
310 #define ADSWIO3_ALERT_DO_INT_SC_MASK 0x0400u
311 #define ADSWIO3_ALERT_DO_EXT_TIMEOUT_MASK 0x0800u
312 #define ADSWIO3_ALERT_DO_INT_TIMEOUT_MASK 0x1000u
313 #define ADSWIO3_ALERT_ANALOG_IO_SC_MASK 0x2000u
314 #define ADSWIO3_ALERT_ANALOG_IO_OC_MASK 0x4000u
315 
320 #define ADSWIO3_PPC_TX_DATA_BIT_MASK 0x00FFu
321 #define ADSWIO3_PPC_TX_AVDD_VTG_MIN 6.0f
322 #define ADSWIO3_PPC_TX_AVDD_VTG_DEFAULT 24.00f
323 #define ADSWIO3_PPC_TX_AVDD_VTG_MAX 24.20f
324 #define ADSWIO3_PPC_TX_AVDD_DATA_MAX 255.0f
325 #define ADSWIO3_PPC_TX_AVDD_DATA_CALC 1.0f
326 #define ADSWIO3_PPC_ACTIVE_TX_BUSY 0x0100u
327 #define ADSWIO3_PPC_ACTIVE_PPC_TX_BUSY_ERR 0x0200u
328 #define ADSWIO3_PPC_ACTIVE_PPC_TX_ACK_ERR 0x0400u
329 
334 #define ADSWIO3_DIN_CONFIG2_DIN_THRESH_MODE 0x0080u
335 #define ADSWIO3_SENS_SEL_TRSH_MULTI 50.0f
336 #define ADSWIO3_SENS_SEL_SCALE_MULTI 60.0f
337 #define ADSWIO3_SENS_SEL_TRSH_CORR_VAL 20.0f
338 
344 #define ADSWIO3_DIGI_OUT_MODE_SRC 0.3125f
345 #define ADSWIO3_DIGI_OUT_MODE_SNK 2.5f
346 
351 #define ADSWIO3_CALC_DIAG_AGND( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
352 #define ADSWIO3_CALC_DIAG_SENS_TEMP( DIAG_ADC ) ( DIAG_ADC / 8.95f ) - 40.0f
353 #define ADSWIO3_CALC_DIAG_DVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 8.25f
354 #define ADSWIO3_CALC_DIAG_ALDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 5.825f
355 #define ADSWIO3_CALC_DIAG_DLDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 7.5f
356 #define ADSWIO3_CALC_DIAG_REFOUT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 3.125f
357 #define ADSWIO3_CALC_DIAG_LVIN( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
358 #define ADSWIO3_CALC_DIAG_SENSE_EXT( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 50.0f ) - 20.0f
359 #define ADSWIO3_CALC_DIAG_DO_VDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 49.2f
360 #define ADSWIO3_CALC_DIAG_CURRENT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) / 1.38f
361 #define ADSWIO3_CALC_DIAG_VTG_AVDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 50.0f
362 #define ADSWIO3_CALC_DIAG_VTG_AVSS( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 31.017f ) - 20.0f
363 #define ADSWIO3_CALC_DIAG_VTG_AVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 17.5f
364 
373 #define ADSWIO3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
374 #define ADSWIO3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
375  // adswio3_set
377 
392 #define ADSWIO3_MAP_MIKROBUS( cfg, mikrobus ) \
393  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
394  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
395  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
396  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
397  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
398  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
399  cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
400  // adswio3_map // adswio3
403 
408 typedef struct
409 {
410  // Output pins
411  digital_out_t rst;
413  // Input pins
414  digital_in_t rdy;
415  digital_in_t alr;
417  // Modules
418  spi_master_t spi;
420  pin_name_t chip_select;
422  float dig_out_mode;
424 } adswio3_t;
425 
430 typedef struct
431 {
432  // Communication gpio pins
433  pin_name_t miso;
434  pin_name_t mosi;
435  pin_name_t sck;
436  pin_name_t cs;
438  // Additional gpio pins
439  pin_name_t rst;
440  pin_name_t rdy;
441  pin_name_t alr;
443  // static variable
444  uint32_t spi_speed;
445  spi_master_mode_t spi_mode;
446  spi_master_chip_select_polarity_t cs_polarity;
448 } adswio3_cfg_t;
449 
454 typedef struct
455 {
456  uint8_t conv2_rate;
457  uint8_t conv1_rate;
458  uint8_t conv2_range;
459  uint8_t conv1_range;
460  uint8_t conv2_mux;
461  uint8_t conv1_mux;
464 
469 typedef struct
470 {
471  uint8_t vout_range;
472  uint8_t slew_en;
473  uint8_t slew_lin_step;
474  uint8_t slew_lin_rate;
475  uint8_t i_limit;
478 
483 typedef struct
484 {
485  uint8_t conv_rate_diag;
486  uint8_t conv_seq;
487  uint8_t diag_3_en;
488  uint8_t diag_2_en;
489  uint8_t diag_1_en;
490  uint8_t diag_0_en;
491  uint8_t conv2_en;
492  uint8_t conv1_en;
495 
500 typedef struct
501 {
502  uint8_t hart_alert;
503  uint8_t analog_io_oc;
504  uint8_t analog_io_sc;
505  uint8_t do_int_timeout;
506  uint8_t do_ext_timeout;
507  uint8_t do_int_sc;
508  uint8_t do_ext_sc;
509  uint8_t do_therm_reset;
510  uint8_t di_oc_err;
511  uint8_t di_sc_err;
512  uint8_t adc_err;
513  uint8_t temp_alert;
514  uint8_t ppc_err;
515  uint8_t spi_err;
516  uint8_t supply_err;
517  uint8_t reset_occurred;
520 
525 typedef struct
526 {
532  uint8_t di_oc_status;
533  uint8_t di_sc_status;
535  uint8_t adc_data_rdy;
536  uint8_t adc_busy;
537  uint8_t supply_status;
540 
541 
546 typedef enum
547 {
549  ADSWIO3_ERROR = -1
550 
552 
569 
583 err_t adswio3_init ( adswio3_t *ctx, adswio3_cfg_t *cfg );
584 
598 
611 
625 err_t adswio3_register_write ( adswio3_t *ctx, uint8_t reg, uint16_t data_in );
626 
640 err_t adswio3_register_read ( adswio3_t *ctx, uint8_t reg, uint16_t *data_out );
641 
655 err_t adswio3_function_setup ( adswio3_t *ctx, uint8_t ch_fun );
656 
671 err_t adswio3_adc_config ( adswio3_t *ctx, adswio3_adc_cfg_t adc_config );
672 
687 err_t adswio3_pwr_optim_config ( adswio3_t *ctx, uint8_t buff_sel, uint8_t buff_mode );
688 
704 
720 err_t adswio3_rtd_config ( adswio3_t *ctx, uint8_t rtd_mode_sel, uint8_t rtd_exc_swap, uint8_t rtd_current );
721 
735 err_t adswio3_set_dac_code ( adswio3_t *ctx, uint16_t dac_code );
736 
753 err_t adswio3_set_gpio_config ( adswio3_t *ctx, uint8_t gpio_sel, uint8_t gpo_data,
754  uint8_t gp_wk_pd_en, uint8_t out_mode );
755 
771 
789 err_t adswio3_set_diag_assign ( adswio3_t *ctx, uint8_t diag_0, uint8_t diag_1,
790  uint8_t diag_2, uint8_t diag_3 );
791 
809  adswio3_live_status_t *live_status );
810 
825 err_t adswio3_get_adc_res ( adswio3_t *ctx, uint8_t adc_sel, uint16_t *adc_data );
826 
843 err_t adswio3_get_voltage_input ( adswio3_t *ctx, uint8_t adc_sel, float *voltage );
844 
859 err_t adswio3_get_diag_res ( adswio3_t *ctx, uint8_t diag_sel, uint16_t *adc_diag_data );
860 
878 err_t adswio3_get_diag_vtg ( adswio3_t *ctx, uint8_t diag_sel, float *diag_vtg );
879 
895 err_t adswio3_get_ntc_temp ( adswio3_t *ctx, uint8_t diag_sel, float *ntc_temp );
896 
911 err_t adswio3_set_alert_mask ( adswio3_t *ctx, uint16_t alert_mask );
912 
929 err_t adswio3_set_ppc_vtg ( adswio3_t *ctx, float ppc_vtg );
930 
943 uint8_t adswio3_get_ready ( adswio3_t *ctx );
944 
957 uint8_t adswio3_get_alarm ( adswio3_t *ctx );
958 
959 #ifdef __cplusplus
960 }
961 #endif
962 #endif // ADSWIO3_H
963  // adswio3
965 
966 // ------------------------------------------------------------------------ END
adswio3_cfg_t::rst
pin_name_t rst
Definition: adswio3.h:439
adswio3_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adswio3.h:445
adswio3_return_value_t
adswio3_return_value_t
AD-SWIO 3 Click return value data.
Definition: adswio3.h:547
adswio3_alert_status_t::supply_err
uint8_t supply_err
Definition: adswio3.h:516
adswio3_cfg_t::mosi
pin_name_t mosi
Definition: adswio3.h:434
adswio3_output_cfg_t::slew_en
uint8_t slew_en
Definition: adswio3.h:472
adswio3_rtd_config
err_t adswio3_rtd_config(adswio3_t *ctx, uint8_t rtd_mode_sel, uint8_t rtd_exc_swap, uint8_t rtd_current)
AD-SWIO 3 RTD configuration function.
adswio3_get_status
err_t adswio3_get_status(adswio3_t *ctx, adswio3_alert_status_t *alert_status, adswio3_live_status_t *live_status)
AD-SWIO 3 get status function.
adswio3_set_adc_cnv
err_t adswio3_set_adc_cnv(adswio3_t *ctx, adswio3_adc_cnv_ctrl_t adc_cnv_ctrl)
AD-SWIO 3 ADC conversion control function.
adswio3_alert_status_t::do_int_timeout
uint8_t do_int_timeout
Definition: adswio3.h:505
adswio3_alert_status_t::adc_err
uint8_t adc_err
Definition: adswio3.h:512
adswio3_get_ready
uint8_t adswio3_get_ready(adswio3_t *ctx)
AD-SWIO 3 gets the ready pin function.
adswio3_adc_cnv_ctrl_t::conv2_en
uint8_t conv2_en
Definition: adswio3.h:491
adswio3_live_status_t::do_ext_sc_status
uint8_t do_ext_sc_status
Definition: adswio3.h:530
adswio3_adc_cnv_ctrl_t::conv_rate_diag
uint8_t conv_rate_diag
Definition: adswio3.h:485
adswio3_live_status_t::supply_status
uint8_t supply_status
Definition: adswio3.h:537
adswio3_live_status_t::di_oc_status
uint8_t di_oc_status
Definition: adswio3.h:532
adswio3_adc_cfg_t
AD-SWIO 3 Click ADC configuration object.
Definition: adswio3.h:455
adswio3_cfg_t::alr
pin_name_t alr
Definition: adswio3.h:441
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adswio3_cfg_t::spi_speed
uint32_t spi_speed
Definition: adswio3.h:444
adswio3_get_alarm
uint8_t adswio3_get_alarm(adswio3_t *ctx)
AD-SWIO 3 gets the alarm pin function.
adswio3_default_cfg
err_t adswio3_default_cfg(adswio3_t *ctx)
AD-SWIO 3 default configuration function.
adswio3_init
err_t adswio3_init(adswio3_t *ctx, adswio3_cfg_t *cfg)
AD-SWIO 3 initialization function.
adswio3_adc_cfg_t::conv2_rate
uint8_t conv2_rate
Definition: adswio3.h:456
adswio3_cfg_t::cs
pin_name_t cs
Definition: adswio3.h:436
adswio3_alert_status_t::do_therm_reset
uint8_t do_therm_reset
Definition: adswio3.h:509
adswio3_adc_cfg_t::conv1_range
uint8_t conv1_range
Definition: adswio3.h:459
ADSWIO3_ERROR
@ ADSWIO3_ERROR
Definition: adswio3.h:549
adswio3_live_status_t::analog_io_oc_status
uint8_t analog_io_oc_status
Definition: adswio3.h:527
adswio3_alert_status_t::ppc_err
uint8_t ppc_err
Definition: adswio3.h:514
adswio3_get_diag_vtg
err_t adswio3_get_diag_vtg(adswio3_t *ctx, uint8_t diag_sel, float *diag_vtg)
AD-SWIO 3 gets the diagnostic conversion results function.
adswio3_t
AD-SWIO 3 Click context object.
Definition: adswio3.h:409
adswio3_t::rst
digital_out_t rst
Definition: adswio3.h:411
adswio3_get_diag_res
err_t adswio3_get_diag_res(adswio3_t *ctx, uint8_t diag_sel, uint16_t *adc_diag_data)
AD-SWIO 3 gets the diagnostic conversion results function.
adswio3_adc_cnv_ctrl_t::conv_seq
uint8_t conv_seq
Definition: adswio3.h:486
adswio3_alert_status_t::do_ext_timeout
uint8_t do_ext_timeout
Definition: adswio3.h:506
adswio3_pwr_optim_config
err_t adswio3_pwr_optim_config(adswio3_t *ctx, uint8_t buff_sel, uint8_t buff_mode)
AD-SWIO 3 set power optimization function.
adswio3_cfg_t::miso
pin_name_t miso
Definition: adswio3.h:433
adswio3_adc_cfg_t::conv1_rate
uint8_t conv1_rate
Definition: adswio3.h:457
adswio3_adc_cnv_ctrl_t::diag_3_en
uint8_t diag_3_en
Definition: adswio3.h:487
adswio3_hw_reset
void adswio3_hw_reset(adswio3_t *ctx)
AD-SWIO 3 HW reset function.
adswio3_output_cfg_t::i_limit
uint8_t i_limit
Definition: adswio3.h:475
adswio3_alert_status_t::do_ext_sc
uint8_t do_ext_sc
Definition: adswio3.h:508
adswio3_alert_status_t::hart_alert
uint8_t hart_alert
Definition: adswio3.h:502
adswio3_live_status_t
AD-SWIO 3 Click live status object.
Definition: adswio3.h:526
adswio3_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adswio3.h:446
adswio3_alert_status_t::di_oc_err
uint8_t di_oc_err
Definition: adswio3.h:510
adswio3_alert_status_t::do_int_sc
uint8_t do_int_sc
Definition: adswio3.h:507
adswio3_cfg_t::rdy
pin_name_t rdy
Definition: adswio3.h:440
adswio3_live_status_t::analog_io_sc_status
uint8_t analog_io_sc_status
Definition: adswio3.h:528
adswio3_set_ppc_vtg
err_t adswio3_set_ppc_vtg(adswio3_t *ctx, float ppc_vtg)
AD-SWIO 3 power control voltage configuration function.
adswio3_function_setup
err_t adswio3_function_setup(adswio3_t *ctx, uint8_t ch_fun)
AD-SWIO 3 select the channel function.
adswio3_set_gpio_config
err_t adswio3_set_gpio_config(adswio3_t *ctx, uint8_t gpio_sel, uint8_t gpo_data, uint8_t gp_wk_pd_en, uint8_t out_mode)
AD-SWIO 3 GPIO configuration function.
adswio3_set_diag_assign
err_t adswio3_set_diag_assign(adswio3_t *ctx, uint8_t diag_0, uint8_t diag_1, uint8_t diag_2, uint8_t diag_3)
AD-SWIO 3 assigns diagnostics function.
adswio3_adc_cfg_t::conv2_range
uint8_t conv2_range
Definition: adswio3.h:458
adswio3_output_config
err_t adswio3_output_config(adswio3_t *ctx, adswio3_output_cfg_t out_cfg)
AD-SWIO 3 configures the output settings function.
adswio3_output_cfg_t
AD-SWIO 3 Click output configuration object.
Definition: adswio3.h:470
adswio3_t::dig_out_mode
float dig_out_mode
Definition: adswio3.h:422
adswio3_t::spi
spi_master_t spi
Definition: adswio3.h:418
adswio3_live_status_t::do_therm_reset_status
uint8_t do_therm_reset_status
Definition: adswio3.h:531
adswio3_adc_config
err_t adswio3_adc_config(adswio3_t *ctx, adswio3_adc_cfg_t adc_config)
AD-SWIO 3 select the ADC config function.
adswio3_get_adc_res
err_t adswio3_get_adc_res(adswio3_t *ctx, uint8_t adc_sel, uint16_t *adc_data)
AD-SWIO 3 gets the ADC conversion result function.
adswio3_adc_cnv_ctrl_t::diag_2_en
uint8_t diag_2_en
Definition: adswio3.h:488
adswio3_alert_status_t
AD-SWIO 3 Click the alert status object.
Definition: adswio3.h:501
adswio3_adc_cnv_ctrl_t::conv1_en
uint8_t conv1_en
Definition: adswio3.h:492
adswio3_live_status_t::adc_busy
uint8_t adc_busy
Definition: adswio3.h:536
adswio3_live_status_t::do_int_sc_status
uint8_t do_int_sc_status
Definition: adswio3.h:529
adswio3_get_ntc_temp
err_t adswio3_get_ntc_temp(adswio3_t *ctx, uint8_t diag_sel, float *ntc_temp)
AD-SWIO 3 gets the NTC temperature function.
adswio3_t::rdy
digital_in_t rdy
Definition: adswio3.h:414
adswio3_t::chip_select
pin_name_t chip_select
Definition: adswio3.h:420
adswio3_adc_cfg_t::conv1_mux
uint8_t conv1_mux
Definition: adswio3.h:461
ADSWIO3_OK
@ ADSWIO3_OK
Definition: adswio3.h:548
adswio3_cfg_t::sck
pin_name_t sck
Definition: adswio3.h:435
adswio3_cfg_t
AD-SWIO 3 Click configuration object.
Definition: adswio3.h:431
adswio3_alert_status_t::spi_err
uint8_t spi_err
Definition: adswio3.h:515
adswio3_adc_cnv_ctrl_t::diag_0_en
uint8_t diag_0_en
Definition: adswio3.h:490
adswio3_output_cfg_t::slew_lin_step
uint8_t slew_lin_step
Definition: adswio3.h:473
adswio3_live_status_t::di_sc_status
uint8_t di_sc_status
Definition: adswio3.h:533
adswio3_alert_status_t::di_sc_err
uint8_t di_sc_err
Definition: adswio3.h:511
adswio3_adc_cnv_ctrl_t::diag_1_en
uint8_t diag_1_en
Definition: adswio3.h:489
adswio3_adc_cfg_t::conv2_mux
uint8_t conv2_mux
Definition: adswio3.h:460
adswio3_live_status_t::adc_data_rdy
uint8_t adc_data_rdy
Definition: adswio3.h:535
adswio3_alert_status_t::analog_io_sc
uint8_t analog_io_sc
Definition: adswio3.h:504
adswio3_cfg_setup
void adswio3_cfg_setup(adswio3_cfg_t *cfg)
AD-SWIO 3 configuration object setup function.
adswio3_get_voltage_input
err_t adswio3_get_voltage_input(adswio3_t *ctx, uint8_t adc_sel, float *voltage)
AD-SWIO 3 gets the voltage input function.
adswio3_register_write
err_t adswio3_register_write(adswio3_t *ctx, uint8_t reg, uint16_t data_in)
AD-SWIO 3 data writing function.
adswio3_set_dac_code
err_t adswio3_set_dac_code(adswio3_t *ctx, uint16_t dac_code)
AD-SWIO 3 sets the DAC code for the output function.
adswio3_output_cfg_t::slew_lin_rate
uint8_t slew_lin_rate
Definition: adswio3.h:474
adswio3_register_read
err_t adswio3_register_read(adswio3_t *ctx, uint8_t reg, uint16_t *data_out)
AD-SWIO 3 data reading function.
adswio3_t::alr
digital_in_t alr
Definition: adswio3.h:415
adswio3_output_cfg_t::vout_range
uint8_t vout_range
Definition: adswio3.h:471
adswio3_live_status_t::temp_alert_status
uint8_t temp_alert_status
Definition: adswio3.h:534
adswio3_alert_status_t::temp_alert
uint8_t temp_alert
Definition: adswio3.h:513
adswio3_set_alert_mask
err_t adswio3_set_alert_mask(adswio3_t *ctx, uint16_t alert_mask)
AD-SWIO 3 sets the alert mask function.
adswio3_adc_cnv_ctrl_t
AD-SWIO 3 Click ADC conversion control object.
Definition: adswio3.h:484
adswio3_alert_status_t::reset_occurred
uint8_t reset_occurred
Definition: adswio3.h:517
adswio3_alert_status_t::analog_io_oc
uint8_t analog_io_oc
Definition: adswio3.h:503