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 
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 
74 #define ADSWIO3_REG_NOP 0x00
75 #define ADSWIO3_REG_CH_FUNC_SETUP 0x01
76 #define ADSWIO3_REG_ADC_CONFIG 0x02
77 #define ADSWIO3_REG_PWR_OPTIM_CONFIG 0x03
78 #define ADSWIO3_REG_DIN_CONFIG1 0x04
79 #define ADSWIO3_REG_DIN_CONFIG2 0x05
80 #define ADSWIO3_REG_OUTPUT_CONFIG 0x06
81 #define ADSWIO3_REG_RTD3W4W_CONFIG 0x07
82 #define ADSWIO3_REG_DO_INT_CONFIG 0x08
83 #define ADSWIO3_REG_DO_EXT_CONFIG 0x09
84 #define ADSWIO3_REG_I_BURNOUT_CONFIG 0x0A
85 #define ADSWIO3_REG_DAC_CODE 0x0B
86 #define ADSWIO3_REG_DAC_ACTIVE 0x0D
87 #define ADSWIO3_REG_GPIO_CONFIG0 0x35
88 #define ADSWIO3_REG_GPIO_CONFIG1 0x36
89 #define ADSWIO3_REG_GPIO_CONFIG2 0x37
90 #define ADSWIO3_REG_GPIO_CONFIG3 0x38
91 #define ADSWIO3_REG_FET_LKG_COMP 0x39
92 #define ADSWIO3_REG_CHARGE_PUMP 0x3A
93 #define ADSWIO3_REG_ADC_CONV_CTRL 0x3B
94 #define ADSWIO3_REG_DIAG_ASSIGN 0x3C
95 #define ADSWIO3_REG_DIN_COMP_OUT 0x40
96 #define ADSWIO3_REG_ALERT_STATUS 0x41
97 #define ADSWIO3_REG_LIVE_STATUS 0x42
98 #define ADSWIO3_REG_ADC_RESULT1 0x44
99 #define ADSWIO3_REG_ADC_RESULT2 0x46
100 #define ADSWIO3_REG_ADC_DIAG_RESULT0 0x53
101 #define ADSWIO3_REG_ADC_DIAG_RESULT1 0x54
102 #define ADSWIO3_REG_ADC_DIAG_RESULT2 0x55
103 #define ADSWIO3_REG_ADC_DIAG_RESULT3 0x56
104 #define ADSWIO3_REG_DIN_COUNTER 0x57
105 #define ADSWIO3_REG_SUPPLY_ALERT_STATUS 0x5B
106 #define ADSWIO3_REG_ALERT_MASK 0x5F
107 #define ADSWIO3_REG_SUPPLY_ALERT_MASK 0x60
108 #define ADSWIO3_REG_READ_SELECT 0x64
109 #define ADSWIO3_REG_BURST_READ_SEL 0x65
110 #define ADSWIO3_REG_PPC_TX 0x66
111 #define ADSWIO3_REG_PPC_ACTIVE 0x6E
112 #define ADSWIO3_REG_THERM_RST 0x77
113 #define ADSWIO3_REG_CMD_KEY 0x78
114 #define ADSWIO3_REG_SCRATCH_0 0x79
115 #define ADSWIO3_REG_SCRATCH_1 0x7A
116 #define ADSWIO3_REG_SILICON_REV 0x7B
117 #define ADSWIO3_REG_SILICON_ID0 0x7C
118 #define ADSWIO3_REG_SILICON_ID1 0x7D
119 #define ADSWIO3_REG_SILICON_ID2 0x7E
120 #define ADSWIO3_REG_SILICON_ID3 0x7F
121 #define ADSWIO3_REG_HART_ALERT_STATUS 0x80
122 #define ADSWIO3_REG_HART_RX 0x81
123 #define ADSWIO3_REG_HART_TX 0x82
124 #define ADSWIO3_REG_HART_FCR 0x83
125 #define ADSWIO3_REG_HART_MCR 0x84
126 #define ADSWIO3_REG_HART_RFC 0x85
127 #define ADSWIO3_REG_HART_TFC 0x86
128 #define ADSWIO3_REG_HART_ALERT_MASK 0x87
129 #define ADSWIO3_REG_HART_CONFIG 0x88
130 #define ADSWIO3_REG_HART_EVDET_COUNT 0x89
131  // adswio3_reg
133 
148 #define ADSWIO3_CH_FUNC_SETUP_ADC 0x00
149 #define ADSWIO3_CH_FUNC_SETUP_VTG_OUT 0x01
150 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT 0x02
151 #define ADSWIO3_CH_FUNC_SETUP_VTG_IN 0x03
152 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_EXT 0x04
153 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_LOOP 0x05
154 #define ADSWIO3_CH_FUNC_SETUP_2WIRE_RES_MEASURE 0x06
155 #define ADSWIO3_CH_FUNC_SETUP_3WIRE_RES_MEASURE 0x07
156 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOG 0x08
157 #define ADSWIO3_CH_FUNC_SETUP_DIGI_IN_LOOP 0x09
158 #define ADSWIO3_CH_FUNC_SETUP_CURR_OUT_HART 0x0A
159 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_EXT 0x0B
160 #define ADSWIO3_CH_FUNC_SETUP_CURR_IN_HART_LOOP 0x0C
161 
166 #define ADSWIO3_DIAG_ASSIGN_AGND 0x00
167 #define ADSWIO3_DIAG_ASSIGN_TEMP_SENS 0x01
168 #define ADSWIO3_DIAG_ASSIGN_DVCC 0x02
169 #define ADSWIO3_DIAG_ASSIGN_AVCC 0x03
170 #define ADSWIO3_DIAG_ASSIGN_ALDO1V8 0x04
171 #define ADSWIO3_DIAG_ASSIGN_DLDO1V8 0x05
172 #define ADSWIO3_DIAG_ASSIGN_REFOUT 0x06
173 #define ADSWIO3_DIAG_ASSIGN_AVDD 0x07
174 #define ADSWIO3_DIAG_ASSIGN_AVSS 0x08
175 #define ADSWIO3_DIAG_ASSIGN_LVIN 0x09
176 #define ADSWIO3_DIAG_ASSIGN_SENSEL 0x0A
177 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT1 0x0B
178 #define ADSWIO3_DIAG_ASSIGN_SENSE_EXT2 0x0C
179 #define ADSWIO3_DIAG_ASSIGN_DO_VDD 0x0D
180 #define ADSWIO3_DIAG_ASSIGN_AGND0 0x0E
181 #define ADSWIO3_DIAG_ASSIGN_CURRENT_EXT 0x0F
182 #define ADSWIO3_DIAG_RESULT_SEL_0 0x00
183 #define ADSWIO3_DIAG_RESULT_SEL_1 0x01
184 #define ADSWIO3_DIAG_RESULT_SEL_2 0x02
185 #define ADSWIO3_DIAG_RESULT_SEL_3 0x03
186 
191 #define ADSWIO3_READ_SELECT_SPI_RD_RET_INFO 0x01
192 #define ADSWIO3_READ_SELECT_AUTO_RD_EN 0x02
193 #define ADSWIO3_READ_REG_STATUS_BIT 0x7F
194 
199 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT1 0x00
200 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_EXT2 0x01
201 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_HF 0x02
202 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_LF 0x03
203 #define ADSWIO3_PWR_OPTIM_CONFIG_SEL_SEN_AGND 0x04
204 #define ADSWIO3_PWR_OPTIM_CONFIG_LOW_PWR 0x00
205 #define ADSWIO3_PWR_OPTIM_CONFIG_FULL_PWR 0x01
206 
211 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_250UA 0x00
212 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_500UA 0x01
213 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_750UA 0x02
214 #define ADSWIO3_RTD3W4W_CONFIG_RTD_CURR_1MA 0x03
215 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC 0x00
216 #define ADSWIO3_RTD3W4W_CONFIG_RTD_EXC_SWAP 0x01
217 #define ADSWIO3_RTD3W4W_CONFIG_RTD_3_WIRE 0x00
218 #define ADSWIO3_RTD3W4W_CONFIG_RTD_4_WIRE 0x01
219 #define ADSWIO3_RTD3W4W_CONFIG_BIT_MASK 0xFFF0u
220 
225 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
226 #define ADSWIO3_ADC_CONV_CTRL_CONV_EN 0x01
227 #define ADSWIO3_ADC_CONV_CTRL_CONV_DIS 0x00
228 #define ADSWIO3_ADC_CONV_DIAG_DIS 0x00
229 #define ADSWIO3_ADC_CONV_DIAG_EN 0x01
230 #define ADSWIO3_ADC_CONV_SEQ_MODE_STBY 0x00
231 #define ADSWIO3_ADC_CONV_SEQ_START_SGL_CNV 0x01
232 #define ADSWIO3_ADC_CONV_SEQ_START_CONT_CNV 0x02
233 #define ADSWIO3_ADC_CONV_SEQ_STOP_CONT_CNV 0x03
234 #define ADSWIO3_ADC_CONV_RATE_DIAG_20_SPS 0x00
235 #define ADSWIO3_ADC_CONV_RATE_DIAG_4_8K_SPS 0x01
236 #define ADSWIO3_ADC_CONV_RATE_DIAG_9_6K_SPS 0x02
237 
242 #define ADSWIO3_ADC_CONFIG_CNV_RATE_10_SPS 0x00
243 #define ADSWIO3_ADC_CONFIG_CNV_RATE_20_SPS 0x01
244 #define ADSWIO3_ADC_CONFIG_CNV_RATE_1_2K_SPS 0x02
245 #define ADSWIO3_ADC_CONFIG_CNV_RATE_4_8K_SPS 0x03
246 #define ADSWIO3_ADC_CONFIG_CNV_RATE_9_6K_SPS 0x04
247 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_12V 0x00
248 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_12V 0x01
249 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_2_5V 0x02
250 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_M_2_5V 0x03
251 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_2_5V 0x04
252 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_P_0_625V 0x05
253 #define ADSWIO3_ADC_CONFIG_CNV_RANGE_PM_0_104V 0x06
254 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_AGND_SEN 0x00
255 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSELF 0x01
256 #define ADSWIO3_ADC_CONFIG_CNV1_SENSE_EXT2_EXT1 0x02
257 #define ADSWIO3_ADC_CONFIG_CNV1_SENSELF_SENSE_EXT1 0x03
258 #define ADSWIO3_ADC_CONFIG_CNV2_EXT1_AGND_SEN 0x00
259 #define ADSWIO3_ADC_CONFIG_CNV2_EXT2_AGND_SEN 0x01
260 #define ADSWIO3_ADC_CONFIG_CNV2_SENSE_EXT2_EXT1 0x02
261 #define ADSWIO3_ADC_CONFIG_CNV2_AGND_AGND 0x03
262 
267 #define ADSWIO3_DAC_CODE_RESOLUTION 0x3FFFu
268 
273 #define ADSWIO3_GPIO_CONFIG_SEL_A 0x00
274 #define ADSWIO3_GPIO_CONFIG_SEL_B 0x01
275 #define ADSWIO3_GPIO_CONFIG_SEL_C 0x02
276 #define ADSWIO3_GPIO_CONFIG_SEL_D 0x03
277 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_LOW 0x00
278 #define ADSWIO3_GPIO_CONFIG_GPO_DATA_HIGH 0x01
279 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_DIS 0x00
280 #define ADSWIO3_GPIO_CONFIG_GP_WK_PD_EN 0x01
281 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_LOW 0x00
282 #define ADSWIO3_GPIO_CONFIG_DATA_LOGIC_HIGH 0x01
283 #define ADSWIO3_GPIO_CONFIG_MODE_HI 0x00
284 #define ADSWIO3_GPIO_CONFIG_MODE_OUT 0x01
285 #define ADSWIO3_GPIO_CONFIG_MODE_OUT_IN 0x02
286 #define ADSWIO3_GPIO_CONFIG_MODE_IN 0x03
287 #define ADSWIO3_GPIO_CONFIG_MODE_FET 0x04
288 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_IN 0x05
289 #define ADSWIO3_GPIO_CONFIG_MODE_C_TXD_OUT 0x06
290 #define ADSWIO3_GPIO_CONFIG_MODE_TX_COM 0x07
291 
296 #define ADSWIO3_ADC_RESULT_SEL_1 0x00
297 #define ADSWIO3_ADC_RESULT_SEL_2 0x01
298 #define ADSWIO3_ADC_RESULT_RESOLUTION 65536.0f
299 #define ADSWIO3_ADC_RESULT_RANGE 12.0f
300 
305 #define ADSWIO3_NTC_VTG_AT_25_C 1.0f
306 #define ADSWIO3_NTC_TABLE_POS_CALC_N 0.2f
307 #define ADSWIO3_NTC_TABLE_POS_CALC_P 0.5f
308 #define ADSWIO3_NTC_TABLE_POS_MAX 9
309 #define ADSWIO3_NTC_TABLE_NEG_MAX 13
310 #define ADSWIO3_NTC_TEMP_AT_1_V 25.0f
311 
316 #define ADSWIO3_ALERT_SPI_ERR_MASK 0x0004u
317 #define ADSWIO3_ALERT_PPC_ERR_MASK 0x0008u
318 #define ADSWIO3_ALERT_TEMP_ALERT_MASK 0x0010u
319 #define ADSWIO3_ALERT_ADC_ERR_MASK 0x0020u
320 #define ADSWIO3_ALERT_DI_SC_ERR_MASK 0x0040u
321 #define ADSWIO3_ALERT_DI_OC_ERR_MASK 0x0080u
322 #define ADSWIO3_ALERT_DO_THERM_RESET_MASK 0x0100u
323 #define ADSWIO3_ALERT_DO_EXT_SC_MASK 0x0200u
324 #define ADSWIO3_ALERT_DO_INT_SC_MASK 0x0400u
325 #define ADSWIO3_ALERT_DO_EXT_TIMEOUT_MASK 0x0800u
326 #define ADSWIO3_ALERT_DO_INT_TIMEOUT_MASK 0x1000u
327 #define ADSWIO3_ALERT_ANALOG_IO_SC_MASK 0x2000u
328 #define ADSWIO3_ALERT_ANALOG_IO_OC_MASK 0x4000u
329 
334 #define ADSWIO3_PPC_TX_DATA_BIT_MASK 0x00FFu
335 #define ADSWIO3_PPC_TX_AVDD_VTG_MIN 6.0f
336 #define ADSWIO3_PPC_TX_AVDD_VTG_DEFAULT 24.00f
337 #define ADSWIO3_PPC_TX_AVDD_VTG_MAX 24.20f
338 #define ADSWIO3_PPC_TX_AVDD_DATA_MAX 255.0f
339 #define ADSWIO3_PPC_TX_AVDD_DATA_CALC 1.0f
340 #define ADSWIO3_PPC_ACTIVE_TX_BUSY 0x0100u
341 #define ADSWIO3_PPC_ACTIVE_PPC_TX_BUSY_ERR 0x0200u
342 #define ADSWIO3_PPC_ACTIVE_PPC_TX_ACK_ERR 0x0400u
343 
348 #define ADSWIO3_DIN_CONFIG2_DIN_THRESH_MODE 0x0080u
349 #define ADSWIO3_SENS_SEL_TRSH_MULTI 50.0f
350 #define ADSWIO3_SENS_SEL_SCALE_MULTI 60.0f
351 #define ADSWIO3_SENS_SEL_TRSH_CORR_VAL 20.0f
352 
358 #define ADSWIO3_DIGI_OUT_MODE_SRC 0.3125f
359 #define ADSWIO3_DIGI_OUT_MODE_SNK 2.5f
360 
365 #define ADSWIO3_CALC_DIAG_AGND( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
366 #define ADSWIO3_CALC_DIAG_SENS_TEMP( DIAG_ADC ) ( DIAG_ADC / 8.95f ) - 40.0f
367 #define ADSWIO3_CALC_DIAG_DVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 8.25f
368 #define ADSWIO3_CALC_DIAG_ALDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 5.825f
369 #define ADSWIO3_CALC_DIAG_DLDO1V8( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 7.5f
370 #define ADSWIO3_CALC_DIAG_REFOUT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 3.125f
371 #define ADSWIO3_CALC_DIAG_LVIN( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 2.5f
372 #define ADSWIO3_CALC_DIAG_SENSE_EXT( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 50.0f ) - 20.0f
373 #define ADSWIO3_CALC_DIAG_DO_VDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 49.2f
374 #define ADSWIO3_CALC_DIAG_CURRENT( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) / 1.38f
375 #define ADSWIO3_CALC_DIAG_VTG_AVDD( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 50.0f
376 #define ADSWIO3_CALC_DIAG_VTG_AVSS( DIAG_ADC ) ( ( DIAG_ADC / 65536.0f ) * 31.017f ) - 20.0f
377 #define ADSWIO3_CALC_DIAG_VTG_AVCC( DIAG_ADC ) ( DIAG_ADC / 65536.0f ) * 17.5f
378 
387 #define ADSWIO3_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
388 #define ADSWIO3_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
389  // adswio3_set
391 
406 #define ADSWIO3_MAP_MIKROBUS( cfg, mikrobus ) \
407  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
408  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
409  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
410  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
411  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
412  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
413  cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
414  // adswio3_map // adswio3
417 
422 typedef struct
423 {
424  // Output pins
425  digital_out_t rst;
427  // Input pins
428  digital_in_t rdy;
429  digital_in_t alr;
431  // Modules
432  spi_master_t spi;
434  pin_name_t chip_select;
436  float dig_out_mode;
438 } adswio3_t;
439 
444 typedef struct
445 {
446  // Communication gpio pins
447  pin_name_t miso;
448  pin_name_t mosi;
449  pin_name_t sck;
450  pin_name_t cs;
452  // Additional gpio pins
453  pin_name_t rst;
454  pin_name_t rdy;
455  pin_name_t alr;
457  // static variable
458  uint32_t spi_speed;
459  spi_master_mode_t spi_mode;
460  spi_master_chip_select_polarity_t cs_polarity;
462 } adswio3_cfg_t;
463 
468 typedef struct
469 {
470  uint8_t conv2_rate;
471  uint8_t conv1_rate;
472  uint8_t conv2_range;
473  uint8_t conv1_range;
474  uint8_t conv2_mux;
475  uint8_t conv1_mux;
478 
483 typedef struct
484 {
485  uint8_t vout_range;
486  uint8_t slew_en;
487  uint8_t slew_lin_step;
488  uint8_t slew_lin_rate;
489  uint8_t i_limit;
492 
497 typedef struct
498 {
499  uint8_t conv_rate_diag;
500  uint8_t conv_seq;
501  uint8_t diag_3_en;
502  uint8_t diag_2_en;
503  uint8_t diag_1_en;
504  uint8_t diag_0_en;
505  uint8_t conv2_en;
506  uint8_t conv1_en;
509 
514 typedef struct
515 {
516  uint8_t hart_alert;
517  uint8_t analog_io_oc;
518  uint8_t analog_io_sc;
519  uint8_t do_int_timeout;
520  uint8_t do_ext_timeout;
521  uint8_t do_int_sc;
522  uint8_t do_ext_sc;
523  uint8_t do_therm_reset;
524  uint8_t di_oc_err;
525  uint8_t di_sc_err;
526  uint8_t adc_err;
527  uint8_t temp_alert;
528  uint8_t ppc_err;
529  uint8_t spi_err;
530  uint8_t supply_err;
531  uint8_t reset_occurred;
534 
539 typedef struct
540 {
546  uint8_t di_oc_status;
547  uint8_t di_sc_status;
549  uint8_t adc_data_rdy;
550  uint8_t adc_busy;
551  uint8_t supply_status;
554 
555 
560 typedef enum
561 {
563  ADSWIO3_ERROR = -1
564 
566 
583 
597 err_t adswio3_init ( adswio3_t *ctx, adswio3_cfg_t *cfg );
598 
612 
625 
639 err_t adswio3_register_write ( adswio3_t *ctx, uint8_t reg, uint16_t data_in );
640 
654 err_t adswio3_register_read ( adswio3_t *ctx, uint8_t reg, uint16_t *data_out );
655 
669 err_t adswio3_function_setup ( adswio3_t *ctx, uint8_t ch_fun );
670 
685 err_t adswio3_adc_config ( adswio3_t *ctx, adswio3_adc_cfg_t adc_config );
686 
701 err_t adswio3_pwr_optim_config ( adswio3_t *ctx, uint8_t buff_sel, uint8_t buff_mode );
702 
718 
734 err_t adswio3_rtd_config ( adswio3_t *ctx, uint8_t rtd_mode_sel, uint8_t rtd_exc_swap, uint8_t rtd_current );
735 
749 err_t adswio3_set_dac_code ( adswio3_t *ctx, uint16_t dac_code );
750 
767 err_t adswio3_set_gpio_config ( adswio3_t *ctx, uint8_t gpio_sel, uint8_t gpo_data,
768  uint8_t gp_wk_pd_en, uint8_t out_mode );
769 
785 
803 err_t adswio3_set_diag_assign ( adswio3_t *ctx, uint8_t diag_0, uint8_t diag_1,
804  uint8_t diag_2, uint8_t diag_3 );
805 
823  adswio3_live_status_t *live_status );
824 
839 err_t adswio3_get_adc_res ( adswio3_t *ctx, uint8_t adc_sel, uint16_t *adc_data );
840 
857 err_t adswio3_get_voltage_input ( adswio3_t *ctx, uint8_t adc_sel, float *voltage );
858 
873 err_t adswio3_get_diag_res ( adswio3_t *ctx, uint8_t diag_sel, uint16_t *adc_diag_data );
874 
892 err_t adswio3_get_diag_vtg ( adswio3_t *ctx, uint8_t diag_sel, float *diag_vtg );
893 
909 err_t adswio3_get_ntc_temp ( adswio3_t *ctx, uint8_t diag_sel, float *ntc_temp );
910 
925 err_t adswio3_set_alert_mask ( adswio3_t *ctx, uint16_t alert_mask );
926 
943 err_t adswio3_set_ppc_vtg ( adswio3_t *ctx, float ppc_vtg );
944 
957 uint8_t adswio3_get_ready ( adswio3_t *ctx );
958 
971 uint8_t adswio3_get_alarm ( adswio3_t *ctx );
972 
973 #ifdef __cplusplus
974 }
975 #endif
976 #endif // ADSWIO3_H
977  // adswio3
979 
980 // ------------------------------------------------------------------------ END
adswio3_cfg_t::rst
pin_name_t rst
Definition: adswio3.h:453
adswio3_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adswio3.h:459
adswio3_return_value_t
adswio3_return_value_t
AD-SWIO 3 Click return value data.
Definition: adswio3.h:561
adswio3_alert_status_t::supply_err
uint8_t supply_err
Definition: adswio3.h:530
adswio3_cfg_t::mosi
pin_name_t mosi
Definition: adswio3.h:448
adswio3_output_cfg_t::slew_en
uint8_t slew_en
Definition: adswio3.h:486
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:519
adswio3_alert_status_t::adc_err
uint8_t adc_err
Definition: adswio3.h:526
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:505
adswio3_live_status_t::do_ext_sc_status
uint8_t do_ext_sc_status
Definition: adswio3.h:544
adswio3_adc_cnv_ctrl_t::conv_rate_diag
uint8_t conv_rate_diag
Definition: adswio3.h:499
adswio3_live_status_t::supply_status
uint8_t supply_status
Definition: adswio3.h:551
adswio3_live_status_t::di_oc_status
uint8_t di_oc_status
Definition: adswio3.h:546
adswio3_adc_cfg_t
AD-SWIO 3 Click ADC configuration object.
Definition: adswio3.h:469
adswio3_cfg_t::alr
pin_name_t alr
Definition: adswio3.h:455
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adswio3_cfg_t::spi_speed
uint32_t spi_speed
Definition: adswio3.h:458
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:470
adswio3_cfg_t::cs
pin_name_t cs
Definition: adswio3.h:450
adswio3_alert_status_t::do_therm_reset
uint8_t do_therm_reset
Definition: adswio3.h:523
adswio3_adc_cfg_t::conv1_range
uint8_t conv1_range
Definition: adswio3.h:473
ADSWIO3_ERROR
@ ADSWIO3_ERROR
Definition: adswio3.h:563
adswio3_live_status_t::analog_io_oc_status
uint8_t analog_io_oc_status
Definition: adswio3.h:541
adswio3_alert_status_t::ppc_err
uint8_t ppc_err
Definition: adswio3.h:528
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:423
adswio3_t::rst
digital_out_t rst
Definition: adswio3.h:425
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:500
adswio3_alert_status_t::do_ext_timeout
uint8_t do_ext_timeout
Definition: adswio3.h:520
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:447
adswio3_adc_cfg_t::conv1_rate
uint8_t conv1_rate
Definition: adswio3.h:471
adswio3_adc_cnv_ctrl_t::diag_3_en
uint8_t diag_3_en
Definition: adswio3.h:501
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:489
adswio3_alert_status_t::do_ext_sc
uint8_t do_ext_sc
Definition: adswio3.h:522
adswio3_alert_status_t::hart_alert
uint8_t hart_alert
Definition: adswio3.h:516
adswio3_live_status_t
AD-SWIO 3 Click live status object.
Definition: adswio3.h:540
adswio3_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adswio3.h:460
adswio3_alert_status_t::di_oc_err
uint8_t di_oc_err
Definition: adswio3.h:524
adswio3_alert_status_t::do_int_sc
uint8_t do_int_sc
Definition: adswio3.h:521
adswio3_cfg_t::rdy
pin_name_t rdy
Definition: adswio3.h:454
adswio3_live_status_t::analog_io_sc_status
uint8_t analog_io_sc_status
Definition: adswio3.h:542
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:472
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:484
adswio3_t::dig_out_mode
float dig_out_mode
Definition: adswio3.h:436
adswio3_t::spi
spi_master_t spi
Definition: adswio3.h:432
adswio3_live_status_t::do_therm_reset_status
uint8_t do_therm_reset_status
Definition: adswio3.h:545
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:502
adswio3_alert_status_t
AD-SWIO 3 Click the alert status object.
Definition: adswio3.h:515
adswio3_adc_cnv_ctrl_t::conv1_en
uint8_t conv1_en
Definition: adswio3.h:506
adswio3_live_status_t::adc_busy
uint8_t adc_busy
Definition: adswio3.h:550
adswio3_live_status_t::do_int_sc_status
uint8_t do_int_sc_status
Definition: adswio3.h:543
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:428
adswio3_t::chip_select
pin_name_t chip_select
Definition: adswio3.h:434
adswio3_adc_cfg_t::conv1_mux
uint8_t conv1_mux
Definition: adswio3.h:475
ADSWIO3_OK
@ ADSWIO3_OK
Definition: adswio3.h:562
adswio3_cfg_t::sck
pin_name_t sck
Definition: adswio3.h:449
adswio3_cfg_t
AD-SWIO 3 Click configuration object.
Definition: adswio3.h:445
adswio3_alert_status_t::spi_err
uint8_t spi_err
Definition: adswio3.h:529
adswio3_adc_cnv_ctrl_t::diag_0_en
uint8_t diag_0_en
Definition: adswio3.h:504
adswio3_output_cfg_t::slew_lin_step
uint8_t slew_lin_step
Definition: adswio3.h:487
adswio3_live_status_t::di_sc_status
uint8_t di_sc_status
Definition: adswio3.h:547
adswio3_alert_status_t::di_sc_err
uint8_t di_sc_err
Definition: adswio3.h:525
adswio3_adc_cnv_ctrl_t::diag_1_en
uint8_t diag_1_en
Definition: adswio3.h:503
adswio3_adc_cfg_t::conv2_mux
uint8_t conv2_mux
Definition: adswio3.h:474
adswio3_live_status_t::adc_data_rdy
uint8_t adc_data_rdy
Definition: adswio3.h:549
adswio3_alert_status_t::analog_io_sc
uint8_t analog_io_sc
Definition: adswio3.h:518
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:488
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:429
adswio3_output_cfg_t::vout_range
uint8_t vout_range
Definition: adswio3.h:485
adswio3_live_status_t::temp_alert_status
uint8_t temp_alert_status
Definition: adswio3.h:548
adswio3_alert_status_t::temp_alert
uint8_t temp_alert
Definition: adswio3.h:527
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:498
adswio3_alert_status_t::reset_occurred
uint8_t reset_occurred
Definition: adswio3.h:531
adswio3_alert_status_t::analog_io_oc
uint8_t analog_io_oc
Definition: adswio3.h:517