no-OS
ad7768.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef AD7768_H_
40 #define AD7768_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_gpio.h"
47 #include "no_os_spi.h"
48 
49 /******************************************************************************/
50 /********************** Macros and Constants Definitions **********************/
51 /******************************************************************************/
52 #define AD7768_REG_CH_STANDBY 0x00
53 #define AD7768_REG_CH_MODE_A 0x01
54 #define AD7768_REG_CH_MODE_B 0x02
55 #define AD7768_REG_CH_MODE_SEL 0x03
56 #define AD7768_REG_PWR_MODE 0x04
57 #define AD7768_REG_GENERAL_CFG 0x05
58 #define AD7768_REG_DATA_CTRL 0x06
59 #define AD7768_REG_INTERFACE_CFG 0x07
60 #define AD7768_REG_BIST_CTRL 0x08
61 #define AD7768_REG_DEV_STATUS 0x09
62 #define AD7768_REG_REV_ID 0x0A
63 #define AD7768_REG_DEV_ID_MSB 0x0B
64 #define AD7768_REG_DEV_ID_LSB 0x0C
65 #define AD7768_REG_SW_REV_ID 0x0D
66 #define AD7768_REG_GPIO_CTRL 0x0E
67 #define AD7768_REG_GPIO_WR_DATA 0x0F
68 #define AD7768_REG_GPIO_RD_DATA 0x10
69 #define AD7768_REG_PRECHARGE_BUF_1 0x11
70 #define AD7768_REG_PRECHARGE_BUF_2 0x12
71 #define AD7768_REG_POS_REF_BUF 0x13
72 #define AD7768_REG_NEG_REF_BUF 0x14
73 #define AD7768_REG_CH_OFFSET_1(ch) (0x1E + (ch) * 3)
74 #define AD7768_REG_CH_OFFSET_2(ch) (0x1F + (ch) * 3)
75 #define AD7768_REG_CH_OFFSET_3(ch) (0x20 + (ch) * 3)
76 #define AD7768_REG_CH_GAIN_1(ch) (0x36 + (ch) * 3)
77 #define AD7768_REG_CH_GAIN_2(ch) (0x37 + (ch) * 3)
78 #define AD7768_REG_CH_GAIN_3(ch) (0x38 + (ch) * 3)
79 #define AD7768_REG_CH_SYNC_OFFSET(ch) (0x4E + (ch) * 3)
80 #define AD7768_REG_DIAG_METER_RX 0x56
81 #define AD7768_REG_DIAG_CTRL 0x57
82 #define AD7768_REG_DIAG_MOD_DELAY_CTRL 0x58
83 #define AD7768_REG_DIAG_CHOP_CTRL 0x59
84 
85 /* AD7768_REG_CH_STANDBY */
86 #define AD7768_CH_STANDBY(x) (1 << (x))
87 
88 /* AD7768_REG_CH_MODE_x */
89 #define AD7768_CH_MODE_FILTER_TYPE (1 << 3)
90 #define AD7768_CH_MODE_DEC_RATE_MSK NO_OS_GENMASK(2, 0)
91 #define AD7768_CH_MODE_DEC_RATE(x) (((x) & 0x7) << 0)
92 
93 /* AD7768_REG_CH_MODE_SEL */
94 #define AD7768_CH_MODE(x) (1 << (x))
95 
96 /* AD7768_REG_PWR_MODE */
97 #define AD7768_PWR_MODE_POWER_MODE_MSK NO_OS_GENMASK(5, 4)
98 #define AD7768_PWR_MODE_SLEEP_MODE (1 << 7)
99 #define AD7768_PWR_MODE_POWER_MODE(x) (((x) & 0x3) << 4)
100 #define AD7768_PWR_MODE_LVDS_ENABLE (1 << 3)
101 #define AD7768_PWR_MODE_MCLK_DIV_MSK NO_OS_GENMASK(1, 0)
102 #define AD7768_PWR_MODE_MCLK_DIV(x) (((x) & 0x3) << 0)
103 #define ad7768_map_power_mode_to_regval(x) ((x) ? ((x) + 1) : 0)
104 
105 /* AD7768_REG_DATA_CTRL */
106 #define AD7768_DATA_CTRL_SPI_SYNC (1 << 7)
107 #define AD7768_DATA_CTRL_SINGLE_SHOT_EN (1 << 4)
108 #define AD7768_DATA_CTRL_SPI_RESET(x) (((x) & 0x3) << 0)
109 #define AD7768_DATA_CONTROL_SPI_SYNC_MSK NO_OS_BIT(7)
110 #define AD7768_DATA_CONTROL_SPI_SYNC NO_OS_BIT(7)
111 #define AD7768_DATA_CONTROL_SPI_SYNC_CLEAR 0
112 
113 /* AD7768_REG_INTERFACE_CFG */
114 #define AD7768_INTERFACE_CFG_CRC_SEL(x) (((x) & 0x3) << 2)
115 #define AD7768_INTERFACE_CFG_DCLK_DIV(x) (((x) & 0x3) << 0)
116 #define AD7768_INTERFACE_CFG_DCLK_DIV_MSK NO_OS_GENMASK(1, 0)
117 #define AD7768_INTERFACE_CFG_DCLK_DIV_MODE(x) (4 - no_os_find_first_set_bit(x))
118 #define AD7768_MAX_DCLK_DIV 8
119 
120 #define AD7768_RESOLUTION 24
121 #define AD7768_SAMPLE_SIZE 32
122 #define AD7768_MAX_FREQ_PER_MODE 6
123 #define AD7768_NUM_CHANNELS 8
124 
125 /******************************************************************************/
126 /*************************** Types Declarations *******************************/
127 /******************************************************************************/
128 typedef enum {
132 
133 typedef enum {
138 
144 };
145 
146 typedef enum {
151 
152 typedef enum {
158 
159 typedef enum {
163 
164 typedef enum {
168 
169 typedef enum {
175 
176 typedef enum {
186 } ad7768_ch;
187 
188 typedef enum {
192 
193 typedef enum {
197 
198 typedef enum {
202 
203 typedef enum {
213 
214 static const int ad7768_dec_rate_vals[6] = {
215  32, 64, 128, 256, 512, 1024
216 };
217 
218 static const int ad7768_mclk_div_vals[3] = {
219  32, 8, 4
220 };
221 
223  unsigned int freq;
224  unsigned int dec_rate;
225 };
226 
228  unsigned int n_freqs;
230 };
231 
232 typedef struct {
244  enum ad7768_power_modes_raw power_mode_raw;
249  ad7768_ch_state ch_state[8];
250  ad7768_ch_mode ch_mode[8];
251  ad7768_filt_type filt_type[2];
253  unsigned int mclk;
254  unsigned int datalines;
255  unsigned int sampling_freq;
257 } ad7768_dev;
258 
259 typedef struct {
260  /* SPI */
262  /* GPIO */
263  struct no_os_gpio_init_param gpio_reset;
265  struct no_os_gpio_init_param gpio_mode0;
266  struct no_os_gpio_init_param gpio_mode1;
267  struct no_os_gpio_init_param gpio_mode2;
268  struct no_os_gpio_init_param gpio_mode3;
269  /* Configuration */
277  unsigned int mclk;
278  unsigned int datalines;
280 
281 /******************************************************************************/
282 /************************ Functions Declarations ******************************/
283 /******************************************************************************/
284 /* SPI read from device. */
285 int32_t ad7768_spi_read(ad7768_dev *dev,
286  uint8_t reg_addr,
287  uint8_t *reg_data);
288 /* SPI write to device. */
289 int32_t ad7768_spi_write(ad7768_dev *dev,
290  uint8_t reg_addr,
291  uint8_t reg_data);
292 /* SPI read from device using a mask. */
293 int32_t ad7768_spi_read_mask(ad7768_dev *dev,
294  uint8_t reg_addr,
295  uint8_t mask,
296  uint8_t *data);
297 /* SPI write to device using a mask. */
298 int32_t ad7768_spi_write_mask(ad7768_dev *dev,
299  uint8_t reg_addr,
300  uint8_t mask,
301  uint8_t data);
302 /* Set the device sleep mode. */
303 int32_t ad7768_set_sleep_mode(ad7768_dev *dev,
304  ad7768_sleep_mode mode);
305 /* Get the device sleep mode. */
306 int32_t ad7768_get_sleep_mode(ad7768_dev *dev,
307  ad7768_sleep_mode *mode);
308 /* Set the device power mode. */
309 int32_t ad7768_set_power_mode(ad7768_dev *dev,
310  ad7768_power_mode mode);
311 /* Get the device power mode. */
312 int32_t ad7768_get_power_mode(ad7768_dev *dev,
313  ad7768_power_mode *mode);
314 /* Set the MCLK divider. */
315 int32_t ad7768_set_mclk_div(ad7768_dev *dev,
316  ad7768_mclk_div clk_div);
317 /* Get the MCLK divider. */
318 int32_t ad7768_get_mclk_div(ad7768_dev *dev,
319  ad7768_mclk_div *clk_div);
320 /* Set the DCLK divider. */
321 int32_t ad7768_set_dclk_div(ad7768_dev *dev,
322  ad7768_dclk_div clk_div);
323 /* Get the DCLK divider. */
324 int32_t ad7768_get_dclk_div(ad7768_dev *dev,
325  ad7768_dclk_div *clk_div);
326 /* Set the conversion operation mode. */
327 int32_t ad7768_set_conv_op(ad7768_dev *dev,
328  ad7768_conv_op conv_op);
329 /* Get the conversion operation mode. */
330 int32_t ad7768_get_conv_op(ad7768_dev *dev,
331  ad7768_conv_op *conv_op);
332 /* Set the CRC selection. */
333 int32_t ad7768_set_crc_sel(ad7768_dev *dev,
334  ad7768_crc_sel crc_sel);
335 /* Get the CRC selection. */
336 int32_t ad7768_get_crc_sel(ad7768_dev *dev,
337  ad7768_crc_sel *crc_sel);
338 /* Set the channel state. */
339 int32_t ad7768_set_ch_state(ad7768_dev *dev,
340  ad7768_ch ch,
341  ad7768_ch_state state);
342 /* Get the channel state. */
343 int32_t ad7768_get_ch_state(ad7768_dev *dev,
344  ad7768_ch ch,
345  ad7768_ch_state *state);
346 /* Set the mode configuration. */
348  ad7768_ch_mode mode,
349  ad7768_filt_type filt_type,
350  ad7768_dec_rate dec_rate);
351 /* Get the mode configuration. */
353  ad7768_ch_mode mode,
354  ad7768_filt_type *filt_type,
355  ad7768_dec_rate *dec_rate);
356 /* Set the channel mode. */
357 int32_t ad7768_set_ch_mode(ad7768_dev *dev,
358  ad7768_ch ch,
359  ad7768_ch_mode mode);
360 /* Get the channel mode. */
361 int32_t ad7768_get_ch_mode(ad7768_dev *dev,
362  ad7768_ch ch,
363  ad7768_ch_mode *mode);
364 /* Initialize the device. */
365 int32_t ad7768_setup(ad7768_dev **device,
367 /* Free the resources allocated by ad7768_setup(). */
368 int ad7768_remove(ad7768_dev *dev);
369 /* Begin initializing the device. */
372 /* Finish initializing the device. */
373 int32_t ad7768_setup_finish(ad7768_dev *dev,
375 /* Set available sampling frequency. */
377 /* Set power mode and sampling frequency. */
379  enum ad7768_power_modes_raw mode);
380 #endif // AD7768_H_
ad7768_setup
int32_t ad7768_setup(ad7768_dev **device, ad7768_init_param init_param)
Definition: ad7768.c:625
ad7768_set_available_sampl_freq
void ad7768_set_available_sampl_freq(ad7768_dev *dev)
Definition: ad7768.c:852
ad7768_get_ch_state
int32_t ad7768_get_ch_state(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state *state)
Definition: ad7768.c:498
ad7768_dev
Definition: ad7768.h:232
ad7768_set_power_mode
int32_t ad7768_set_power_mode(ad7768_dev *dev, ad7768_power_mode mode)
Definition: ad7768.c:229
ad7768_init_param::sleep_mode
ad7768_sleep_mode sleep_mode
Definition: ad7768.h:271
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
ad7768_map_power_mode_to_regval
#define ad7768_map_power_mode_to_regval(x)
Definition: ad7768.h:103
AD7768_MAX_DCLK_DIV
#define AD7768_MAX_DCLK_DIV
Definition: ad7768.h:118
AD7768_DEC_X1024_2ND
@ AD7768_DEC_X1024_2ND
Definition: ad7768.h:210
ad7768_power_mode
ad7768_power_mode
Definition: ad7768.h:133
ad7768_get_crc_sel
int32_t ad7768_get_crc_sel(ad7768_dev *dev, ad7768_crc_sel *crc_sel)
Definition: ad7768.c:445
AD7768_PWR_MODE_MCLK_DIV_MSK
#define AD7768_PWR_MODE_MCLK_DIV_MSK
Definition: ad7768.h:101
ad7768_dev::sleep_mode
ad7768_sleep_mode sleep_mode
Definition: ad7768.h:242
ad7768_mclk_div
ad7768_mclk_div
Definition: ad7768.h:146
ad7768_set_sleep_mode
int32_t ad7768_set_sleep_mode(ad7768_dev *dev, ad7768_sleep_mode mode)
Definition: ad7768.c:165
AD7768_CH3
@ AD7768_CH3
Definition: ad7768.h:180
AD7768_CH_MODE_DEC_RATE
#define AD7768_CH_MODE_DEC_RATE(x)
Definition: ad7768.h:91
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:165
ad7768_dev::mclk_div
ad7768_mclk_div mclk_div
Definition: ad7768.h:245
AD7768_NUM_POWER_MODES
@ AD7768_NUM_POWER_MODES
Definition: ad7768.h:143
ad7768_spi_write_mask
int32_t ad7768_spi_write_mask(ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: ad7768.c:141
no_os_spi.h
Header file of SPI Interface.
ad7768_dev::pin_spi_ctrl
ad7768_pin_spi_ctrl pin_spi_ctrl
Definition: ad7768.h:241
AD7768_DEC_X256
@ AD7768_DEC_X256
Definition: ad7768.h:207
AD7768_DEC_X512
@ AD7768_DEC_X512
Definition: ad7768.h:208
ad7768_dev::gpio_reset_value
uint8_t gpio_reset_value
Definition: ad7768.h:235
AD7768_FAST_MODE
@ AD7768_FAST_MODE
Definition: ad7768.h:142
ad7768_spi_write
int32_t ad7768_spi_write(ad7768_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: ad7768.c:97
ad7768_set_sleep_mode
int32_t ad7768_set_sleep_mode(ad7768_dev *dev, ad7768_sleep_mode mode)
Definition: ad7768.c:165
AD7768_DCLK_DIV_2
@ AD7768_DCLK_DIV_2
Definition: ad7768.h:155
AD7768_CH_MODE_DEC_RATE_MSK
#define AD7768_CH_MODE_DEC_RATE_MSK
Definition: ad7768.h:90
ad7768_avail_freq::n_freqs
unsigned int n_freqs
Definition: ad7768.h:228
AD7768_DCLK_DIV_1
@ AD7768_DCLK_DIV_1
Definition: ad7768.h:156
ad7768_dev::mclk
unsigned int mclk
Definition: ad7768.h:253
AD7768_LOW_POWER_MODE
@ AD7768_LOW_POWER_MODE
Definition: ad7768.h:140
ad7768_setup_finish
int32_t ad7768_setup_finish(ad7768_dev *dev, ad7768_init_param init_param)
Definition: ad7768.c:707
AD7768_FILTER_SINC
@ AD7768_FILTER_SINC
Definition: ad7768.h:200
ad7768_init_param::crc_sel
ad7768_crc_sel crc_sel
Definition: ad7768.h:276
ad7768_get_ch_mode
int32_t ad7768_get_ch_mode(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode *mode)
Definition: ad7768.c:609
ad7768_spi_write
int32_t ad7768_spi_write(ad7768_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: ad7768.c:97
ad7768_get_mclk_div
int32_t ad7768_get_mclk_div(ad7768_dev *dev, ad7768_mclk_div *clk_div)
Definition: ad7768.c:301
AD7768_FILTER_WIDEBAND
@ AD7768_FILTER_WIDEBAND
Definition: ad7768.h:199
AD7768_SAMPLE_SIZE
#define AD7768_SAMPLE_SIZE
Definition: ad7768.h:121
spi_init
struct no_os_spi_init_param spi_init
Definition: common_data.c:64
AD7768_STANDARD_CONV
@ AD7768_STANDARD_CONV
Definition: ad7768.h:165
NO_OS_DIV_ROUND_CLOSEST_ULL
#define NO_OS_DIV_ROUND_CLOSEST_ULL(x, y)
Definition: no_os_util.h:60
AD7768_DEC_X1024
@ AD7768_DEC_X1024
Definition: ad7768.h:209
AD7768_REG_CH_STANDBY
#define AD7768_REG_CH_STANDBY
Definition: ad7768.h:52
no_os_spi_init_param::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:139
ad7768_crc_sel
ad7768_crc_sel
Definition: ad7768.h:169
device
Definition: ad9361_util.h:75
ad7768_dev::dec_rate
ad7768_dec_rate dec_rate[2]
Definition: ad7768.h:252
ad7768_get_sleep_mode
int32_t ad7768_get_sleep_mode(ad7768_dev *dev, ad7768_sleep_mode *mode)
Definition: ad7768.c:183
AD7768_REG_INTERFACE_CFG
#define AD7768_REG_INTERFACE_CFG
Definition: ad7768.h:59
ad7768_get_conv_op
int32_t ad7768_get_conv_op(ad7768_dev *dev, ad7768_conv_op *conv_op)
Definition: ad7768.c:410
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:60
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:53
ad7768_ch_state
ad7768_ch_state
Definition: ad7768.h:188
ad7768_remove
int ad7768_remove(ad7768_dev *dev)
Definition: ad7768.c:922
AD7768_INTERFACE_CFG_DCLK_DIV_MODE
#define AD7768_INTERFACE_CFG_DCLK_DIV_MODE(x)
Definition: ad7768.h:117
ad7768_get_sleep_mode
int32_t ad7768_get_sleep_mode(ad7768_dev *dev, ad7768_sleep_mode *mode)
Definition: ad7768.c:183
ad7768_dev::gpio_mode0
struct no_os_gpio_desc * gpio_mode0
Definition: ad7768.h:236
ad7768_setup_finish
int32_t ad7768_setup_finish(ad7768_dev *dev, ad7768_init_param init_param)
Definition: ad7768.c:707
ad7768_dev::power_mode
ad7768_power_mode power_mode
Definition: ad7768.h:243
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:121
ad7768_init_param::power_mode
ad7768_power_mode power_mode
Definition: ad7768.h:272
ad7768_set_conv_op
int32_t ad7768_set_conv_op(ad7768_dev *dev, ad7768_conv_op conv_op)
Definition: ad7768.c:373
AD7768_DEC_X64
@ AD7768_DEC_X64
Definition: ad7768.h:205
AD7768_ACTIVE
@ AD7768_ACTIVE
Definition: ad7768.h:129
ad7768_set_mode_pins
int32_t ad7768_set_mode_pins(ad7768_dev *dev, uint8_t state)
Definition: ad7768.c:197
AD7768_CH_NO
@ AD7768_CH_NO
Definition: ad7768.h:185
ad7768_set_crc_sel
int32_t ad7768_set_crc_sel(ad7768_dev *dev, ad7768_crc_sel crc_sel)
Definition: ad7768.c:427
AD7768_DATA_CTRL_SINGLE_SHOT_EN
#define AD7768_DATA_CTRL_SINGLE_SHOT_EN
Definition: ad7768.h:107
AD7768_DCLK_DIV_8
@ AD7768_DCLK_DIV_8
Definition: ad7768.h:153
no_os_error.h
Error codes definition.
AD7768_MCLK_DIV_8
@ AD7768_MCLK_DIV_8
Definition: ad7768.h:148
ad7768_set_mode_config
int32_t ad7768_set_mode_config(ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type filt_type, ad7768_dec_rate dec_rate)
Definition: ad7768.c:525
ad7768_set_crc_sel
int32_t ad7768_set_crc_sel(ad7768_dev *dev, ad7768_crc_sel crc_sel)
Definition: ad7768.c:427
ad7768_get_dclk_div
int32_t ad7768_get_dclk_div(ad7768_dev *dev, ad7768_dclk_div *clk_div)
Definition: ad7768.c:356
AD7768_CH_MODE
#define AD7768_CH_MODE(x)
Definition: ad7768.h:94
ad7768_ch
ad7768_ch
Definition: ad7768.h:176
ad7768_freq_config::freq
unsigned int freq
Definition: ad7768.h:223
ad7768_dev::dclk_div
ad7768_dclk_div dclk_div
Definition: ad7768.h:246
ad7768_setup_begin
int32_t ad7768_setup_begin(ad7768_dev **device, ad7768_init_param init_param)
Definition: ad7768.c:657
AD7768_INTERFACE_CFG_DCLK_DIV_MSK
#define AD7768_INTERFACE_CFG_DCLK_DIV_MSK
Definition: ad7768.h:116
AD7768_MCLK_DIV_4
@ AD7768_MCLK_DIV_4
Definition: ad7768.h:149
ad7768_get_power_mode
int32_t ad7768_get_power_mode(ad7768_dev *dev, ad7768_power_mode *mode)
Definition: ad7768.c:266
ad7768_init_param::conv_op
ad7768_conv_op conv_op
Definition: ad7768.h:275
ad7768_set_dclk_div
int32_t ad7768_set_dclk_div(ad7768_dev *dev, ad7768_dclk_div clk_div)
Definition: ad7768.c:319
AD7768_ENABLED
@ AD7768_ENABLED
Definition: ad7768.h:189
ad7768_set_power_mode_and_sampling_freq
int ad7768_set_power_mode_and_sampling_freq(ad7768_dev *dev, enum ad7768_power_modes_raw mode)
Definition: ad7768.c:883
ad7768_dec_rate
ad7768_dec_rate
Definition: ad7768.h:203
ad7768_spi_read_mask
int32_t ad7768_spi_read_mask(ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
Definition: ad7768.c:119
AD7768_CRC_4
@ AD7768_CRC_4
Definition: ad7768.h:171
AD7768_REG_DATA_CTRL
#define AD7768_REG_DATA_CTRL
Definition: ad7768.h:58
ad7768_pin_spi_ctrl
ad7768_pin_spi_ctrl
Definition: ad7768.h:159
ad7768_dev::filt_type
ad7768_filt_type filt_type[2]
Definition: ad7768.h:251
AD7768_DEC_X1024_3RD
@ AD7768_DEC_X1024_3RD
Definition: ad7768.h:211
ad7768_dev::power_mode_raw
enum ad7768_power_modes_raw power_mode_raw
Definition: ad7768.h:244
AD7768_ECO
@ AD7768_ECO
Definition: ad7768.h:134
AD7768_PWR_MODE_POWER_MODE_MSK
#define AD7768_PWR_MODE_POWER_MODE_MSK
Definition: ad7768.h:97
ad7768_dev::gpio_mode2
struct no_os_gpio_desc * gpio_mode2
Definition: ad7768.h:238
ad7768_set_conv_op
int32_t ad7768_set_conv_op(ad7768_dev *dev, ad7768_conv_op conv_op)
Definition: ad7768.c:373
ad7768_dev::gpio_reset
struct no_os_gpio_desc * gpio_reset
Definition: ad7768.h:234
ad7768_ch_mode
ad7768_ch_mode
Definition: ad7768.h:193
ad7768_setup
int32_t ad7768_setup(ad7768_dev **device, ad7768_init_param init_param)
Definition: ad7768.c:625
AD7768_PWR_MODE_POWER_MODE
#define AD7768_PWR_MODE_POWER_MODE(x)
Definition: ad7768.h:99
ad7768_set_available_sampl_freq
void ad7768_set_available_sampl_freq(ad7768_dev *dev)
Definition: ad7768.c:852
ad7768_init_param::mclk_div
ad7768_mclk_div mclk_div
Definition: ad7768.h:273
ad7768.h
Header file of AD7768 Driver.
ad7768_dev::gpio_mode1
struct no_os_gpio_desc * gpio_mode1
Definition: ad7768.h:237
ad7768_filt_type
ad7768_filt_type
Definition: ad7768.h:198
AD7768_MEDIAN
@ AD7768_MEDIAN
Definition: ad7768.h:135
AD7768_CH4
@ AD7768_CH4
Definition: ad7768.h:181
AD7768_DEC_X128
@ AD7768_DEC_X128
Definition: ad7768.h:206
ad7768_dev::sampling_freq
unsigned int sampling_freq
Definition: ad7768.h:255
ad7768_init_param::mclk
unsigned int mclk
Definition: ad7768.h:277
AD7768_STANDBY
@ AD7768_STANDBY
Definition: ad7768.h:190
AD7768_INTERFACE_CFG_DCLK_DIV
#define AD7768_INTERFACE_CFG_DCLK_DIV(x)
Definition: ad7768.h:115
AD7768_PWR_MODE_MCLK_DIV
#define AD7768_PWR_MODE_MCLK_DIV(x)
Definition: ad7768.h:102
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
AD7768_CH1
@ AD7768_CH1
Definition: ad7768.h:178
AD7768_DATA_CONTROL_SPI_SYNC_MSK
#define AD7768_DATA_CONTROL_SPI_SYNC_MSK
Definition: ad7768.h:109
AD7768_NUM_CHANNELS
#define AD7768_NUM_CHANNELS
Definition: ad7768.h:123
AD7768_MODE_A
@ AD7768_MODE_A
Definition: ad7768.h:194
ad7768_spi_read_mask
int32_t ad7768_spi_read_mask(ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
Definition: ad7768.c:119
ad7768_get_conv_op
int32_t ad7768_get_conv_op(ad7768_dev *dev, ad7768_conv_op *conv_op)
Definition: ad7768.c:410
ad7768_dev::crc_sel
ad7768_crc_sel crc_sel
Definition: ad7768.h:248
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
AD7768_CH7
@ AD7768_CH7
Definition: ad7768.h:184
AD7768_CH6
@ AD7768_CH6
Definition: ad7768.h:183
AD7768_CRC_16_2ND
@ AD7768_CRC_16_2ND
Definition: ad7768.h:173
AD7768_REG_CH_MODE_B
#define AD7768_REG_CH_MODE_B
Definition: ad7768.h:54
ad7768_conv_op
ad7768_conv_op
Definition: ad7768.h:164
ad7768_spi_write_mask
int32_t ad7768_spi_write_mask(ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: ad7768.c:141
AD7768_FAST
@ AD7768_FAST
Definition: ad7768.h:136
standard_pin_ctrl_mode_sel
const uint8_t standard_pin_ctrl_mode_sel[3][4]
Definition: ad7768.c:50
ad7768_dev::conv_op
ad7768_conv_op conv_op
Definition: ad7768.h:247
AD7768_MAX_FREQ_PER_MODE
#define AD7768_MAX_FREQ_PER_MODE
Definition: ad7768.h:122
ad7768_set_ch_mode
int32_t ad7768_set_ch_mode(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode mode)
Definition: ad7768.c:581
ad7768_dev::pin_spi_input_value
uint8_t pin_spi_input_value
Definition: ad7768.h:240
AD7768_CH2
@ AD7768_CH2
Definition: ad7768.h:179
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:55
AD7768_MCLK_DIV_32
@ AD7768_MCLK_DIV_32
Definition: ad7768.h:147
ad7768_dev::ch_state
ad7768_ch_state ch_state[8]
Definition: ad7768.h:249
ad7768_dev::ch_mode
ad7768_ch_mode ch_mode[8]
Definition: ad7768.h:250
ad7768_get_mode_config
int32_t ad7768_get_mode_config(ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type *filt_type, ad7768_dec_rate *dec_rate)
Definition: ad7768.c:553
no_os_find_last_set_bit
uint32_t no_os_find_last_set_bit(uint32_t word)
AD7768_ONE_SHOT_CONV
@ AD7768_ONE_SHOT_CONV
Definition: ad7768.h:166
ad7768_power_modes_raw
ad7768_power_modes_raw
Definition: ad7768.h:139
ad7768_get_mclk_div
int32_t ad7768_get_mclk_div(ad7768_dev *dev, ad7768_mclk_div *clk_div)
Definition: ad7768.c:301
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
ad7768_avail_freq::freq_cfg
struct ad7768_freq_config freq_cfg[AD7768_MAX_FREQ_PER_MODE]
Definition: ad7768.h:229
ad7768_set_power_mode
int32_t ad7768_set_power_mode(ad7768_dev *dev, ad7768_power_mode mode)
Definition: ad7768.c:229
ad7768_freq_config::dec_rate
unsigned int dec_rate
Definition: ad7768.h:224
AD7768_DATA_CONTROL_SPI_SYNC
#define AD7768_DATA_CONTROL_SPI_SYNC
Definition: ad7768.h:110
ad7768_set_mode_config
int32_t ad7768_set_mode_config(ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type filt_type, ad7768_dec_rate dec_rate)
Definition: ad7768.c:525
AD7768_SPI_CTRL
@ AD7768_SPI_CTRL
Definition: ad7768.h:161
AD7768_DEC_X32
@ AD7768_DEC_X32
Definition: ad7768.h:204
AD7768_REG_PWR_MODE
#define AD7768_REG_PWR_MODE
Definition: ad7768.h:56
ad7768_get_power_mode
int32_t ad7768_get_power_mode(ad7768_dev *dev, ad7768_power_mode *mode)
Definition: ad7768.c:266
ad7768_dev::gpio_mode3
struct no_os_gpio_desc * gpio_mode3
Definition: ad7768.h:239
ad7768_dev::avail_freq
struct ad7768_avail_freq avail_freq[AD7768_NUM_POWER_MODES]
Definition: ad7768.h:256
ad7768_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7768.h:233
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:203
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
ad7768_set_ch_mode
int32_t ad7768_set_ch_mode(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode mode)
Definition: ad7768.c:581
AD7768_PIN_CTRL
@ AD7768_PIN_CTRL
Definition: ad7768.h:160
AD7768_INTERFACE_CFG_CRC_SEL
#define AD7768_INTERFACE_CFG_CRC_SEL(x)
Definition: ad7768.h:114
ad7768_dclk_div
ad7768_dclk_div
Definition: ad7768.h:152
ad7768_get_mode_config
int32_t ad7768_get_mode_config(ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type *filt_type, ad7768_dec_rate *dec_rate)
Definition: ad7768.c:553
ad7768_remove
int ad7768_remove(ad7768_dev *dev)
Definition: ad7768.c:922
ad7768_set_mclk_div
int32_t ad7768_set_mclk_div(ad7768_dev *dev, ad7768_mclk_div clk_div)
Definition: ad7768.c:283
AD7768_MODE_B
@ AD7768_MODE_B
Definition: ad7768.h:195
AD7768_CH0
@ AD7768_CH0
Definition: ad7768.h:177
ad7768_init_param::pin_spi_input_value
uint8_t pin_spi_input_value
Definition: ad7768.h:270
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:122
AD7768_NO_CRC
@ AD7768_NO_CRC
Definition: ad7768.h:170
ad7768_spi_read
int32_t ad7768_spi_read(ad7768_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: ad7768.c:71
no_os_gpio.h
Header file of GPIO Interface.
ad7768_set_ch_state
int32_t ad7768_set_ch_state(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state state)
Definition: ad7768.c:470
AD7768_REG_CH_MODE_A
#define AD7768_REG_CH_MODE_A
Definition: ad7768.h:53
ad7768_init_param::datalines
unsigned int datalines
Definition: ad7768.h:278
ad7768_set_mclk_div
int32_t ad7768_set_mclk_div(ad7768_dev *dev, ad7768_mclk_div clk_div)
Definition: ad7768.c:283
ad7768_dev::datalines
unsigned int datalines
Definition: ad7768.h:254
ad7768_get_ch_mode
int32_t ad7768_get_ch_mode(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode *mode)
Definition: ad7768.c:609
AD7768_CH_STANDBY
#define AD7768_CH_STANDBY(x)
Definition: ad7768.h:86
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
AD7768_DCLK_DIV_4
@ AD7768_DCLK_DIV_4
Definition: ad7768.h:154
ad7768_spi_read
int32_t ad7768_spi_read(ad7768_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: ad7768.c:71
AD7768_MEDIAN_MODE
@ AD7768_MEDIAN_MODE
Definition: ad7768.h:141
ad7768_freq_config
Definition: ad7768.h:222
no_os_util.h
Header file of utility functions.
no_os_hweight32
unsigned int no_os_hweight32(uint32_t word)
AD7768_SLEEP
@ AD7768_SLEEP
Definition: ad7768.h:130
AD7768_PWR_MODE_SLEEP_MODE
#define AD7768_PWR_MODE_SLEEP_MODE
Definition: ad7768.h:98
AD7768_REG_CH_MODE_SEL
#define AD7768_REG_CH_MODE_SEL
Definition: ad7768.h:55
ad7768_get_dclk_div
int32_t ad7768_get_dclk_div(ad7768_dev *dev, ad7768_dclk_div *clk_div)
Definition: ad7768.c:356
ad7768_setup_begin
int32_t ad7768_setup_begin(ad7768_dev **device, ad7768_init_param init_param)
Definition: ad7768.c:657
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:153
ad7768_init_param
Definition: ad7768.h:259
one_shot_pin_ctrl_mode_sel
const uint8_t one_shot_pin_ctrl_mode_sel[3][4]
Definition: ad7768.c:57
ad7768_init_param::dclk_div
ad7768_dclk_div dclk_div
Definition: ad7768.h:274
ad7768_get_crc_sel
int32_t ad7768_get_crc_sel(ad7768_dev *dev, ad7768_crc_sel *crc_sel)
Definition: ad7768.c:445
ad7768_set_power_mode_and_sampling_freq
int ad7768_set_power_mode_and_sampling_freq(ad7768_dev *dev, enum ad7768_power_modes_raw mode)
Definition: ad7768.c:883
ad7768_set_dclk_div
int32_t ad7768_set_dclk_div(ad7768_dev *dev, ad7768_dclk_div clk_div)
Definition: ad7768.c:319
ad7768_sleep_mode
ad7768_sleep_mode
Definition: ad7768.h:128
AD7768_CRC_16
@ AD7768_CRC_16
Definition: ad7768.h:172
ad7768_avail_freq
Definition: ad7768.h:227
ad7768_init_param::gpio_reset_value
uint8_t gpio_reset_value
Definition: ad7768.h:264
ad7768_get_ch_state
int32_t ad7768_get_ch_state(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state *state)
Definition: ad7768.c:498
ad7768_set_ch_state
int32_t ad7768_set_ch_state(ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state state)
Definition: ad7768.c:470
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
AD7768_CH5
@ AD7768_CH5
Definition: ad7768.h:182
AD7768_CH_MODE_FILTER_TYPE
#define AD7768_CH_MODE_FILTER_TYPE
Definition: ad7768.h:89
AD7768_DATA_CONTROL_SPI_SYNC_CLEAR
#define AD7768_DATA_CONTROL_SPI_SYNC_CLEAR
Definition: ad7768.h:111