Go to the documentation of this file.
39 #ifdef PREINIT_SUPPORTED
43 #ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_spi_master.h"
74 #define ADC24_CTRL_SET_WRITE 0x0800u
75 #define ADC24_CTRL_SET_SEQ 0x0400u
76 #define ADC24_CTRL_SET_CH_0 0x0000u
77 #define ADC24_CTRL_SET_CH_1 0x0040u
78 #define ADC24_CTRL_SET_CH_2 0x0080u
79 #define ADC24_CTRL_SET_CH_3 0x00C0u
80 #define ADC24_CTRL_SET_CH_4 0x0100u
81 #define ADC24_CTRL_SET_CH_5 0x0140u
82 #define ADC24_CTRL_SET_CH_6 0x0180u
83 #define ADC24_CTRL_SET_CH_7 0x01C0u
84 #define ADC24_CTRL_SET_CH_8 0x0200u
85 #define ADC24_CTRL_SET_CH_9 0x0240u
86 #define ADC24_CTRL_SET_CH_10 0x0280u
87 #define ADC24_CTRL_SET_CH_11 0x02C0u
88 #define ADC24_CTRL_SET_CH_12 0x0300u
89 #define ADC24_CTRL_SET_CH_13 0x0340u
90 #define ADC24_CTRL_SET_CH_14 0x0380u
91 #define ADC24_CTRL_SET_CH_15 0x03C0u
92 #define ADC24_CTRL_SET_PM_NORMAL 0x0030u
93 #define ADC24_CTRL_SET_PM_FULL_SHDN 0x0020u
94 #define ADC24_CTRL_SET_PM_AUTO_SHDN 0x0010u
95 #define ADC24_CTRL_SET_PM_STANDBY 0x0000u
96 #define ADC24_CTRL_SET_SHADOW 0x0008u
97 #define ADC24_CTRL_SET_WEAK 0x0004u
98 #define ADC24_CTRL_SET_RANGE_5V 0x0000u
99 #define ADC24_CTRL_SET_RANGE_2_5V 0x0002u
100 #define ADC24_CTRL_SET_CODING_2C 0x0000u
101 #define ADC24_CTRL_SET_CODING_BIN 0x0001u
107 #define ADC24_SEQ_SHADOW_AN_INPUT 0
108 #define ADC24_SEQ_SHADOW_PROGRAMMING 1
109 #define ADC24_SEQ_SHADOW_ALTERED 2
110 #define ADC24_SEQ_SHADOW_ADDR_CONJ 3
116 #define ADC24_CH_SEL_IN_0 0
117 #define ADC24_CH_SEL_IN_1 1
118 #define ADC24_CH_SEL_IN_2 2
119 #define ADC24_CH_SEL_IN_3 3
120 #define ADC24_CH_SEL_IN_4 4
121 #define ADC24_CH_SEL_IN_5 5
122 #define ADC24_CH_SEL_IN_6 6
123 #define ADC24_CH_SEL_IN_7 7
124 #define ADC24_CH_SEL_IN_8 8
125 #define ADC24_CH_SEL_IN_9 9
126 #define ADC24_CH_SEL_IN_10 10
127 #define ADC24_CH_SEL_IN_11 11
128 #define ADC24_CH_SEL_IN_12 12
129 #define ADC24_CH_SEL_IN_13 13
130 #define ADC24_CH_SEL_IN_14 14
131 #define ADC24_CH_SEL_IN_15 15
137 #define ADC24_PM_STANDBY 0
138 #define ADC24_PM_AUTO_SHDN 1
139 #define ADC24_PM_FULL_SHDN 2
140 #define ADC24_PM_NORMAL 3
146 #define ADC24_WEAK_DOUT_THREE_STATE 0
147 #define ADC24_WEAK_DOUT_WEAKLY_DRIVEN 1
153 #define ADC24_RANGE_VREF_5V 0
154 #define ADC24_RANGE_VREF_2V5 1
160 #define ADC24_CODING_2C 0
161 #define ADC24_CODING_BIN 1
167 #define ADC24_ADC_RESOLUTION 0x0FFF
168 #define ADC24_VREF_2V5 2.5f
169 #define ADC24_VREF_5V 5.0f
179 #define ADC24_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
180 #define ADC24_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
198 #define ADC24_MAP_MIKROBUS( cfg, mikrobus ) \
199 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
200 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
201 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
202 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
uint8_t ch_sel
Definition: adc24.h:245
err_t adc24_get_adc_data(adc24_t *ctx, adc24_ctrl_t ctrl, uint8_t *in_pos, uint16_t *adc_data)
ADC 24 get ADC data function.
err_t adc24_generic_read(adc24_t *ctx, uint16_t *data_out)
ADC 24 data reading function.
err_t adc24_init(adc24_t *ctx, adc24_cfg_t *cfg)
ADC 24 initialization function.
uint32_t spi_speed
Definition: adc24.h:233
@ ADC24_ERROR
Definition: adc24.h:261
spi_master_chip_select_polarity_t cs_polarity
Definition: adc24.h:235
This file contains SPI specific macros, functions, etc.
@ ADC24_OK
Definition: adc24.h:260
ADC 24 Click context object.
Definition: adc24.h:212
uint8_t seq_shadow
Definition: adc24.h:247
err_t adc24_generic_write(adc24_t *ctx, uint16_t control)
ADC 24 data writing function.
uint8_t range
Definition: adc24.h:249
ADC 24 Click configuration object.
Definition: adc24.h:225
pin_name_t chip_select
Definition: adc24.h:216
void adc24_cfg_setup(adc24_cfg_t *cfg)
ADC 24 configuration object setup function.
err_t adc24_get_voltage(adc24_t *ctx, adc24_ctrl_t ctrl, uint8_t *in_pos, float *voltage)
ADC 24 get voltage level function.
uint8_t pm
Definition: adc24.h:246
spi_master_mode_t spi_mode
Definition: adc24.h:234
pin_name_t sck
Definition: adc24.h:229
pin_name_t mosi
Definition: adc24.h:228
uint8_t weak
Definition: adc24.h:248
pin_name_t miso
Definition: adc24.h:227
adc24_return_value_t
ADC 24 Click return value data.
Definition: adc24.h:259
spi_master_t spi
Definition: adc24.h:214
pin_name_t cs
Definition: adc24.h:230
uint8_t coding
Definition: adc24.h:250
ADC 24 Click control object.
Definition: adc24.h:244