adswio2  2.0.0.0
adswio2.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef ADSWIO2_H
36 #define ADSWIO2_H
37 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 #include "drv_spi_master.h"
55 #include "spi_specifics.h"
56 
57 // -------------------------------------------------------------- PUBLIC MACROS
68 #define ADSWIO2_MAP_MIKROBUS( cfg, mikrobus ) \
69  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
74  cfg.alt = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
75  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
76 
82 #define adswio2_obj_t const uint8_t*
83 
89 #define adswio2_err_t uint8_t
90 
96 #define ADSWIO2_RETVAL uint8_t
97 
98 #define ADSWIO2_OK 0x00
99 #define ADSWIO2_INIT_ERROR 0xFF
100 
106 #define ADSWIO2_FRAME_LENGTH 4
107 #define ADSWIO2_MASK_RD_FRAME_RESERVED_BIT 0x80
108 #define ADSWIO2_MASK_RD_FRAME_REG_ADDR 0x7F
109 #define ADSWIO2_MASK_RD_FRAME_STATUS 0x7F
110 
116 #define ADSWIO2_RD_RET_INFO 0x1
117 
123 #define ADSWIO2_OFFSET_REG_CONV_RES 0x25
124 #define ADSWIO2_OFFSET_REG_DIAG_RES 0x29
125 
131 #define DUMMY 0
132 #define ADSWIO2_NULL 0
133 
139 #define ADSWIO2_RD_AUTO_EN 0x2
140 #define ADSWIO2_RD_AUTO_DIS 0x0
141 
152 #define ADSWIO2_MASK_CONV_EN 0xF
153 #define ADSWIO2_OFFSET_CONV_EN_CH 0
154 #define ADSWIO2_OFFSET_CONV_EN_DIAG 4
155 
161 #define ADSWIO2_MASK_DIAG_ASSIGN 0xF
162 #define ADSWIO2_OFFSET_ASSIGN_DIAG0 0
163 #define ADSWIO2_OFFSET_ASSIGN_DIAG1 4
164 #define ADSWIO2_OFFSET_ASSIGN_DIAG2 8
165 #define ADSWIO2_OFFSET_ASSIGN_DIAG3 12
166 
172 #define ADSWIO2_MASK_CONV_MODE 0x300
173 #define ADSWIO2_OFFSET_CONV_MODE 8
174 
180 #define ADSWIO2_MASK_DAC_CODE 0x1FFF
181 
187 #define ADSWIO2_MASK_ALERT 0x7FFF
188 
194 #define ADSWIO2_MASK_DIN_THRESH_COMP 0x3E
195 
201 #define ADSWIO2_MASK_STATUS_ALRT_CAL_MEM_ERR 0x4000
202 #define ADSWIO2_MASK_STATUS_ALRT_SPI_CRC_ERR 0x2000
203 #define ADSWIO2_MASK_STATUS_ALRT_RST 0x8000
204 #define ADSWIO2_MASK_STATUS_ALRT_SPI_SCLK_CNT_ERR 0x1000
205 #define ADSWIO2_MASK_STATUS_ALRT_ADC_SAT_ERR 0x800
206 #define ADSWIO2_MASK_STATUS_ALRT_ADC_CONV_ERR 0x400
207 #define ADSWIO2_MASK_STATUS_ALRT_ALDO1V8_ERR 0x200
208 #define ADSWIO2_MASK_STATUS_ALRT_DVCC_ERR 0x100
209 #define ADSWIO2_MASK_STATUS_ALRT_AVDD_ERR 0x80
210 #define ADSWIO2_MASK_STATUS_ALRT_ALDO5V_ERR 0x40
211 #define ADSWIO2_MASK_STATUS_ALRT_CHARGE_PUMP_ERR 0x20
212 #define ADSWIO2_MASK_STATUS_ALRT_HI_TEMP_ERR 0x10
213 #define ADSWIO2_MASK_STATUS_ALRT_VI_ERR_D 0x8
214 #define ADSWIO2_MASK_STATUS_ALRT_VI_ERR_C 0x4
215 #define ADSWIO2_MASK_STATUS_ALRT_VI_ERR_B 0x2
216 #define ADSWIO2_MASK_STATUS_ALRT_VI_ERR_A 0x1
217 
223 #define ADSWIO2_MASK_STATUS_LIVE_ADC_DRDY 0x4000
224 #define ADSWIO2_MASK_STATUS_LIVE_ADC_BUSY 0x2000
225 #define ADSWIO2_MASK_STATUS_LIVE_ADC_CURR_CH 0x1C00
226 #define ADSWIO2_MASK_STATUS_LIVE_ALDO1V8 0x200
227 #define ADSWIO2_MASK_STATUS_LIVE_DVCC 0x100
228 #define ADSWIO2_MASK_STATUS_LIVE_AVDD 0x80
229 #define ADSWIO2_MASK_STATUS_LIVE_ALDO5V 0x40
230 #define ADSWIO2_MASK_STATUS_LIVE_CHARGE_PUMP 0x20
231 #define ADSWIO2_MASK_STATUS_LIVE_HI_TEMP 0x10
232 #define ADSWIO2_MASK_STATUS_LIVE_VI_ERR_CURR_D 0x8
233 #define ADSWIO2_MASK_STATUS_LIVE_VI_ERR_CURR_C 0x4
234 #define ADSWIO2_MASK_STATUS_LIVE_VI_ERR_CURR_B 0x2
235 #define ADSWIO2_MASK_STATUS_LIVE_VI_ERR_CURR_A 0x1
236 
242 #define ADSWIO2_MAX_NWORDS 4
243 #define ADSWIO2_MIN_NWORDS 1
244  // End offset_mask group
247 
252 #define ADSWIO2_REG_NOP 0x0
253 #define ADSWIO2_REG_FUNC_SETUP_CHA 0x1
254 #define ADSWIO2_REG_FUNC_SETUP_CHB 0x2
255 #define ADSWIO2_REG_FUNC_SETUP_CHC 0x3
256 #define ADSWIO2_REG_FUNC_SETUP_CHD 0x4
257 #define ADSWIO2_REG_CFG_ADC_CHA 0x5
258 #define ADSWIO2_REG_CFG_ADC_CHB 0x6
259 #define ADSWIO2_REG_CFG_ADC_CHC 0x7
260 #define ADSWIO2_REG_CFG_ADC_CHD 0x8
261 #define ADSWIO2_REG_CFG_DIN_CHA 0x9
262 #define ADSWIO2_REG_CFG_DIN_CHB 0xA
263 #define ADSWIO2_REG_CFG_DIN_CHC 0xB
264 #define ADSWIO2_REG_CFG_DIN_CHD 0xC
265 #define ADSWIO2_REG_GPO_PARALLEL 0xD
266 #define ADSWIO2_REG_CFG_GPO_CHA 0xE
267 #define ADSWIO2_REG_CFG_GPO_CHB 0xF
268 #define ADSWIO2_REG_CFG_GPO_CHC 0x10
269 #define ADSWIO2_REG_CFG_GPO_CHD 0x11
270 #define ADSWIO2_REG_CFG_OUTPUT_CHA 0x12
271 #define ADSWIO2_REG_CFG_OUTPUT_CHB 0x13
272 #define ADSWIO2_REG_CFG_OUTPUT_CHC 0x14
273 #define ADSWIO2_REG_CFG_OUTPUT_CHD 0x15
274 #define ADSWIO2_REG_DAC_CODE_CHA 0x16
275 #define ADSWIO2_REG_DAC_CODE_CHB 0x17
276 #define ADSWIO2_REG_DAC_CODE_CHC 0x18
277 #define ADSWIO2_REG_DAC_CODE_CHD 0x19
278 #define ADSWIO2_REG_DAC_CODE_CLR_CHA 0x1A
279 #define ADSWIO2_REG_DAC_CODE_CLR_CHB 0x1B
280 #define ADSWIO2_REG_DAC_CODE_CLR_CHC 0x1C
281 #define ADSWIO2_REG_DAC_CODE_CLR_CHD 0x1D
282 #define ADSWIO2_REG_DAC_CODE_ACT_CHA 0x1E
283 #define ADSWIO2_REG_DAC_CODE_ACT_CHB 0x1F
284 #define ADSWIO2_REG_DAC_CODE_ACT_CHC 0x20
285 #define ADSWIO2_REG_DAC_CODE_ACT_CHD 0x21
286 #define ADSWIO2_REG_DIN_THRESH 0x22
287 #define ADSWIO2_REG_ADC_CONV_CTRL 0x23
288 #define ADSWIO2_REG_DIAG_ASSIGN 0x24
289 #define ADSWIO2_REG_DIN_COMP_OUT 0x25
290 #define ADSWIO2_REG_RESULT_ADC_CHA 0x26
291 #define ADSWIO2_REG_RESULT_ADC_CHB 0x27
292 #define ADSWIO2_REG_RESULT_ADC_CHC 0x28
293 #define ADSWIO2_REG_RESULT_ADC_CHD 0x29
294 #define ADSWIO2_REG_RESULT_DIAG1 0x2A
295 #define ADSWIO2_REG_RESULT_DIAG2 0x2B
296 #define ADSWIO2_REG_RESULT_DIAG3 0x2C
297 #define ADSWIO2_REG_RESULT_DIAG4 0x2D
298 #define ADSWIO2_REG_STATUS_ALERT 0x2E
299 #define ADSWIO2_REG_STATUS_LIVE 0x2F
300 #define ADSWIO2_REG_MASK_ALERT 0x3C
301 #define ADSWIO2_REG_DIN_COUNTER_CHA 0x3D
302 #define ADSWIO2_REG_DIN_COUNTER_CHB 0x3E
303 #define ADSWIO2_REG_DIN_COUNTER_CHC 0x3F
304 #define ADSWIO2_REG_DIN_COUNTER_CHD 0x40
305 #define ADSWIO2_REG_READ_SELECT 0x41
306 #define ADSWIO2_REG_THERM_RST 0x43
307 #define ADSWIO2_REG_CMD_KEY 0x44
308 #define ADSWIO2_REG_SCRATCH 0x45
309 #define ADSWIO2_REG_SILICON_REV 0x46
310 
321 #define ADSWIO2_SETUP_CONV_EN_CHD 0x8
322 #define ADSWIO2_SETUP_CONV_EN_CHC 0x4
323 #define ADSWIO2_SETUP_CONV_EN_CHB 0x2
324 #define ADSWIO2_SETUP_CONV_EN_CHA 0x1
325 
331 #define ADSWIO2_SETUP_CH_FUNC_HZ 0x0
332 #define ADSWIO2_SETUP_CH_FUNC_VOLT_OUTPUT 0x1
333 #define ADSWIO2_SETUP_CH_FUNC_CURR_OUTPUT 0x2
334 #define ADSWIO2_SETUP_CH_FUNC_VOLT_INPUT 0x3
335 #define ADSWIO2_SETUP_CH_FUNC_CURR_INPUT_PWR_EXT 0x4
336 #define ADSWIO2_SETUP_CH_FUNC_CURR_INPUT_PWR_LOOP 0x5
337 #define ADSWIO2_SETUP_CH_FUNC_RES_MEAS 0x6
338 #define ADSWIO2_SETUP_CH_FUNC_DIG_INPUT_LOGIC 0x7
339 #define ADSWIO2_SETUP_CH_FUNC_DIG_INPUT_PWR_LOOP 0x8
340 #define ADSWIO2_SETUP_CH_FUNC_CURR_INPUT_PWR_EXT_HART 0x9
341 #define ADSWIO2_SETUP_CH_FUNC_CURR_INPUT_PWR_LOOP_HART 0xA
342 
348 #define ADSWIO2_SETUP_CONV_EN_DIAG3 0x8
349 #define ADSWIO2_SETUP_CONV_EN_DIAG2 0x4
350 #define ADSWIO2_SETUP_CONV_EN_DIAG1 0x2
351 #define ADSWIO2_SETUP_CONV_EN_DIAG0 0x1
352 
358 #define ADSWIO2_SETUP_DIAG_ASSIGN_AGND 0x0
359 #define ADSWIO2_SETUP_DIAG_ASSIGN_TEMP 0x1
360 #define ADSWIO2_SETUP_DIAG_ASSIGN_AVDD 0x2
361 #define ADSWIO2_SETUP_DIAG_ASSIGN_VAVSS 0x3
362 #define ADSWIO2_SETUP_DIAG_ASSIGN_REFOUT 0x4
363 #define ADSWIO2_SETUP_DIAG_ASSIGN_ALDO5V 0x5
364 #define ADSWIO2_SETUP_DIAG_ASSIGN_ALDO1V8 0x6
365 #define ADSWIO2_SETUP_DIAG_ASSIGN_DLDO1V8 0x7
366 #define ADSWIO2_SETUP_DIAG_ASSIGN_DVCC 0x8
367 #define ADSWIO2_SETUP_DIAG_ASSIGN_IOVDD 0x9
368 #define ADSWIO2_SETUP_DIAG_ASSIGN_SENSELA 0xA
369 #define ADSWIO2_SETUP_DIAG_ASSIGN_SENSELB 0xB
370 #define ADSWIO2_SETUP_DIAG_ASSIGN_SENSELC 0xC
371 #define ADSWIO2_SETUP_DIAG_ASSIGN_SENSELD 0xD
372 #define ADSWIO2_SETUP_DIAG_ASSIGN_LVIN 0xE
373 
379 #define ADSWIO2_SETUP_CONV_STOP_CONT_CONV_ADC_PWR_UP 0x0
380 #define ADSWIO2_SETUP_CONV_START_SING_SEQ_CONV 0x1
381 #define ADSWIO2_SETUP_CONV_START_CONT_CONV 0x2
382 #define ADSWIO2_SETUP_CONV_STOP_CONT_CONV_ADC_PWR_DWN 0x3
383 
389 #define ADSWIO2_SETUP_ADC_RANGE_0V_TO_10V 0x0
390 #define ADSWIO2_SETUP_ADC_RANGE_2500MV_PWR_EXT 0x20
391 #define ADSWIO2_SETUP_ADC_RANGE_2500MV_PWR_LOOP 0x40
392 #define ADSWIO2_SETUP_ADC_RANGE_2500MV_NEG_TO_2500MV_POS 0x60
393 #define ADSWIO2_SETUP_ADC_RANGE_104MV_NEG_TO_104MV_POS 0x80
394 #define ADSWIO2_SETUP_ADC_SAMPLE_RATE_20SPS 0x0
395 #define ADSWIO2_SETUP_ADC_SAMPLE_RATE_4800SPS 0x8
396 #define ADSWIO2_SETUP_ADC_SAMPLE_RATE_10SPS 0x10
397 #define ADSWIO2_SETUP_ADC_SAMPLE_RATE_1200SPS 0x18
398 #define ADSWIO2_SETUP_ADC_CH_200K_TO_GND 0x4
399 #define ADSWIO2_SETUP_ADC_INPUT_VOLTAGE_AGND_SENSE 0x0
400 #define ADSWIO2_SETUP_ADC_INPUT_VOLTAGE_100_OHM_RES 0x1
401 
407 #define ADSWIO2_SETUP_DIN_COUNT_EN 0x8000
408 #define ADSWIO2_SETUP_DIN_COMP_IN_FILTERED 0x4000
409 #define ADSWIO2_SETUP_DIN_COMP_OUT_INV 0x2000
410 #define ADSWIO2_SETUP_DIN_COMP_EN 0x1000
411 #define ADSWIO2_SETUP_DIN_RANGE_0 0x0
412 #define ADSWIO2_SETUP_DIN_RANGE_1 0x800
413 #define ADSWIO2_SETUP_DIN_DEBOUNCE_MODE_0 0x0
414 #define ADSWIO2_SETUP_DIN_DEBOUNCE_MODE_1 0x20
415 
421 #define ADSWIO2_SETUP_GPO_PARALL_DATA_D 0x8
422 #define ADSWIO2_SETUP_GPO_PARALL_DATA_C 0x4
423 #define ADSWIO2_SETUP_GPO_PARALL_DATA_B 0x2
424 #define ADSWIO2_SETUP_GPO_PARALL_DATA_A 0x1
425 
431 #define ADSWIO2_SETUP_GPO_LOGIC_LOW 0x0
432 #define ADSWIO2_SETUP_GPO_LOGIC_HIGH 0x8
433 
439 #define ADSWIO2_SETUP_OUT_SLEW_EN_LINEAR 0x40
440 #define ADSWIO2_SETUP_OUT_SLEW_EN_HART 0x80
441 #define ADSWIO2_SETUP_OUT_SLEW_LIN_STEP_64_DEC_CODES 0x0
442 #define ADSWIO2_SETUP_OUT_SLEW_LIN_STEP_120_DEC_CODES 0x10
443 #define ADSWIO2_SETUP_OUT_SLEW_LIN_STEP_500_DEC_CODES 0x20
444 #define ADSWIO2_SETUP_OUT_SLEW_LIN_STEP_1820_DEC_CODES 0x30
445 #define ADSWIO2_SETUP_OUT_SLEW_LIN_RATE_4KHZ 0x0
446 #define ADSWIO2_SETUP_OUT_SLEW_LIN_RATE_64KHZ 0x4
447 #define ADSWIO2_SETUP_OUT_SLEW_LIN_RATE_150KHZ 0x8
448 #define ADSWIO2_SETUP_OUT_SLEW_LIN_RATE_240KHZ 0xC
449 #define ADSWIO2_SETUP_OUT_CLR_EN 0x2
450 #define ADSWIO2_SETUP_OUT_CURR_LIM_30MA 0x0
451 #define ADSWIO2_SETUP_OUT_CURR_LIM_7_5MA 0x1
452 
458 #define ADSWIO2_SETUP_DIN_THRESH_GND_AND_AVDD 0x0
459 #define ADSWIO2_SETUP_DIN_THRESH_GND_AND_16V 0x1
460 
466 #define ADSWIO2_SETUP_CONV_EN_50_60_HZ_REJ_DIAG 0x400
467 
468 #define ADSWIO2_SETUP_CONV_EN_ALL_CH 0xF
469 #define ADSWIO2_SETUP_CONV_EN_ALL_DIAG 0xF
470 #define ADSWIO2_SETUP_CONV_DIS_ALL_CH 0x0
471 #define ADSWIO2_SETUP_CONV_DIS_ALL_DIAG 0x0
472 
478 #define ADSWIO2_SETUP_THERM_RST_EN 0x1
479 
485 #define ADSWIO2_STATUS_LIVE_ADC_CURR_CHA 0x0
486 #define ADSWIO2_STATUS_LIVE_ADC_CURR_CHB 0x400
487 #define ADSWIO2_STATUS_LIVE_ADC_CURR_CHC 0x800
488 #define ADSWIO2_STATUS_LIVE_ADC_CURR_CHD 0xC00
489 #define ADSWIO2_STATUS_LIVE_ADC_CURR_DIAG0 0x1000
490 #define ADSWIO2_STATUS_LIVE_ADC_CURR_DIAG1 0x1400
491 #define ADSWIO2_STATUS_LIVE_ADC_CURR_DIAG2 0x1800
492 #define ADSWIO2_STATUS_LIVE_ADC_CURR_DIAG3 0x1C00
493 
499 #define ADSWIO2_CMD_NOP 0x0
500 #define ADSWIO2_CMD_SW_RST_KEY1 0x15FA
501 #define ADSWIO2_CMD_SW_RST_KEY2 0xAF51
502 #define ADSWIO2_CMD_LDAC_KEY 0x953A
503 #define ADSWIO2_CMD_DAC_CLR_KEY 0x73D1
504  // End reg_setup group
507 
512 #define ADSWIO2_ERR_STATUS_OK 0
513 #define ADSWIO2_ERR_INIT_DRV 1
514 #define ADSWIO2_ERR_UNSUPPORTED_PIN 2
515 #define ADSWIO2_ERR_RD_STATUS 3
516 #define ADSWIO2_ERR_RD_MODE 4
517 #define ADSWIO2_ERR_RD_NWORDS 5
518 #define ADSWIO2_ERR_CMD_KEY 6
519 #define ADSWIO2_ERR_EN_CH 7
520 #define ADSWIO2_ERR_EN_DIAG 8
521 #define ADSWIO2_ERR_CRC 9
522 #define ADSWIO2_ERR_REG_ADDR 10
523 #define ADSWIO2_ERR_CONV_MODE 11
524 #define ADSWIO2_ERR_CH_FUNC 12
525 #define ADSWIO2_ERR_DIAG_ASSIGN 13
526 
532 #define ADSWIO2_ID_SILICON_REV 0x8
533 
543 #define ADSWIO2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
544 #define ADSWIO2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
545  // End group macro
547 // --------------------------------------------------------------- PUBLIC TYPES
556 typedef void ( * adswio2_handler_t )( uint8_t * );
557 
558 
562 typedef struct
563 {
564  // Output pins
565 
566  digital_out_t cs;
567  digital_out_t rst;
568 
569  // Input pins
570 
571  digital_out_t alt;
572  digital_in_t rdy;
573 
574  // Modules
575 
576  spi_master_t spi;
577  pin_name_t chip_select;
578 
579  // static variable
580 
582 
583 } adswio2_t;
584 
588 typedef struct
589 {
590  // static variable
591 
592  uint8_t reg_addr;
593  uint16_t *data_out;
594  uint8_t rd_mode;
595  uint8_t n_words;
596 
598 
602 typedef struct
603 {
604  // Communication gpio pins
605 
606  pin_name_t miso;
607  pin_name_t mosi;
608  pin_name_t sck;
609  pin_name_t cs;
610 
611  // Additional gpio pins
612 
613  pin_name_t rst;
614  pin_name_t alt;
615  pin_name_t rdy;
616 
617  // static variable
618 
619  uint32_t spi_speed;
620  spi_master_mode_t spi_mode;
621  spi_master_chip_select_polarity_t cs_polarity;
622 
623 } adswio2_cfg_t;
624  // End types group
626 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
627 
632 #ifdef __cplusplus
633 extern "C"{
634 #endif
635 
645 
655 
664 
676 void adswio2_generic_transfer ( adswio2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
677 
684 
695 
706 
716 
725 
737 adswio2_err_t adswio2_generic_write ( adswio2_t *ctx, uint8_t reg_addr, uint16_t data_in );
738 
758 adswio2_err_t adswio2_generic_read ( adswio2_t *ctx, uint8_t reg_addr, uint16_t *data_out, uint8_t *rd_status );
759 
785 
796 adswio2_err_t adswio2_exe_command ( adswio2_t *ctx, uint16_t cmd_key );
797 
806 void adswio2_mask_alert_set ( adswio2_t *ctx, uint16_t alert_mask );
807 
820 adswio2_err_t adswio2_status_live ( adswio2_t *ctx, uint16_t *status, uint16_t status_mask );
821 
836 adswio2_err_t adswio2_status_data_ready ( adswio2_t *ctx, uint8_t *drdy, uint16_t *conv_target );
837 
852 adswio2_err_t adswio2_status_alert ( adswio2_t *ctx, uint16_t *status, uint16_t status_mask );
853 
871 
888 adswio2_err_t adswio2_enable_ch ( adswio2_t *ctx, uint8_t channel );
889 
906 adswio2_err_t adswio2_enable_diag ( adswio2_t *ctx, uint8_t diagnostic );
907 
919 adswio2_err_t adswio2_set_ch_func ( adswio2_t *ctx, uint8_t channel, uint8_t ch_func );
920 
939 adswio2_err_t adswio2_assign_diag ( adswio2_t *ctx, uint8_t diagnostic, uint8_t duty );
940 
958 adswio2_err_t adswio2_get_conv_results ( adswio2_t *ctx, uint8_t channel, uint16_t *data_out );
959 
977 adswio2_err_t adswio2_get_diag_results ( adswio2_t *ctx, uint8_t diagnostic, uint16_t *data_out );
978 
979 #ifdef __cplusplus
980 }
981 #endif
982 #endif // _ADSWIO2_H_
983  // End public_function group
986 
987 // ------------------------------------------------------------------------- END
adswio2_t
Click ctx object definition.
Definition: adswio2.h:563
adswio2_t::alt
digital_out_t alt
Definition: adswio2.h:571
adswio2_read_t::n_words
uint8_t n_words
Definition: adswio2.h:595
adswio2_enable_ch
adswio2_err_t adswio2_enable_ch(adswio2_t *ctx, uint8_t channel)
Channel Enable function.
adswio2_get_conv_results
adswio2_err_t adswio2_get_conv_results(adswio2_t *ctx, uint8_t channel, uint16_t *data_out)
Channel Results Get function.
adswio2_t::rst
digital_out_t rst
Definition: adswio2.h:567
adswio2_cfg_t::mosi
pin_name_t mosi
Definition: adswio2.h:607
adswio2_enable_diag
adswio2_err_t adswio2_enable_diag(adswio2_t *ctx, uint8_t diagnostic)
Diagnostic Enable function.
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adswio2_status_pin_ready
uint8_t adswio2_status_pin_ready(adswio2_t *ctx)
Ready Pin Status Check function.
adswio2_cfg_setup
void adswio2_cfg_setup(adswio2_cfg_t *cfg)
Config Object Initialization function.
adswio2_generic_multi_read
adswio2_err_t adswio2_generic_multi_read(adswio2_t *ctx, adswio2_read_t *rd)
Generic Multi Read function.
adswio2_get_diag_results
adswio2_err_t adswio2_get_diag_results(adswio2_t *ctx, uint8_t diagnostic, uint16_t *data_out)
Diagnostic Results Get function.
adswio2_status_live
adswio2_err_t adswio2_status_live(adswio2_t *ctx, uint16_t *status, uint16_t status_mask)
Live Status function.
adswio2_exe_command
adswio2_err_t adswio2_exe_command(adswio2_t *ctx, uint16_t cmd_key)
Command Execute function.
adswio2_assign_diag
adswio2_err_t adswio2_assign_diag(adswio2_t *ctx, uint8_t diagnostic, uint8_t duty)
Diagnostic Assign function.
adswio2_mask_alert_set
void adswio2_mask_alert_set(adswio2_t *ctx, uint16_t alert_mask)
Alert Mask function.
adswio2_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adswio2.h:621
adswio2_status_pin_alert
uint8_t adswio2_status_pin_alert(adswio2_t *ctx)
Alert Pin Status Check function.
adswio2_init
ADSWIO2_RETVAL adswio2_init(adswio2_t *ctx, adswio2_cfg_t *cfg)
Initialization function.
adswio2_t::rdy
digital_in_t rdy
Definition: adswio2.h:572
adswio2_generic_read
adswio2_err_t adswio2_generic_read(adswio2_t *ctx, uint8_t reg_addr, uint16_t *data_out, uint8_t *rd_status)
Generic Read function.
adswio2_cfg_t::rdy
pin_name_t rdy
Definition: adswio2.h:615
adswio2_status_alert
adswio2_err_t adswio2_status_alert(adswio2_t *ctx, uint16_t *status, uint16_t status_mask)
Alert Status function.
adswio2_t::err_handler
adswio2_handler_t err_handler
Definition: adswio2.h:581
adswio2_set_conv_mode
adswio2_err_t adswio2_set_conv_mode(adswio2_t *ctx, uint8_t mode)
Conversion Mode Setup function.
adswio2_read_t::data_out
uint16_t * data_out
Definition: adswio2.h:593
adswio2_t::chip_select
pin_name_t chip_select
Definition: adswio2.h:577
adswio2_set_ch_func
adswio2_err_t adswio2_set_ch_func(adswio2_t *ctx, uint8_t channel, uint8_t ch_func)
Channel Function Setup function.
adswio2_default_cfg
void adswio2_default_cfg(adswio2_t *ctx)
Click Default Configuration function.
ADSWIO2_RETVAL
#define ADSWIO2_RETVAL
Definition: adswio2.h:96
adswio2_cfg_t::rst
pin_name_t rst
Definition: adswio2.h:613
adswio2_err_t
#define adswio2_err_t
Definition: adswio2.h:89
adswio2_cfg_t::spi_speed
uint32_t spi_speed
Definition: adswio2.h:619
adswio2_handler_t
void(* adswio2_handler_t)(uint8_t *)
Click error handler definition.
Definition: adswio2.h:556
adswio2_t::cs
digital_out_t cs
Definition: adswio2.h:566
adswio2_cfg_t
Click configuration structure definition.
Definition: adswio2.h:603
adswio2_reset
void adswio2_reset(adswio2_t *ctx)
Click Reset function.
adswio2_read_t::reg_addr
uint8_t reg_addr
Definition: adswio2.h:592
adswio2_t::spi
spi_master_t spi
Definition: adswio2.h:576
adswio2_generic_write
adswio2_err_t adswio2_generic_write(adswio2_t *ctx, uint8_t reg_addr, uint16_t data_in)
Generic Write function.
adswio2_read_t::rd_mode
uint8_t rd_mode
Definition: adswio2.h:594
adswio2_cfg_t::sck
pin_name_t sck
Definition: adswio2.h:608
adswio2_status_data_ready
adswio2_err_t adswio2_status_data_ready(adswio2_t *ctx, uint8_t *drdy, uint16_t *conv_target)
Data Ready Status function.
adswio2_generic_transfer
void adswio2_generic_transfer(adswio2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
adswio2_clear_handler
void adswio2_clear_handler(adswio2_t *ctx)
Error Handler Clear function.
adswio2_cfg_t::alt
pin_name_t alt
Definition: adswio2.h:614
adswio2_cfg_t::cs
pin_name_t cs
Definition: adswio2.h:609
adswio2_set_handler
void adswio2_set_handler(adswio2_t *ctx, adswio2_handler_t handler)
Error Handler Setup function.
adswio2_cfg_t::miso
pin_name_t miso
Definition: adswio2.h:606
adswio2_read_t
Click ctx object definition.
Definition: adswio2.h:589
adswio2_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adswio2.h:620