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 "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 
70 #define ADSWIO3_REG_NOP 0x00
71 #define ADSWIO3_REG_CH_FUNC_SETUP 0x01
72 #define ADSWIO3_REG_ADC_CONFIG 0x02
73 #define ADSWIO3_REG_PWR_OPTIM_CONFIG 0x03
74 #define ADSWIO3_REG_DIN_CONFIG1 0x04
75 #define ADSWIO3_REG_DIN_CONFIG2 0x05
76 #define ADSWIO3_REG_OUTPUT_CONFIG 0x06
77 #define ADSWIO3_REG_RTD3W4W_CONFIG 0x07
78 #define ADSWIO3_REG_DO_INT_CONFIG 0x08
79 #define ADSWIO3_REG_DO_EXT_CONFIG 0x09
80 #define ADSWIO3_REG_I_BURNOUT_CONFIG 0x0A
81 #define ADSWIO3_REG_DAC_CODE 0x0B
82 #define ADSWIO3_REG_DAC_ACTIVE 0x0D
83 #define ADSWIO3_REG_GPIO_CONFIG0 0x35
84 #define ADSWIO3_REG_GPIO_CONFIG1 0x36
85 #define ADSWIO3_REG_GPIO_CONFIG2 0x37
86 #define ADSWIO3_REG_GPIO_CONFIG3 0x38
87 #define ADSWIO3_REG_FET_LKG_COMP 0x39
88 #define ADSWIO3_REG_CHARGE_PUMP 0x3A
89 #define ADSWIO3_REG_ADC_CONV_CTRL 0x3B
90 #define ADSWIO3_REG_DIAG_ASSIGN 0x3C
91 #define ADSWIO3_REG_DIN_COMP_OUT 0x40
92 #define ADSWIO3_REG_ALERT_STATUS 0x41
93 #define ADSWIO3_REG_LIVE_STATUS 0x42
94 #define ADSWIO3_REG_ADC_RESULT1 0x44
95 #define ADSWIO3_REG_ADC_RESULT2 0x46
96 #define ADSWIO3_REG_ADC_DIAG_RESULT0 0x53
97 #define ADSWIO3_REG_ADC_DIAG_RESULT1 0x54
98 #define ADSWIO3_REG_ADC_DIAG_RESULT2 0x55
99 #define ADSWIO3_REG_ADC_DIAG_RESULT3 0x56
100 #define ADSWIO3_REG_DIN_COUNTER 0x57
101 #define ADSWIO3_REG_SUPPLY_ALERT_STATUS 0x5B
102 #define ADSWIO3_REG_ALERT_MASK 0x5F
103 #define ADSWIO3_REG_SUPPLY_ALERT_MASK 0x60
104 #define ADSWIO3_REG_READ_SELECT 0x64
105 #define ADSWIO3_REG_BURST_READ_SEL 0x65
106 #define ADSWIO3_REG_PPC_TX 0x66
107 #define ADSWIO3_REG_PPC_ACTIVE 0x6E
108 #define ADSWIO3_REG_THERM_RST 0x77
109 #define ADSWIO3_REG_CMD_KEY 0x78
110 #define ADSWIO3_REG_SCRATCH_0 0x79
111 #define ADSWIO3_REG_SCRATCH_1 0x7A
112 #define ADSWIO3_REG_SILICON_REV 0x7B
113 #define ADSWIO3_REG_SILICON_ID0 0x7C
114 #define ADSWIO3_REG_SILICON_ID1 0x7D
115 #define ADSWIO3_REG_SILICON_ID2 0x7E
116 #define ADSWIO3_REG_SILICON_ID3 0x7F
117 #define ADSWIO3_REG_HART_ALERT_STATUS 0x80
118 #define ADSWIO3_REG_HART_RX 0x81
119 #define ADSWIO3_REG_HART_TX 0x82
120 #define ADSWIO3_REG_HART_FCR 0x83
121 #define ADSWIO3_REG_HART_MCR 0x84
122 #define ADSWIO3_REG_HART_RFC 0x85
123 #define ADSWIO3_REG_HART_TFC 0x86
124 #define ADSWIO3_REG_HART_ALERT_MASK 0x87
125 #define ADSWIO3_REG_HART_CONFIG 0x88
126 #define ADSWIO3_REG_HART_EVDET_COUNT 0x89
127  // adswio3_reg
129 
144 #define ADSWIO3_CH_FUNC_SETUP_ADC 0x00
145 #define ADSWIO3_CH_FUNC_SETUP_VTG_OUT 0x01
146 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT 0x02
147 #define ADSWIO3_CH_FUNC_SETUP_VTG_IN 0x03
148 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_EXT 0x04
149 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_LOOP 0x05
150 #define ADSWIO3_CH_FUNC_SETUP_2WIRE_RES_MEASURE 0x06
151 #define ADSWIO3_CH_FUNC_SETUP_3WIRE_RES_MEASURE 0x07
152 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOG 0x08
153 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOOP 0x09
154 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT_HART 0x0A
155 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_EXT 0x0B
156 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_LOOP 0x0C
157 
162 #define ADSWIO3_DIAG_ASSIGN_AGND 0x00
163 #define ADSWIO3_DIAG_ASSIGN_TEMP_SENS 0x01
164 #define ADSWIO3_DIAG_ASSIGN_DVCC 0x02
165 #define ADSWIO3_DIAG_ASSIGN_AVCC 0x03
166 #define ADSWIO3_DIAG_ASSIGN_ALDO1V8 0x04
167 #define ADSWIO3_DIAG_ASSIGN_DLDO1V8 0x05
168 #define ADSWIO3_DIAG_ASSIGN_REFOUT 0x06
169 #define ADSWIO3_DIAG_ASSIGN_AVDD 0x07
170 #define ADSWIO3_DIAG_ASSIGN_AVSS 0x08
171 #define ADSWIO3_DIAG_ASSIGN_LVIN 0x09
172 #define ADSWIO3_DIAG_ASSIGN_SENSEL 0x0A
173 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT1 0x0B
174 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT2 0x0C
175 #define ADSWIO3_DIAG_ASSIGN_DO_VDD 0x0D
176 #define ADSWIO3_DIAG_ASSIGN_AGND0 0x0E
177 #define ADSWIO3_DIAG_ASSIGN_CURRENT_EXT 0x0F
178 #define ADSWIO3_DIAG_RESULT_SEL_0 0x00
179 #define ADSWIO3_DIAG_RESULT_SEL_1 0x01
180 #define ADSWIO3_DIAG_RESULT_SEL_2 0x02
181 #define ADSWIO3_DIAG_RESULT_SEL_3 0x03
182 
187 #define ADSWIO3_READ_SELECT_SPI_RD_RET_INFO 0x01
188 #define ADSWIO3_READ_SELECT_AUTO_RD_EN 0x02
189 #define ADSWIO3_READ_REG_STATUS_BIT 0x7F
190 
195 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT1 0x00
196 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT2 0x01
197 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_HF 0x02
198 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_LF 0x03
199 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_AGND 0x04
200 #define ADSWIO3_PWR_OPTIM_CONFIG_LOW_PWR 0x00
201 #define ADSWIO3_PWR_OPTIM_CONFIG_FULL_PWR 0x01
202 
207 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_250UA 0x00
208 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_500UA 0x01
209 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_750UA 0x02
210 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_1MA 0x03
211 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC 0x00
212 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC_SWAP 0x01
213 #define ADSWIO3_RTD3W4W_CONFIG_RTD_3_WIRE 0x00
214 #define ADSWIO3_RTD3W4W_CONFIG_RTD_4_WIRE 0x01
215 #define ADSWIO3_RTD3W4W_CONFIG_BIT_MASK 0xFFF0u
216 
221 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
222 #define ADSWIO3_ADC_CONV_CTRL_CONV_EN 0x01
223 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
224 #define ADSWIO3_ADC_CONV_DIAG_DIS 0x00
225 #define ADSWIO3_ADC_CONV_DIAG_EN 0x01
226 #define ADSWIO3_ADC_CONV_SEQ_MODE_STBY 0x00
227 #define ADSWIO3_ADC_CONV_SEQ_START_SGL_CNV 0x01
228 #define ADSWIO3_ADC_CONV_SEQ_START_CONT_CNV 0x02
229 #define ADSWIO3_ADC_CONV_SEQ_STOP_CONT_CNV 0x03
230 #define ADSWIO3_ADC_CONV_RATE_DIAG_20_SPS 0x00
231 #define ADSWIO3_ADC_CONV_RATE_DIAG_4_8K_SPS 0x01
232 #define ADSWIO3_ADC_CONV_RATE_DIAG_9_6K_SPS 0x02
233 
238 #define ADSWIO3_ADC_CONFIG_CNV_RATE_10_SPS 0x00
239 #define ADSWIO3_ADC_CONFIG_CNV_RATE_20_SPS 0x01
240 #define ADSWIO3_ADC_CONFIG_CNV_RATE_1_2K_SPS 0x02
241 #define ADSWIO3_ADC_CONFIG_CNV_RATE_4_8K_SPS 0x03
242 #define ADSWIO3_ADC_CONFIG_CNV_RATE_9_6K_SPS 0x04
243 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_12V 0x00
244 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_12V 0x01
245 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_2_5V 0x02
246 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_M_2_5V 0x03
247 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_2_5V 0x04
248 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_0_625V 0x05
249 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_0_104V 0x06
250 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_AGND_SEN 0x00
251 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSELF 0x01
252 #define ADSWIO3_ADC_CONFIG_CNV1_SENSE_EXT2_EXT1 0x02
253 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSE_EXT1 0x03
254 #define ADSWIO3_ADC_CONFIG_CNV2_EXT1_AGND_SEN 0x00
255 #define ADSWIO3_ADC_CONFIG_CNV2_EXT2_AGND_SEN 0x01
256 #define ADSWIO3_ADC_CONFIG_CNV2_SENSE_EXT2_EXT1 0x02
257 #define ADSWIO3_ADC_CONFIG_CNV2_AGND_AGND 0x03
258 
263 #define ADSWIO3_DAC_CODE_RESOLUTION 0x3FFFu
264 
269 #define ADSWIO3_GPIO_CONFIG_SEL_A 0x00
270 #define ADSWIO3_GPIO_CONFIG_SEL_B 0x01
271 #define ADSWIO3_GPIO_CONFIG_SEL_C 0x02
272 #define ADSWIO3_GPIO_CONFIG_SEL_D 0x03
273 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_LOW 0x00
274 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_HIGH 0x01
275 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_DIS 0x00
276 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_EN 0x01
277 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_LOW 0x00
278 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_HIGH 0x01
279 #define ADSWIO3_GPIO_CONFIG_MODE_HI 0x00
280 #define ADSWIO3_GPIO_CONFIG_MODE_OUT 0x01
281 #define ADSWIO3_GPIO_CONFIG_MODE_OUT_IN 0x02
282 #define ADSWIO3_GPIO_CONFIG_MODE_IN 0x03
283 #define ADSWIO3_GPIO_CONFIG_MODE_FET 0x04
284 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_IN 0x05
285 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_OUT 0x06
286 #define ADSWIO3_GPIO_CONFIG_MODE_TX_COM 0x07
287 
292 #define ADSWIO3_ADC_RESULT_SEL_1 0x00
293 #define ADSWIO3_ADC_RESULT_SEL_2 0x01
294 #define ADSWIO3_ADC_RESULT_RESOLUTION 65536.0f
295 #define ADSWIO3_ADC_RESULT_RANGE 12.0f
296 
301 #define ADSWIO3_NTC_VTG_AT_25_C 1.0f
302 #define ADSWIO3_NTC_TABLE_POS_CALC_N 0.2f
303 #define ADSWIO3_NTC_TABLE_POS_CALC_P 0.5f
304 #define ADSWIO3_NTC_TABLE_POS_MAX 9
305 #define ADSWIO3_NTC_TABLE_NEG_MAX 13
306 #define ADSWIO3_NTC_TEMP_AT_1_V 25.0f
307 
312 #define ADSWIO3_ALERT_SPI_ERR_MASK 0x0004u
313 #define ADSWIO3_ALERT_PPC_ERR_MASK 0x0008u
314 #define ADSWIO3_ALERT_TEMP_ALERT_MASK 0x0010u
315 #define ADSWIO3_ALERT_ADC_ERR_MASK 0x0020u
316 #define ADSWIO3_ALERT_DI_SC_ERR_MASK 0x0040u
317 #define ADSWIO3_ALERT_DI_OC_ERR_MASK 0x0080u
318 #define ADSWIO3_ALERT_DO_THERM_RESET_MASK 0x0100u
319 #define ADSWIO3_ALERT_DO_EXT_SC_MASK 0x0200u
320 #define ADSWIO3_ALERT_DO_INT_SC_MASK 0x0400u
321 #define ADSWIO3_ALERT_DO_EXT_TIMEOUT_MASK 0x0800u
322 #define ADSWIO3_ALERT_DO_INT_TIMEOUT_MASK 0x1000u
323 #define ADSWIO3_ALERT_ANALOG_IO_SC_MASK 0x2000u
324 #define ADSWIO3_ALERT_ANALOG_IO_OC_MASK 0x4000u
325 
330 #define ADSWIO3_PPC_TX_DATA_BIT_MASK 0x00FFu
331 #define ADSWIO3_PPC_TX_AVDD_VTG_MIN 6.0f
332 #define ADSWIO3_PPC_TX_AVDD_VTG_DEFAULT 24.00f
333 #define ADSWIO3_PPC_TX_AVDD_VTG_MAX 24.20f
334 #define ADSWIO3_PPC_TX_AVDD_DATA_MAX 255.0f
335 #define ADSWIO3_PPC_TX_AVDD_DATA_CALC 1.0f
336 #define ADSWIO3_PPC_ACTIVE_TX_BUSY 0x0100u
337 #define ADSWIO3_PPC_ACTIVE_PPC_TX_BUSY_ERR 0x0200u
338 #define ADSWIO3_PPC_ACTIVE_PPC_TX_ACK_ERR 0x0400u
339 
344 #define ADSWIO3_DIN_CONFIG2_DIN_THRESH_MODE 0x0080u
345 #define ADSWIO3_SENS_SEL_TRSH_MULTI 50.0f
346 #define ADSWIO3_SENS_SEL_SCALE_MULTI 60.0f
347 #define ADSWIO3_SENS_SEL_TRSH_CORR_VAL 20.0f
348 
354 #define ADSWIO3_DIGI_OUT_MODE_SRC 0.3125f
355 #define ADSWIO3_DIGI_OUT_MODE_SNK 2.5f
356 
361 #define ADSWIO3_CALC_DIAG_AGND( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
362 #define ADSWIO3_CALC_DIAG_SENS_TEMP( DIAG_ADC ) ( DIAG_ADC / 8.95f ) - 40.0f
363 #define ADSWIO3_CALC_DIAG_DVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 8.25f
364 #define ADSWIO3_CALC_DIAG_ALDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 5.825f
365 #define ADSWIO3_CALC_DIAG_DLDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 7.5f
366 #define ADSWIO3_CALC_DIAG_REFOUT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 3.125f
367 #define ADSWIO3_CALC_DIAG_LVIN( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
368 #define ADSWIO3_CALC_DIAG_SENSE_EXT( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 50.0f ) - 20.0f
369 #define ADSWIO3_CALC_DIAG_DO_VDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 49.2f
370 #define ADSWIO3_CALC_DIAG_CURRENT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) / 1.38f
371 #define ADSWIO3_CALC_DIAG_VTG_AVDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 50.0f
372 #define ADSWIO3_CALC_DIAG_VTG_AVSS( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 31.017f ) - 20.0f
373 #define ADSWIO3_CALC_DIAG_VTG_AVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 17.5f
374 
383 #define ADSWIO3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
384 #define ADSWIO3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
385  // adswio3_set
387 
402 #define ADSWIO3_MAP_MIKROBUS( cfg, mikrobus ) \
403  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
404  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
405  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
406  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
407  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
408  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
409  cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
410  // adswio3_map // adswio3
413 
418 typedef struct
419 {
420  // Output pins
421  digital_out_t rst;
423  // Input pins
424  digital_in_t rdy;
425  digital_in_t alr;
427  // Modules
428  spi_master_t spi;
430  pin_name_t chip_select;
432  float dig_out_mode;
434 } adswio3_t;
435 
440 typedef struct
441 {
442  // Communication gpio pins
443  pin_name_t miso;
444  pin_name_t mosi;
445  pin_name_t sck;
446  pin_name_t cs;
448  // Additional gpio pins
449  pin_name_t rst;
450  pin_name_t rdy;
451  pin_name_t alr;
453  // static variable
454  uint32_t spi_speed;
455  spi_master_mode_t spi_mode;
456  spi_master_chip_select_polarity_t cs_polarity;
458 } adswio3_cfg_t;
459 
464 typedef struct
465 {
466  uint8_t conv2_rate;
467  uint8_t conv1_rate;
468  uint8_t conv2_range;
469  uint8_t conv1_range;
470  uint8_t conv2_mux;
471  uint8_t conv1_mux;
474 
479 typedef struct
480 {
481  uint8_t vout_range;
482  uint8_t slew_en;
483  uint8_t slew_lin_step;
484  uint8_t slew_lin_rate;
485  uint8_t i_limit;
488 
493 typedef struct
494 {
495  uint8_t conv_rate_diag;
496  uint8_t conv_seq;
497  uint8_t diag_3_en;
498  uint8_t diag_2_en;
499  uint8_t diag_1_en;
500  uint8_t diag_0_en;
501  uint8_t conv2_en;
502  uint8_t conv1_en;
505 
510 typedef struct
511 {
512  uint8_t hart_alert;
513  uint8_t analog_io_oc;
514  uint8_t analog_io_sc;
515  uint8_t do_int_timeout;
516  uint8_t do_ext_timeout;
517  uint8_t do_int_sc;
518  uint8_t do_ext_sc;
519  uint8_t do_therm_reset;
520  uint8_t di_oc_err;
521  uint8_t di_sc_err;
522  uint8_t adc_err;
523  uint8_t temp_alert;
524  uint8_t ppc_err;
525  uint8_t spi_err;
526  uint8_t supply_err;
527  uint8_t reset_occurred;
530 
535 typedef struct
536 {
542  uint8_t di_oc_status;
543  uint8_t di_sc_status;
545  uint8_t adc_data_rdy;
546  uint8_t adc_busy;
547  uint8_t supply_status;
550 
551 
556 typedef enum
557 {
559  ADSWIO3_ERROR = -1
560 
562 
579 
593 err_t adswio3_init ( adswio3_t *ctx, adswio3_cfg_t *cfg );
594 
608 
621 
635 err_t adswio3_register_write ( adswio3_t *ctx, uint8_t reg, uint16_t data_in );
636 
650 err_t adswio3_register_read ( adswio3_t *ctx, uint8_t reg, uint16_t *data_out );
651 
665 err_t adswio3_function_setup ( adswio3_t *ctx, uint8_t ch_fun );
666 
681 err_t adswio3_adc_config ( adswio3_t *ctx, adswio3_adc_cfg_t adc_config );
682 
697 err_t adswio3_pwr_optim_config ( adswio3_t *ctx, uint8_t buff_sel, uint8_t buff_mode );
698 
714 
730 err_t adswio3_rtd_config ( adswio3_t *ctx, uint8_t rtd_mode_sel, uint8_t rtd_exc_swap, uint8_t rtd_current );
731 
745 err_t adswio3_set_dac_code ( adswio3_t *ctx, uint16_t dac_code );
746 
763 err_t adswio3_set_gpio_config ( adswio3_t *ctx, uint8_t gpio_sel, uint8_t gpo_data,
764  uint8_t gp_wk_pd_en, uint8_t out_mode );
765 
781 
799 err_t adswio3_set_diag_assign ( adswio3_t *ctx, uint8_t diag_0, uint8_t diag_1,
800  uint8_t diag_2, uint8_t diag_3 );
801 
819  adswio3_live_status_t *live_status );
820 
835 err_t adswio3_get_adc_res ( adswio3_t *ctx, uint8_t adc_sel, uint16_t *adc_data );
836 
853 err_t adswio3_get_voltage_input ( adswio3_t *ctx, uint8_t adc_sel, float *voltage );
854 
869 err_t adswio3_get_diag_res ( adswio3_t *ctx, uint8_t diag_sel, uint16_t *adc_diag_data );
870 
888 err_t adswio3_get_diag_vtg ( adswio3_t *ctx, uint8_t diag_sel, float *diag_vtg );
889 
905 err_t adswio3_get_ntc_temp ( adswio3_t *ctx, uint8_t diag_sel, float *ntc_temp );
906 
921 err_t adswio3_set_alert_mask ( adswio3_t *ctx, uint16_t alert_mask );
922 
939 err_t adswio3_set_ppc_vtg ( adswio3_t *ctx, float ppc_vtg );
940 
953 uint8_t adswio3_get_ready ( adswio3_t *ctx );
954 
967 uint8_t adswio3_get_alarm ( adswio3_t *ctx );
968 
969 #ifdef __cplusplus
970 }
971 #endif
972 #endif // ADSWIO3_H
973  // adswio3
975 
976 // ------------------------------------------------------------------------ END
adswio3_cfg_t::rst
pin_name_t rst
Definition: adswio3.h:449
adswio3_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adswio3.h:455
adswio3_return_value_t
adswio3_return_value_t
AD-SWIO 3 Click return value data.
Definition: adswio3.h:557
adswio3_alert_status_t::supply_err
uint8_t supply_err
Definition: adswio3.h:526
adswio3_cfg_t::mosi
pin_name_t mosi
Definition: adswio3.h:444
adswio3_output_cfg_t::slew_en
uint8_t slew_en
Definition: adswio3.h:482
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:515
adswio3_alert_status_t::adc_err
uint8_t adc_err
Definition: adswio3.h:522
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:501
adswio3_live_status_t::do_ext_sc_status
uint8_t do_ext_sc_status
Definition: adswio3.h:540
adswio3_adc_cnv_ctrl_t::conv_rate_diag
uint8_t conv_rate_diag
Definition: adswio3.h:495
adswio3_live_status_t::supply_status
uint8_t supply_status
Definition: adswio3.h:547
adswio3_live_status_t::di_oc_status
uint8_t di_oc_status
Definition: adswio3.h:542
adswio3_adc_cfg_t
AD-SWIO 3 Click ADC configuration object.
Definition: adswio3.h:465
adswio3_cfg_t::alr
pin_name_t alr
Definition: adswio3.h:451
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adswio3_cfg_t::spi_speed
uint32_t spi_speed
Definition: adswio3.h:454
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:466
adswio3_cfg_t::cs
pin_name_t cs
Definition: adswio3.h:446
adswio3_alert_status_t::do_therm_reset
uint8_t do_therm_reset
Definition: adswio3.h:519
adswio3_adc_cfg_t::conv1_range
uint8_t conv1_range
Definition: adswio3.h:469
ADSWIO3_ERROR
@ ADSWIO3_ERROR
Definition: adswio3.h:559
adswio3_live_status_t::analog_io_oc_status
uint8_t analog_io_oc_status
Definition: adswio3.h:537
adswio3_alert_status_t::ppc_err
uint8_t ppc_err
Definition: adswio3.h:524
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:419
adswio3_t::rst
digital_out_t rst
Definition: adswio3.h:421
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:496
adswio3_alert_status_t::do_ext_timeout
uint8_t do_ext_timeout
Definition: adswio3.h:516
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:443
adswio3_adc_cfg_t::conv1_rate
uint8_t conv1_rate
Definition: adswio3.h:467
adswio3_adc_cnv_ctrl_t::diag_3_en
uint8_t diag_3_en
Definition: adswio3.h:497
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:485
adswio3_alert_status_t::do_ext_sc
uint8_t do_ext_sc
Definition: adswio3.h:518
adswio3_alert_status_t::hart_alert
uint8_t hart_alert
Definition: adswio3.h:512
adswio3_live_status_t
AD-SWIO 3 Click live status object.
Definition: adswio3.h:536
adswio3_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adswio3.h:456
adswio3_alert_status_t::di_oc_err
uint8_t di_oc_err
Definition: adswio3.h:520
adswio3_alert_status_t::do_int_sc
uint8_t do_int_sc
Definition: adswio3.h:517
adswio3_cfg_t::rdy
pin_name_t rdy
Definition: adswio3.h:450
adswio3_live_status_t::analog_io_sc_status
uint8_t analog_io_sc_status
Definition: adswio3.h:538
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:468
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:480
adswio3_t::dig_out_mode
float dig_out_mode
Definition: adswio3.h:432
adswio3_t::spi
spi_master_t spi
Definition: adswio3.h:428
adswio3_live_status_t::do_therm_reset_status
uint8_t do_therm_reset_status
Definition: adswio3.h:541
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:498
adswio3_alert_status_t
AD-SWIO 3 Click the alert status object.
Definition: adswio3.h:511
adswio3_adc_cnv_ctrl_t::conv1_en
uint8_t conv1_en
Definition: adswio3.h:502
adswio3_live_status_t::adc_busy
uint8_t adc_busy
Definition: adswio3.h:546
adswio3_live_status_t::do_int_sc_status
uint8_t do_int_sc_status
Definition: adswio3.h:539
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:424
adswio3_t::chip_select
pin_name_t chip_select
Definition: adswio3.h:430
adswio3_adc_cfg_t::conv1_mux
uint8_t conv1_mux
Definition: adswio3.h:471
ADSWIO3_OK
@ ADSWIO3_OK
Definition: adswio3.h:558
adswio3_cfg_t::sck
pin_name_t sck
Definition: adswio3.h:445
adswio3_cfg_t
AD-SWIO 3 Click configuration object.
Definition: adswio3.h:441
adswio3_alert_status_t::spi_err
uint8_t spi_err
Definition: adswio3.h:525
adswio3_adc_cnv_ctrl_t::diag_0_en
uint8_t diag_0_en
Definition: adswio3.h:500
adswio3_output_cfg_t::slew_lin_step
uint8_t slew_lin_step
Definition: adswio3.h:483
adswio3_live_status_t::di_sc_status
uint8_t di_sc_status
Definition: adswio3.h:543
adswio3_alert_status_t::di_sc_err
uint8_t di_sc_err
Definition: adswio3.h:521
adswio3_adc_cnv_ctrl_t::diag_1_en
uint8_t diag_1_en
Definition: adswio3.h:499
adswio3_adc_cfg_t::conv2_mux
uint8_t conv2_mux
Definition: adswio3.h:470
adswio3_live_status_t::adc_data_rdy
uint8_t adc_data_rdy
Definition: adswio3.h:545
adswio3_alert_status_t::analog_io_sc
uint8_t analog_io_sc
Definition: adswio3.h:514
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:484
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:425
adswio3_output_cfg_t::vout_range
uint8_t vout_range
Definition: adswio3.h:481
adswio3_live_status_t::temp_alert_status
uint8_t temp_alert_status
Definition: adswio3.h:544
adswio3_alert_status_t::temp_alert
uint8_t temp_alert
Definition: adswio3.h:523
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:494
adswio3_alert_status_t::reset_occurred
uint8_t reset_occurred
Definition: adswio3.h:527
adswio3_alert_status_t::analog_io_oc
uint8_t analog_io_oc
Definition: adswio3.h:513