Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_spi_master.h"
60 #define ADC20_CMD_NOP 0x00
61 #define ADC20_CMD_REG_READ 0x10
62 #define ADC20_CMD_REG_WRITE 0x08
63 #define ADC20_CMD_SET_BIT 0x18
64 #define ADC20_CMD_CLEAR_BIT 0x20
70 #define ADC20_REG_SYSTEM_STATUS 0x00
71 #define ADC20_REG_GENERAL_CFG 0x01
72 #define ADC20_REG_DATA_CFG 0x02
73 #define ADC20_REG_OSR_CFG 0x03
74 #define ADC20_REG_OPMODE_CFG 0x04
75 #define ADC20_REG_PIN_CFG 0x05
76 #define ADC20_REG_GPIO_CFG 0x07
77 #define ADC20_REG_GPO_DRIVE_CFG 0x09
78 #define ADC20_REG_GPO_VALUE 0x0B
79 #define ADC20_REG_GPI_VALUE 0x0D
80 #define ADC20_REG_SEQUENCE_CFG 0x10
81 #define ADC20_REG_CHANNEL_SEL 0x11
82 #define ADC20_REG_AUTO_SEQ_CH_SEL 0x12
100 #define ADC20_DATA_CFG_FIX_PAT 0x80
101 #define ADC20_DATA_CFG_APPEND_CHANNEL_ID 0x10
102 #define ADC20_DATA_CFG_SPI_MODE_0 0x00
103 #define ADC20_DATA_CFG_SPI_MODE_1 0x01
104 #define ADC20_DATA_CFG_SPI_MODE_2 0x02
105 #define ADC20_DATA_CFG_SPI_MODE_3 0x03
106 #define ADC20_DATA_CFG_SPI_MODE_MASK 0x03
112 #define ADC20_FIXED_CODE 0xA5A0
118 #define ADC20_CHANNEL_0 0x01
119 #define ADC20_CHANNEL_1 0x02
120 #define ADC20_CHANNEL_2 0x04
121 #define ADC20_CHANNEL_3 0x08
122 #define ADC20_CHANNEL_4 0x10
123 #define ADC20_CHANNEL_5 0x20
124 #define ADC20_CHANNEL_6 0x40
125 #define ADC20_CHANNEL_7 0x80
126 #define ADC20_CHANNEL_NONE 0x00
127 #define ADC20_CHANNEL_MASK 0xFF
133 #define ADC20_CHANNEL_ID_0 0
134 #define ADC20_CHANNEL_ID_1 1
135 #define ADC20_CHANNEL_ID_2 2
136 #define ADC20_CHANNEL_ID_3 3
137 #define ADC20_CHANNEL_ID_4 4
138 #define ADC20_CHANNEL_ID_5 5
139 #define ADC20_CHANNEL_ID_6 6
140 #define ADC20_CHANNEL_ID_7 7
141 #define ADC20_CHANNEL_ID_MASK 0x0F
147 #define ADC20_PIN_CFG_ANALOG 0
148 #define ADC20_PIN_CFG_GPIO 1
154 #define ADC20_GPIO_CFG_DIG_INPUT 0
155 #define ADC20_GPIO_CFG_DIG_OUTPUT 1
161 #define ADC20_GPO_DRIVE_CFG_OPEN_DRAIN 0
162 #define ADC20_GPO_DRIVE_CFG_PUSH_PULL 1
168 #define ADC20_GPIO_VALUE_LOW 0
169 #define ADC20_GPIO_VALUE_HIGH 1
175 #define ADC20_OSR_NO_AVERAGING 0x00
176 #define ADC20_OSR_2_SAMPLES 0x01
177 #define ADC20_OSR_4_SAMPLES 0x02
178 #define ADC20_OSR_8_SAMPLES 0x03
179 #define ADC20_OSR_16_SAMPLES 0x04
180 #define ADC20_OSR_32_SAMPLES 0x05
181 #define ADC20_OSR_64_SAMPLES 0x06
182 #define ADC20_OSR_128_SAMPLES 0x07
183 #define ADC20_OSR_MASK 0x07
189 #define ADC20_SEQ_STOP 0x00
190 #define ADC20_SEQ_START 0x10
191 #define ADC20_SEQ_MODE_MANUAL 0x00
192 #define ADC20_SEQ_MODE_AUTO 0x01
193 #define ADC20_SEQ_MODE_OTF 0x02
194 #define ADC20_SEQ_MODE_MASK 0x03
200 #define ADC20_ADC_OFFSET 4
201 #define ADC20_RES_12BIT 0x0FFF
202 #define ADC20_VREF_3V3 3.3f
212 #define ADC20_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
213 #define ADC20_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
231 #define ADC20_MAP_MIKROBUS( cfg, mikrobus ) \
232 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
233 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
234 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
235 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
ADC 20 Click context object.
Definition: adc20.h:245
pin_name_t mosi
Definition: adc20.h:261
err_t adc20_set_pin_config(adc20_t *ctx, uint8_t ch_mask, uint8_t pin_cfg)
ADC 20 set pin config function.
err_t adc20_default_cfg(adc20_t *ctx)
ADC 20 default configuration function.
err_t adc20_write_register(adc20_t *ctx, uint8_t reg, uint8_t data_in)
ADC 20 write register function.
err_t adc20_read_data(adc20_t *ctx, uint16_t *data_out)
ADC 20 read data function.
spi_master_mode_t spi_mode
Definition: adc20.h:267
err_t adc20_set_gpio_config(adc20_t *ctx, uint8_t ch_mask, uint8_t gpio_cfg)
ADC 20 set gpio config function.
This file contains SPI specific macros, functions, etc.
err_t adc20_stop_auto_sequence(adc20_t *ctx)
ADC 20 stop auto sequence function.
spi_master_t spi
Definition: adc20.h:247
ADC 20 Click configuration object.
Definition: adc20.h:258
@ ADC20_ERROR
Definition: adc20.h:279
adc20_return_value_t
ADC 20 Click return value data.
Definition: adc20.h:277
uint32_t spi_speed
Definition: adc20.h:266
pin_name_t sck
Definition: adc20.h:262
spi_master_chip_select_polarity_t cs_polarity
Definition: adc20.h:268
err_t adc20_check_communication(adc20_t *ctx)
ADC 20 check communication function.
err_t adc20_read_register(adc20_t *ctx, uint8_t reg, uint8_t *data_out)
ADC 20 read register function.
pin_name_t cs
Definition: adc20.h:263
void adc20_cfg_setup(adc20_cfg_t *cfg)
ADC 20 configuration object setup function.
err_t adc20_read_gpio_value(adc20_t *ctx, uint8_t *gpio_value)
ADC 20 read gpio value function.
err_t adc20_set_gpo_drive_config(adc20_t *ctx, uint8_t ch_mask, uint8_t gpo_drive_cfg)
ADC 20 set gpo drive config function.
@ ADC20_OK
Definition: adc20.h:278
pin_name_t miso
Definition: adc20.h:260
pin_name_t chip_select
Definition: adc20.h:249
err_t adc20_start_auto_sequence(adc20_t *ctx)
ADC 20 start auto sequence function.
err_t adc20_set_gpo_value(adc20_t *ctx, uint8_t ch_mask, uint8_t value)
ADC 20 set gpo value function.
err_t adc20_init(adc20_t *ctx, adc20_cfg_t *cfg)
ADC 20 initialization function.