adswio  2.0.0.0
adswio.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 ADSWIO_H
36 #define ADSWIO_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 #include "spi_specifics.h"
42 
43 
44 // -------------------------------------------------------------- PUBLIC MACROS
55 #define ADSWIO_MAP_MIKROBUS( cfg, mikrobus ) \
56  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
57  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
58  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
59  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
60  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
61  cfg.alt = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
62  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
63 
69 #define adswio_obj_t const uint8_t*
70 
76 #define adswio_err_t uint8_t
77 
83 #define ADSWIO_RETVAL uint8_t
84 
85 #define ADSWIO_OK 0x00
86 #define ADSWIO_INIT_ERROR 0xFF
87 
93 #define ADSWIO_FRAME_LENGTH 4
94 #define ADSWIO_MASK_RD_FRAME_RESERVED_BIT 0x80
95 #define ADSWIO_MASK_RD_FRAME_REG_ADDR 0x7F
96 #define ADSWIO_MASK_RD_FRAME_STATUS 0x7F
97 
103 #define ADSWIO_RD_RET_INFO 0x1
104 
110 #define ADSWIO_OFFSET_REG_CONV_RES 0x25
111 #define ADSWIO_OFFSET_REG_DIAG_RES 0x29
112 
118 #define DUMMY 0
119 #define ADSWIO_NULL 0
120 
126 #define ADSWIO_RD_AUTO_EN 0x2
127 #define ADSWIO_RD_AUTO_DIS 0x0
128 
139 #define ADSWIO_MASK_CONV_EN 0xF
140 #define ADSWIO_OFFSET_CONV_EN_CH 0
141 #define ADSWIO_OFFSET_CONV_EN_DIAG 4
142 
148 #define ADSWIO_MASK_DIAG_ASSIGN 0xF
149 #define ADSWIO_OFFSET_ASSIGN_DIAG0 0
150 #define ADSWIO_OFFSET_ASSIGN_DIAG1 4
151 #define ADSWIO_OFFSET_ASSIGN_DIAG2 8
152 #define ADSWIO_OFFSET_ASSIGN_DIAG3 12
153 
159 #define ADSWIO_MASK_CONV_MODE 0x300
160 #define ADSWIO_OFFSET_CONV_MODE 8
161 
167 #define ADSWIO_MASK_DAC_CODE 0x1FFF
168 
174 #define ADSWIO_MASK_ALERT 0x7FFF
175 
181 #define ADSWIO_MASK_DIN_THRESH_COMP 0x3E
182 
188 #define ADSWIO_MASK_STATUS_ALRT_CAL_MEM_ERR 0x4000
189 #define ADSWIO_MASK_STATUS_ALRT_SPI_CRC_ERR 0x2000
190 #define ADSWIO_MASK_STATUS_ALRT_RST 0x8000
191 #define ADSWIO_MASK_STATUS_ALRT_SPI_SCLK_CNT_ERR 0x1000
192 #define ADSWIO_MASK_STATUS_ALRT_ADC_SAT_ERR 0x800
193 #define ADSWIO_MASK_STATUS_ALRT_ADC_CONV_ERR 0x400
194 #define ADSWIO_MASK_STATUS_ALRT_ALDO1V8_ERR 0x200
195 #define ADSWIO_MASK_STATUS_ALRT_DVCC_ERR 0x100
196 #define ADSWIO_MASK_STATUS_ALRT_AVDD_ERR 0x80
197 #define ADSWIO_MASK_STATUS_ALRT_ALDO5V_ERR 0x40
198 #define ADSWIO_MASK_STATUS_ALRT_CHARGE_PUMP_ERR 0x20
199 #define ADSWIO_MASK_STATUS_ALRT_HI_TEMP_ERR 0x10
200 #define ADSWIO_MASK_STATUS_ALRT_VI_ERR_D 0x8
201 #define ADSWIO_MASK_STATUS_ALRT_VI_ERR_C 0x4
202 #define ADSWIO_MASK_STATUS_ALRT_VI_ERR_B 0x2
203 #define ADSWIO_MASK_STATUS_ALRT_VI_ERR_A 0x1
204 
210 #define ADSWIO_MASK_STATUS_LIVE_ADC_DRDY 0x4000
211 #define ADSWIO_MASK_STATUS_LIVE_ADC_BUSY 0x2000
212 #define ADSWIO_MASK_STATUS_LIVE_ADC_CURR_CH 0x1C00
213 #define ADSWIO_MASK_STATUS_LIVE_ALDO1V8 0x200
214 #define ADSWIO_MASK_STATUS_LIVE_DVCC 0x100
215 #define ADSWIO_MASK_STATUS_LIVE_AVDD 0x80
216 #define ADSWIO_MASK_STATUS_LIVE_ALDO5V 0x40
217 #define ADSWIO_MASK_STATUS_LIVE_CHARGE_PUMP 0x20
218 #define ADSWIO_MASK_STATUS_LIVE_HI_TEMP 0x10
219 #define ADSWIO_MASK_STATUS_LIVE_VI_ERR_CURR_D 0x8
220 #define ADSWIO_MASK_STATUS_LIVE_VI_ERR_CURR_C 0x4
221 #define ADSWIO_MASK_STATUS_LIVE_VI_ERR_CURR_B 0x2
222 #define ADSWIO_MASK_STATUS_LIVE_VI_ERR_CURR_A 0x1
223 
229 #define ADSWIO_MAX_NWORDS 4
230 #define ADSWIO_MIN_NWORDS 1
231  // End offset_mask group
234 
239 #define ADSWIO_REG_NOP 0x0
240 #define ADSWIO_REG_FUNC_SETUP_CHA 0x1
241 #define ADSWIO_REG_FUNC_SETUP_CHB 0x2
242 #define ADSWIO_REG_FUNC_SETUP_CHC 0x3
243 #define ADSWIO_REG_FUNC_SETUP_CHD 0x4
244 #define ADSWIO_REG_CFG_ADC_CHA 0x5
245 #define ADSWIO_REG_CFG_ADC_CHB 0x6
246 #define ADSWIO_REG_CFG_ADC_CHC 0x7
247 #define ADSWIO_REG_CFG_ADC_CHD 0x8
248 #define ADSWIO_REG_CFG_DIN_CHA 0x9
249 #define ADSWIO_REG_CFG_DIN_CHB 0xA
250 #define ADSWIO_REG_CFG_DIN_CHC 0xB
251 #define ADSWIO_REG_CFG_DIN_CHD 0xC
252 #define ADSWIO_REG_GPO_PARALLEL 0xD
253 #define ADSWIO_REG_CFG_GPO_CHA 0xE
254 #define ADSWIO_REG_CFG_GPO_CHB 0xF
255 #define ADSWIO_REG_CFG_GPO_CHC 0x10
256 #define ADSWIO_REG_CFG_GPO_CHD 0x11
257 #define ADSWIO_REG_CFG_OUTPUT_CHA 0x12
258 #define ADSWIO_REG_CFG_OUTPUT_CHB 0x13
259 #define ADSWIO_REG_CFG_OUTPUT_CHC 0x14
260 #define ADSWIO_REG_CFG_OUTPUT_CHD 0x15
261 #define ADSWIO_REG_DAC_CODE_CHA 0x16
262 #define ADSWIO_REG_DAC_CODE_CHB 0x17
263 #define ADSWIO_REG_DAC_CODE_CHC 0x18
264 #define ADSWIO_REG_DAC_CODE_CHD 0x19
265 #define ADSWIO_REG_DAC_CODE_CLR_CHA 0x1A
266 #define ADSWIO_REG_DAC_CODE_CLR_CHB 0x1B
267 #define ADSWIO_REG_DAC_CODE_CLR_CHC 0x1C
268 #define ADSWIO_REG_DAC_CODE_CLR_CHD 0x1D
269 #define ADSWIO_REG_DAC_CODE_ACT_CHA 0x1E
270 #define ADSWIO_REG_DAC_CODE_ACT_CHB 0x1F
271 #define ADSWIO_REG_DAC_CODE_ACT_CHC 0x20
272 #define ADSWIO_REG_DAC_CODE_ACT_CHD 0x21
273 #define ADSWIO_REG_DIN_THRESH 0x22
274 #define ADSWIO_REG_ADC_CONV_CTRL 0x23
275 #define ADSWIO_REG_DIAG_ASSIGN 0x24
276 #define ADSWIO_REG_DIN_COMP_OUT 0x25
277 #define ADSWIO_REG_RESULT_ADC_CHA 0x26
278 #define ADSWIO_REG_RESULT_ADC_CHB 0x27
279 #define ADSWIO_REG_RESULT_ADC_CHC 0x28
280 #define ADSWIO_REG_RESULT_ADC_CHD 0x29
281 #define ADSWIO_REG_RESULT_DIAG1 0x2A
282 #define ADSWIO_REG_RESULT_DIAG2 0x2B
283 #define ADSWIO_REG_RESULT_DIAG3 0x2C
284 #define ADSWIO_REG_RESULT_DIAG4 0x2D
285 #define ADSWIO_REG_STATUS_ALERT 0x2E
286 #define ADSWIO_REG_STATUS_LIVE 0x2F
287 #define ADSWIO_REG_MASK_ALERT 0x3C
288 #define ADSWIO_REG_DIN_COUNTER_CHA 0x3D
289 #define ADSWIO_REG_DIN_COUNTER_CHB 0x3E
290 #define ADSWIO_REG_DIN_COUNTER_CHC 0x3F
291 #define ADSWIO_REG_DIN_COUNTER_CHD 0x40
292 #define ADSWIO_REG_READ_SELECT 0x41
293 #define ADSWIO_REG_THERM_RST 0x43
294 #define ADSWIO_REG_CMD_KEY 0x44
295 #define ADSWIO_REG_SCRATCH 0x45
296 #define ADSWIO_REG_SILICON_REV 0x46
297 
308 #define ADSWIO_SETUP_CONV_EN_CHD 0x8
309 #define ADSWIO_SETUP_CONV_EN_CHC 0x4
310 #define ADSWIO_SETUP_CONV_EN_CHB 0x2
311 #define ADSWIO_SETUP_CONV_EN_CHA 0x1
312 
318 #define ADSWIO_SETUP_CH_FUNC_HZ 0x0
319 #define ADSWIO_SETUP_CH_FUNC_VOLT_OUTPUT 0x1
320 #define ADSWIO_SETUP_CH_FUNC_CURR_OUTPUT 0x2
321 #define ADSWIO_SETUP_CH_FUNC_VOLT_INPUT 0x3
322 #define ADSWIO_SETUP_CH_FUNC_CURR_INPUT_PWR_EXT 0x4
323 #define ADSWIO_SETUP_CH_FUNC_CURR_INPUT_PWR_LOOP 0x5
324 #define ADSWIO_SETUP_CH_FUNC_RES_MEAS 0x6
325 #define ADSWIO_SETUP_CH_FUNC_DIG_INPUT_LOGIC 0x7
326 #define ADSWIO_SETUP_CH_FUNC_DIG_INPUT_PWR_LOOP 0x8
327 #define ADSWIO_SETUP_CH_FUNC_CURR_INPUT_PWR_EXT_HART 0x9
328 #define ADSWIO_SETUP_CH_FUNC_CURR_INPUT_PWR_LOOP_HART 0xA
329 
335 #define ADSWIO_SETUP_CONV_EN_DIAG3 0x8
336 #define ADSWIO_SETUP_CONV_EN_DIAG2 0x4
337 #define ADSWIO_SETUP_CONV_EN_DIAG1 0x2
338 #define ADSWIO_SETUP_CONV_EN_DIAG0 0x1
339 
345 #define ADSWIO_SETUP_DIAG_ASSIGN_AGND 0x0
346 #define ADSWIO_SETUP_DIAG_ASSIGN_TEMP 0x1
347 #define ADSWIO_SETUP_DIAG_ASSIGN_AVDD 0x2
348 #define ADSWIO_SETUP_DIAG_ASSIGN_VAVSS 0x3
349 #define ADSWIO_SETUP_DIAG_ASSIGN_REFOUT 0x4
350 #define ADSWIO_SETUP_DIAG_ASSIGN_ALDO5V 0x5
351 #define ADSWIO_SETUP_DIAG_ASSIGN_ALDO1V8 0x6
352 #define ADSWIO_SETUP_DIAG_ASSIGN_DLDO1V8 0x7
353 #define ADSWIO_SETUP_DIAG_ASSIGN_DVCC 0x8
354 #define ADSWIO_SETUP_DIAG_ASSIGN_IOVDD 0x9
355 #define ADSWIO_SETUP_DIAG_ASSIGN_SENSELA 0xA
356 #define ADSWIO_SETUP_DIAG_ASSIGN_SENSELB 0xB
357 #define ADSWIO_SETUP_DIAG_ASSIGN_SENSELC 0xC
358 #define ADSWIO_SETUP_DIAG_ASSIGN_SENSELD 0xD
359 #define ADSWIO_SETUP_DIAG_ASSIGN_LVIN 0xE
360 
366 #define ADSWIO_SETUP_CONV_STOP_CONT_CONV_ADC_PWR_UP 0x0
367 #define ADSWIO_SETUP_CONV_START_SING_SEQ_CONV 0x1
368 #define ADSWIO_SETUP_CONV_START_CONT_CONV 0x2
369 #define ADSWIO_SETUP_CONV_STOP_CONT_CONV_ADC_PWR_DWN 0x3
370 
376 #define ADSWIO_SETUP_ADC_RANGE_0V_TO_10V 0x0
377 #define ADSWIO_SETUP_ADC_RANGE_2500MV_PWR_EXT 0x20
378 #define ADSWIO_SETUP_ADC_RANGE_2500MV_PWR_LOOP 0x40
379 #define ADSWIO_SETUP_ADC_RANGE_2500MV_NEG_TO_2500MV_POS 0x60
380 #define ADSWIO_SETUP_ADC_RANGE_104MV_NEG_TO_104MV_POS 0x80
381 #define ADSWIO_SETUP_ADC_SAMPLE_RATE_20SPS 0x0
382 #define ADSWIO_SETUP_ADC_SAMPLE_RATE_4800SPS 0x8
383 #define ADSWIO_SETUP_ADC_SAMPLE_RATE_10SPS 0x10
384 #define ADSWIO_SETUP_ADC_SAMPLE_RATE_1200SPS 0x18
385 #define ADSWIO_SETUP_ADC_CH_200K_TO_GND 0x4
386 #define ADSWIO_SETUP_ADC_INPUT_VOLTAGE_AGND_SENSE 0x0
387 #define ADSWIO_SETUP_ADC_INPUT_VOLTAGE_100_OHM_RES 0x1
388 
394 #define ADSWIO_SETUP_DIN_COUNT_EN 0x8000
395 #define ADSWIO_SETUP_DIN_COMP_IN_FILTERED 0x4000
396 #define ADSWIO_SETUP_DIN_COMP_OUT_INV 0x2000
397 #define ADSWIO_SETUP_DIN_COMP_EN 0x1000
398 #define ADSWIO_SETUP_DIN_RANGE_0 0x0
399 #define ADSWIO_SETUP_DIN_RANGE_1 0x800
400 #define ADSWIO_SETUP_DIN_DEBOUNCE_MODE_0 0x0
401 #define ADSWIO_SETUP_DIN_DEBOUNCE_MODE_1 0x20
402 
408 #define ADSWIO_SETUP_GPO_PARALL_DATA_D 0x8
409 #define ADSWIO_SETUP_GPO_PARALL_DATA_C 0x4
410 #define ADSWIO_SETUP_GPO_PARALL_DATA_B 0x2
411 #define ADSWIO_SETUP_GPO_PARALL_DATA_A 0x1
412 
418 #define ADSWIO_SETUP_GPO_LOGIC_LOW 0x0
419 #define ADSWIO_SETUP_GPO_LOGIC_HIGH 0x8
420 
426 #define ADSWIO_SETUP_OUT_SLEW_EN_LINEAR 0x40
427 #define ADSWIO_SETUP_OUT_SLEW_EN_HART 0x80
428 #define ADSWIO_SETUP_OUT_SLEW_LIN_STEP_64_DEC_CODES 0x0
429 #define ADSWIO_SETUP_OUT_SLEW_LIN_STEP_120_DEC_CODES 0x10
430 #define ADSWIO_SETUP_OUT_SLEW_LIN_STEP_500_DEC_CODES 0x20
431 #define ADSWIO_SETUP_OUT_SLEW_LIN_STEP_1820_DEC_CODES 0x30
432 #define ADSWIO_SETUP_OUT_SLEW_LIN_RATE_4KHZ 0x0
433 #define ADSWIO_SETUP_OUT_SLEW_LIN_RATE_64KHZ 0x4
434 #define ADSWIO_SETUP_OUT_SLEW_LIN_RATE_150KHZ 0x8
435 #define ADSWIO_SETUP_OUT_SLEW_LIN_RATE_240KHZ 0xC
436 #define ADSWIO_SETUP_OUT_CLR_EN 0x2
437 #define ADSWIO_SETUP_OUT_CURR_LIM_30MA 0x0
438 #define ADSWIO_SETUP_OUT_CURR_LIM_7_5MA 0x1
439 
445 #define ADSWIO_SETUP_DIN_THRESH_GND_AND_AVDD 0x0
446 #define ADSWIO_SETUP_DIN_THRESH_GND_AND_16V 0x1
447 
453 #define ADSWIO_SETUP_CONV_EN_50_60_HZ_REJ_DIAG 0x400
454 
455 #define ADSWIO_SETUP_CONV_EN_ALL_CH 0xF
456 #define ADSWIO_SETUP_CONV_EN_ALL_DIAG 0xF
457 #define ADSWIO_SETUP_CONV_DIS_ALL_CH 0x0
458 #define ADSWIO_SETUP_CONV_DIS_ALL_DIAG 0x0
459 
465 #define ADSWIO_SETUP_THERM_RST_EN 0x1
466 
472 #define ADSWIO_STATUS_LIVE_ADC_CURR_CHA 0x0
473 #define ADSWIO_STATUS_LIVE_ADC_CURR_CHB 0x400
474 #define ADSWIO_STATUS_LIVE_ADC_CURR_CHC 0x800
475 #define ADSWIO_STATUS_LIVE_ADC_CURR_CHD 0xC00
476 #define ADSWIO_STATUS_LIVE_ADC_CURR_DIAG0 0x1000
477 #define ADSWIO_STATUS_LIVE_ADC_CURR_DIAG1 0x1400
478 #define ADSWIO_STATUS_LIVE_ADC_CURR_DIAG2 0x1800
479 #define ADSWIO_STATUS_LIVE_ADC_CURR_DIAG3 0x1C00
480 
486 #define ADSWIO_CMD_NOP 0x0
487 #define ADSWIO_CMD_SW_RST_KEY1 0x15FA
488 #define ADSWIO_CMD_SW_RST_KEY2 0xAF51
489 #define ADSWIO_CMD_LDAC_KEY 0x953A
490 #define ADSWIO_CMD_DAC_CLR_KEY 0x73D1
491  // End reg_setup group
494 
499 #define ADSWIO_ERR_STATUS_OK 0
500 #define ADSWIO_ERR_INIT_DRV 1
501 #define ADSWIO_ERR_UNSUPPORTED_PIN 2
502 #define ADSWIO_ERR_RD_STATUS 3
503 #define ADSWIO_ERR_RD_MODE 4
504 #define ADSWIO_ERR_RD_NWORDS 5
505 #define ADSWIO_ERR_CMD_KEY 6
506 #define ADSWIO_ERR_EN_CH 7
507 #define ADSWIO_ERR_EN_DIAG 8
508 #define ADSWIO_ERR_CRC 9
509 #define ADSWIO_ERR_REG_ADDR 10
510 #define ADSWIO_ERR_CONV_MODE 11
511 #define ADSWIO_ERR_CH_FUNC 12
512 #define ADSWIO_ERR_DIAG_ASSIGN 13
513 
519 #define ADSWIO_ID_SILICON_REV 0x8
520 
530 #define ADSWIO_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
531 #define ADSWIO_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
532  // End group macro
534 // --------------------------------------------------------------- PUBLIC TYPES
543 typedef void ( * adswio_handler_t )( uint8_t * );
544 
545 
549 typedef struct
550 {
551  // Output pins
552 
553  digital_out_t cs;
554  digital_out_t rst;
555 
556  // Input pins
557 
558  digital_in_t alt;
559  digital_in_t rdy;
560 
561  // Modules
562 
563  spi_master_t spi;
564  pin_name_t chip_select;
565 
566  // static variable
567 
569 
570 } adswio_t;
571 
575 typedef struct
576 {
577  // static variable
578 
579  uint8_t reg_addr;
580  uint16_t *data_out;
581  uint8_t rd_mode;
582  uint8_t n_words;
583 
584 } adswio_read_t;
585 
589 typedef struct
590 {
591  // Communication gpio pins
592 
593  pin_name_t miso;
594  pin_name_t mosi;
595  pin_name_t sck;
596  pin_name_t cs;
597 
598  // Additional gpio pins
599 
600  pin_name_t rst;
601  pin_name_t alt;
602  pin_name_t rdy;
603 
604  // static variable
605 
606  uint32_t spi_speed;
607  spi_master_mode_t spi_mode;
608  spi_master_chip_select_polarity_t cs_polarity;
609 
610 } adswio_cfg_t;
611  // End types group
613 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
614 
619 #ifdef __cplusplus
620 extern "C"{
621 #endif
622 
632 
642 
651 
663 void adswio_generic_transfer ( adswio_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
664 
670 void adswio_reset( adswio_t *ctx );
671 
682 
693 
703 
712 
724 adswio_err_t adswio_generic_write ( adswio_t *ctx, uint8_t reg_addr, uint16_t data_in );
725 
745 adswio_err_t adswio_generic_read ( adswio_t *ctx, uint8_t reg_addr, uint16_t *data_out, uint8_t *rd_status );
746 
772 
783 adswio_err_t adswio_exe_command ( adswio_t *ctx, uint16_t cmd_key );
784 
793 void adswio_mask_alert_set ( adswio_t *ctx, uint16_t alert_mask );
794 
807 adswio_err_t adswio_status_live ( adswio_t *ctx, uint16_t *status, uint16_t status_mask );
808 
823 adswio_err_t adswio_status_data_ready ( adswio_t *ctx, uint8_t *drdy, uint16_t *conv_target );
824 
839 adswio_err_t adswio_status_alert ( adswio_t *ctx, uint16_t *status, uint16_t status_mask );
840 
858 
875 adswio_err_t adswio_enable_ch ( adswio_t *ctx, uint8_t channel );
876 
893 adswio_err_t adswio_enable_diag ( adswio_t *ctx, uint8_t diagnostic );
894 
906 adswio_err_t adswio_set_ch_func ( adswio_t *ctx, uint8_t channel, uint8_t ch_func );
907 
926 adswio_err_t adswio_assign_diag ( adswio_t *ctx, uint8_t diagnostic, uint8_t duty );
927 
945 adswio_err_t adswio_get_conv_results ( adswio_t *ctx, uint8_t channel, uint16_t *data_out );
946 
964 adswio_err_t adswio_get_diag_results ( adswio_t *ctx, uint8_t diagnostic, uint16_t *data_out );
965 
966 #ifdef __cplusplus
967 }
968 #endif
969 #endif // _ADSWIO_H_
970  // End public_function group
973 
974 // ------------------------------------------------------------------------- END
adswio_default_cfg
void adswio_default_cfg(adswio_t *ctx)
Click Default Configuration function.
adswio_set_handler
void adswio_set_handler(adswio_t *ctx, adswio_handler_t handler)
Error Handler Setup function.
adswio_cfg_t::sck
pin_name_t sck
Definition: adswio.h:595
adswio_assign_diag
adswio_err_t adswio_assign_diag(adswio_t *ctx, uint8_t diagnostic, uint8_t duty)
Diagnostic Assign function.
adswio_generic_transfer
void adswio_generic_transfer(adswio_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
adswio_status_alert
adswio_err_t adswio_status_alert(adswio_t *ctx, uint16_t *status, uint16_t status_mask)
Alert Status function.
adswio_err_t
#define adswio_err_t
Definition: adswio.h:76
adswio_t::rdy
digital_in_t rdy
Definition: adswio.h:559
adswio_status_pin_alert
uint8_t adswio_status_pin_alert(adswio_t *ctx)
Alert Pin Status Check function.
adswio_cfg_t
Click configuration structure definition.
Definition: adswio.h:590
adswio_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: adswio.h:607
spi_specifics.h
This file contains SPI specific macros, functions, etc.
adswio_cfg_t::rdy
pin_name_t rdy
Definition: adswio.h:602
adswio_generic_read
adswio_err_t adswio_generic_read(adswio_t *ctx, uint8_t reg_addr, uint16_t *data_out, uint8_t *rd_status)
Generic Read function.
adswio_init
ADSWIO_RETVAL adswio_init(adswio_t *ctx, adswio_cfg_t *cfg)
Initialization function.
adswio_read_t::rd_mode
uint8_t rd_mode
Definition: adswio.h:581
adswio_t::chip_select
pin_name_t chip_select
Definition: adswio.h:564
adswio_read_t::data_out
uint16_t * data_out
Definition: adswio.h:580
adswio_clear_handler
void adswio_clear_handler(adswio_t *ctx)
Error Handler Clear function.
adswio_t::err_handler
adswio_handler_t err_handler
Definition: adswio.h:568
adswio_t
Click ctx object definition.
Definition: adswio.h:550
adswio_cfg_t::spi_speed
uint32_t spi_speed
Definition: adswio.h:606
adswio_reset
void adswio_reset(adswio_t *ctx)
Click Reset function.
adswio_generic_multi_read
adswio_err_t adswio_generic_multi_read(adswio_t *ctx, adswio_read_t *rd)
Generic Multi Read function.
adswio_t::alt
digital_in_t alt
Definition: adswio.h:558
adswio_read_t::reg_addr
uint8_t reg_addr
Definition: adswio.h:579
adswio_status_pin_ready
uint8_t adswio_status_pin_ready(adswio_t *ctx)
Ready Pin Status Check function.
adswio_enable_ch
adswio_err_t adswio_enable_ch(adswio_t *ctx, uint8_t channel)
Channel Enable function.
adswio_cfg_t::mosi
pin_name_t mosi
Definition: adswio.h:594
adswio_cfg_setup
void adswio_cfg_setup(adswio_cfg_t *cfg)
Config Object Initialization function.
adswio_mask_alert_set
void adswio_mask_alert_set(adswio_t *ctx, uint16_t alert_mask)
Alert Mask function.
adswio_cfg_t::rst
pin_name_t rst
Definition: adswio.h:600
adswio_cfg_t::alt
pin_name_t alt
Definition: adswio.h:601
adswio_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: adswio.h:608
adswio_handler_t
void(* adswio_handler_t)(uint8_t *)
Click error handler definition.
Definition: adswio.h:543
adswio_cfg_t::cs
pin_name_t cs
Definition: adswio.h:596
adswio_t::rst
digital_out_t rst
Definition: adswio.h:554
adswio_status_data_ready
adswio_err_t adswio_status_data_ready(adswio_t *ctx, uint8_t *drdy, uint16_t *conv_target)
Data Ready Status function.
adswio_get_conv_results
adswio_err_t adswio_get_conv_results(adswio_t *ctx, uint8_t channel, uint16_t *data_out)
Channel Results Get function.
adswio_set_conv_mode
adswio_err_t adswio_set_conv_mode(adswio_t *ctx, uint8_t mode)
Conversion Mode Setup function.
adswio_read_t::n_words
uint8_t n_words
Definition: adswio.h:582
adswio_read_t
Click ctx object definition.
Definition: adswio.h:576
adswio_t::cs
digital_out_t cs
Definition: adswio.h:553
ADSWIO_RETVAL
#define ADSWIO_RETVAL
Definition: adswio.h:83
adswio_enable_diag
adswio_err_t adswio_enable_diag(adswio_t *ctx, uint8_t diagnostic)
Diagnostic Enable function.
adswio_get_diag_results
adswio_err_t adswio_get_diag_results(adswio_t *ctx, uint8_t diagnostic, uint16_t *data_out)
Diagnostic Results Get function.
adswio_exe_command
adswio_err_t adswio_exe_command(adswio_t *ctx, uint16_t cmd_key)
Command Execute function.
adswio_status_live
adswio_err_t adswio_status_live(adswio_t *ctx, uint16_t *status, uint16_t status_mask)
Live Status function.
adswio_generic_write
adswio_err_t adswio_generic_write(adswio_t *ctx, uint8_t reg_addr, uint16_t data_in)
Generic Write function.
adswio_set_ch_func
adswio_err_t adswio_set_ch_func(adswio_t *ctx, uint8_t channel, uint8_t ch_func)
Channel Function Setup function.
adswio_t::spi
spi_master_t spi
Definition: adswio.h:563
adswio_cfg_t::miso
pin_name_t miso
Definition: adswio.h:593