Go to the documentation of this file.
56 #define AD7606_REG_STATUS 0x01
57 #define AD7606_REG_CONFIG 0x02
58 #define AD7606_REG_RANGE_CH_ADDR(ch) (0x03 + ((ch) >> 1))
59 #define AD7606_REG_BANDWIDTH 0x07
60 #define AD7606_REG_OVERSAMPLING 0x08
61 #define AD7606_REG_GAIN_CH(ch) (0x09 + (ch))
62 #define AD7606_REG_OFFSET_CH(ch) (0x11 + (ch))
63 #define AD7606_REG_PHASE_CH(ch) (0x19 + (ch))
64 #define AD7606_REG_DIGITAL_DIAG_ENABLE 0x21
65 #define AD7606_REG_DIGITAL_DIAG_ERR 0x22
66 #define AD7606_REG_OPEN_DETECT_ENABLE 0x23
67 #define AD7606_REG_OPEN_DETECTED 0x24
68 #define AD7606_REG_AIN_OV_UV_DIAG_ENABLE 0x25
69 #define AD7606_REG_AIN_OV_DIAG_ERROR 0x26
70 #define AD7606_REG_AIN_UV_DIAG_ERROR 0x27
71 #define AD7606_REG_DIAGNOSTIC_MUX_CH(ch) (0x28 + ((ch) >> 1))
72 #define AD7606_REG_OPEN_DETECT_QUEUE 0x2C
73 #define AD7606_REG_CLK_FS_COUNTER 0x2D
74 #define AD7606_REG_CLK_OS_COUNTER 0x2E
75 #define AD7606_REG_ID 0x2F
78 #define AD7606_STATUS_CHANNEL_MSK NO_OS_GENMASK(2,0)
79 #define AD7606_AIN_UV_ERR_MSK NO_OS_BIT(3)
80 #define AD7606_AIN_OV_ERR_MSK NO_OS_BIT(4)
81 #define AD7606_OPEN_DETECTED_MSK NO_OS_BIT(5)
82 #define AD7606_DIGITAL_ERROR_MSK NO_OS_BIT(6)
83 #define AD7606_RESET_DETECT_MSK NO_OS_BIT(7)
86 #define AD7606_CONFIG_OPERATION_MODE_MSK NO_OS_GENMASK(1,0)
87 #define AD7606_CONFIG_DOUT_FORMAT_MSK NO_OS_GENMASK(4,3)
88 #define AD7606_CONFIG_EXT_OS_CLOCK_MSK NO_OS_BIT(5)
89 #define AD7606_CONFIG_STATUS_HEADER_MSK NO_OS_BIT(6)
92 #define AD7606_RANGE_CH_MSK(ch) (NO_OS_GENMASK(3, 0) << (4 * ((ch) % 2)))
93 #define AD7606_RANGE_CH_MODE(ch, mode) \
94 ((NO_OS_GENMASK(3, 0) & mode) << (4 * ((ch) % 2)))
97 #define AD7606_OS_PAD_MSK NO_OS_GENMASK(7,4)
98 #define AD7606_OS_RATIO_MSK NO_OS_GENMASK(3,0)
101 #define AD7606_ID_DEVICE_ID_MSK NO_OS_GENMASK(7,4)
102 #define AD7606_ID_SILICON_REVISION_MSK NO_OS_GENMASK(3,0)
105 #define AD7606_GAIN_MSK NO_OS_GENMASK(5,0)
108 #define AD7606_ROM_CRC_ERR_EN_MSK NO_OS_BIT(0)
109 #define AD7606_MM_CRC_ERR_EN_MSK NO_OS_BIT(1)
110 #define AD7606_INT_CRC_ERR_EN_MSK NO_OS_BIT(2)
111 #define AD7606_SPI_WRITE_ERR_EN_MSK NO_OS_BIT(3)
112 #define AD7606_SPI_READ_ERR_EN_MSK NO_OS_BIT(4)
113 #define AD7606_BUSY_STUCK_HIGH_ERR_EN_MSK NO_OS_BIT(5)
114 #define AD7606_CLK_FS_OS_COUNTER_EN_MSK NO_OS_BIT(6)
115 #define AD7606_INTERFACE_CHECK_EN_MSK NO_OS_BIT(7)
118 #define AD7606_DIAGN_MUX_CH_MSK(ch) (NO_OS_GENMASK(2, 0) << (3 * (ch & 0x1)))
120 #define AD7606_RD_FLAG_MSK(x) (NO_OS_BIT(6) | ((x) & 0x3F))
121 #define AD7606_WR_FLAG_MSK(x) ((x) & 0x3F)
123 #define AD7606_MAX_CHANNELS 8
bool spi_read_err_en
Definition: ad7606.h:258
@ AD7606_4_DOUT
Definition: ad7606.h:200
struct no_os_gpio_init_param * gpio_os0
Definition: ad7606.h:338
struct no_os_gpio_init_param * gpio_par_ser
Definition: ad7606.h:344
#define AD7606_REG_PHASE_CH(ch)
Definition: ad7606.h:63
int32_t ad7606_set_ch_range(struct ad7606_dev *dev, uint8_t ch, struct ad7606_range range)
Set the channel operation range.
Definition: ad7606.c:839
@ ID_AD7606C_18
Definition: ad7606.h:143
uint32_t timeout
Definition: ad413x.c:55
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
@ AD7606_8_DOUT
Definition: ad7606.h:202
int8_t offset_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:356
int32_t ad7606_reset(struct ad7606_dev *dev)
Reset the device by toggling the reset GPIO.
Definition: ad7606.c:622
NO_OS_DECLARE_CRC8_TABLE(ad7606_crc8)
#define AD7606_REG_GAIN_CH(ch)
Definition: ad7606.h:61
AD7606_REG_CONFIG configuration parameters.
Definition: ad7606.h:209
bool int_crc_err_en
Definition: ad7606.h:254
@ AD7606_2_DOUT
Definition: ad7606.h:198
NO_OS_DECLARE_CRC16_TABLE(ad7606_crc16)
struct no_os_spi_init_param spi_init
Definition: ad7606.h:326
#define AD7606_MM_CRC_ERR_EN_MSK
Definition: ad7606.h:109
int32_t ad7606_convst(struct ad7606_dev *dev)
Toggle the CONVST pin to start a conversion.
Definition: ad7606.c:417
enum ad7606_device_id device_id
Definition: ad7606.h:346
struct no_os_gpio_desc * gpio_par_ser
Definition: ad7606.h:291
enum ad7606_op_mode op_mode
Definition: ad7606.h:211
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
@ ID_AD7606C_16
Definition: ad7606.h:141
@ AD7606_STANDBY
Definition: ad7606.h:183
Header file for the ad7606 Driver.
struct no_os_gpio_init_param * gpio_reset
Definition: ad7606.h:328
int32_t min
Definition: ad7606.h:226
int32_t ad7606_spi_write_mask(struct ad7606_dev *dev, uint32_t addr, uint32_t mask, uint32_t val)
Write a device register via SPI with masking.
Definition: ad7606.c:340
int32_t ad7606_init(struct ad7606_dev **device, struct ad7606_init_param *init_param)
Initialize the ad7606 device structure.
Definition: ad7606.c:1110
Header file of SPI Interface.
int32_t ad7606_set_ch_gain(struct ad7606_dev *dev, uint8_t ch, uint8_t gain)
Set the channel gain.
Definition: ad7606.c:960
#define AD7606_REG_OVERSAMPLING
Definition: ad7606.h:60
#define AD7606_SPI_WRITE_ERR_EN_MSK
Definition: ad7606.h:111
@ ID_AD7606_4
Definition: ad7606.h:133
int32_t ad7606_spi_reg_read(struct ad7606_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read a device register via SPI.
Definition: ad7606.c:230
int32_t no_os_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition: no_os_gpio.c:227
uint8_t num_channels
Definition: ad7606.h:307
enum ad7606_osr os_ratio
Definition: ad7606.h:241
const struct ad7606_range * hw_range_table
Definition: ad7606.c:62
Header file of Delay functions.
struct no_os_gpio_desc * gpio_os1
Definition: ad7606.h:287
int32_t ad7606_set_digital_diag(struct ad7606_dev *dev, struct ad7606_digital_diag diag)
Set the device digital diagnostics configuration.
Definition: ad7606.c:1065
enum ad7606_device_id device_id
Definition: ad7606.h:293
enum ad7606_dout_format dout_format
Definition: ad7606.h:213
struct no_os_gpio_init_param * gpio_stby_n
Definition: ad7606.h:334
@ AD7606_OSR_8
Definition: ad7606.h:162
#define AD7606_RD_FLAG_MSK(x)
Definition: ad7606.h:120
struct no_os_gpio_init_param * gpio_range
Definition: ad7606.h:336
int32_t ad7606_set_ch_offset(struct ad7606_dev *dev, uint8_t ch, int8_t offset)
Set the channel offset.
Definition: ad7606.c:891
bool sw_mode
Definition: ad7606.h:297
Definition: ad9361_util.h:75
uint8_t num_channels
Definition: ad7606.c:56
ad7606_osr
Oversampling ratio.
Definition: ad7606.h:154
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:123
@ ID_AD7609
Definition: ad7606.h:147
bool reg_mode
Definition: ad7606.h:299
int32_t ad7606_set_ch_offset(struct ad7606_dev *dev, uint8_t ch, int8_t offset)
Set the channel offset.
Definition: ad7606.c:891
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
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:53
#define AD7606_BUSY_STUCK_HIGH_ERR_EN_MSK
Definition: ad7606.h:113
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:130
bool has_oversampling
Definition: ad7606.c:59
struct no_os_gpio_desc * gpio_reset
Definition: ad7606.h:275
struct no_os_gpio_desc * gpio_busy
Definition: ad7606.h:279
Oversampling settings.
Definition: ad7606.h:248
uint8_t phase_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:311
@ AD7606_AUTOSTANDBY
Definition: ad7606.h:185
#define AD7606_INTERFACE_CHECK_EN_MSK
Definition: ad7606.h:115
#define AD7606_REG_DIGITAL_DIAG_ENABLE
Definition: ad7606.h:64
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:121
uint8_t gain_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:313
int32_t ad7606_set_ch_phase(struct ad7606_dev *dev, uint8_t ch, uint8_t phase)
Set the channel phase.
Definition: ad7606.c:926
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
#define AD7606_CONFIG_OPERATION_MODE_MSK
Definition: ad7606.h:86
bool busy_stuck_high_err_en
Definition: ad7606.h:260
#define AD7606_CONFIG_DOUT_FORMAT_MSK
Definition: ad7606.h:87
uint32_t hw_range_table_sz
Definition: ad7606.c:63
#define AD7606_OS_PAD_MSK
Definition: ad7606.h:97
int32_t max
Definition: ad7606.h:228
bool rom_crc_err_en
Definition: ad7606.h:250
struct no_os_gpio_desc * gpio_range
Definition: ad7606.h:283
@ AD7606_SHUTDOWN
Definition: ad7606.h:187
int32_t ad7606_read(struct ad7606_dev *dev, uint32_t *data)
Blocking conversion start and data read.
Definition: ad7606.c:543
#define AD7606_MAX_CHANNELS
Definition: ad7606.h:123
int32_t ad7606_convst(struct ad7606_dev *dev)
Toggle the CONVST pin to start a conversion.
Definition: ad7606.c:417
int32_t ad7606_spi_data_read(struct ad7606_dev *dev, uint32_t *data)
Read conversion data.
Definition: ad7606.c:460
struct ad7606_config config
Definition: ad7606.h:352
#define AD7606_INT_CRC_ERR_EN_MSK
Definition: ad7606.h:110
int32_t ad7606_set_oversampling(struct ad7606_dev *dev, struct ad7606_oversampling oversampling)
Set the oversampling ratio.
Definition: ad7606.c:759
bool mm_crc_err_en
Definition: ad7606.h:252
void no_os_crc8_populate_msb(uint8_t *table, const uint8_t polynomial)
int8_t offset_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:309
struct no_os_gpio_desc * gpio_stby_n
Definition: ad7606.h:281
bool has_registers
Definition: ad7606.c:60
int32_t ad7606_spi_reg_write(struct ad7606_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write a device register via SPI.
Definition: ad7606.c:292
bool ext_os_clock
Definition: ad7606.h:215
uint8_t data[28]
Definition: ad7606.h:317
#define AD7606_CLK_FS_OS_COUNTER_EN_MSK
Definition: ad7606.h:114
#define AD7606_ID_DEVICE_ID_MSK
Definition: ad7606.h:101
uint8_t gain_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:360
@ AD7606_OSR_16
Definition: ad7606.h:164
struct no_os_gpio_desc * gpio_os0
Definition: ad7606.h:285
#define AD7606_RANGE_CH_MSK(ch)
Definition: ad7606.h:92
uint8_t phase_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:358
int32_t ad7606_remove(struct ad7606_dev *dev)
Free any resource used by the driver.
Definition: ad7606.c:1237
struct ad7606_range range_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:315
ad7606_op_mode
Operation mode.
Definition: ad7606.h:179
struct ad7606_range range_ch[AD7606_MAX_CHANNELS]
Definition: ad7606.h:362
int32_t ad7606_spi_data_read(struct ad7606_dev *dev, uint32_t *data)
Read conversion data.
Definition: ad7606.c:460
ad7606_device_id
Device ID definitions.
Definition: ad7606.h:129
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
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
struct no_os_gpio_desc * gpio_os2
Definition: ad7606.h:289
uint32_t sw_range_table_sz
Definition: ad7606.c:65
Generic header file for all CRC computation algorithms.
struct ad7606_oversampling oversampling
Definition: ad7606.h:348
struct no_os_gpio_init_param * gpio_os2
Definition: ad7606.h:342
#define AD7606_CONFIG_EXT_OS_CLOCK_MSK
Definition: ad7606.h:88
@ ID_AD7608
Definition: ad7606.h:145
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
#define AD7606_GAIN_MSK
Definition: ad7606.h:105
#define AD7606_REG_OFFSET_CH(ch)
Definition: ad7606.h:62
int32_t ad7606_spi_write_mask(struct ad7606_dev *dev, uint32_t addr, uint32_t mask, uint32_t val)
Write a device register via SPI with masking.
Definition: ad7606.c:340
#define AD7606_RANGE_CH_MODE(ch, mode)
Definition: ad7606.h:93
uint8_t os_pad
Definition: ad7606.h:239
int32_t ad7606_remove(struct ad7606_dev *dev)
Free any resource used by the driver.
Definition: ad7606.c:1237
int32_t ad7606_spi_reg_read(struct ad7606_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read a device register via SPI.
Definition: ad7606.c:230
#define AD7606_REG_RANGE_CH_ADDR(ch)
Definition: ad7606.h:58
int32_t ad7606_set_config(struct ad7606_dev *dev, struct ad7606_config config)
Set the device config register.
Definition: ad7606.c:996
#define AD7606_REG_ID
Definition: ad7606.h:75
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
struct ad7606_digital_diag digital_diag_enable
Definition: ad7606.h:305
struct ad7606_digital_diag digital_diag_enable
Definition: ad7606.h:354
struct ad7606_oversampling oversampling
Definition: ad7606.h:295
@ AD7606_OSR_2
Definition: ad7606.h:158
int32_t ad7606_set_digital_diag(struct ad7606_dev *dev, struct ad7606_digital_diag diag)
Set the device digital diagnostics configuration.
Definition: ad7606.c:1065
uint8_t no_os_crc8(const uint8_t *table, const uint8_t *pdata, size_t nbytes, uint8_t crc)
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
uint16_t no_os_crc16(const uint16_t *table, const uint8_t *pdata, size_t nbytes, uint16_t crc)
const struct ad7606_range * sw_range_table
Definition: ad7606.c:64
int32_t ad7606_set_ch_range(struct ad7606_dev *dev, uint8_t ch, struct ad7606_range range)
Set the channel operation range.
Definition: ad7606.c:839
struct no_os_gpio_desc * gpio_convst
Definition: ad7606.h:277
@ AD7606_OSR_32
Definition: ad7606.h:166
@ AD7606_1_DOUT
Definition: ad7606.h:196
int32_t ad7606_set_oversampling(struct ad7606_dev *dev, struct ad7606_oversampling oversampling)
Set the oversampling ratio.
Definition: ad7606.c:759
#define AD7606_OS_RATIO_MSK
Definition: ad7606.h:98
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
#define NULL
Definition: wrapper.h:64
struct no_os_gpio_init_param * gpio_busy
Definition: ad7606.h:332
bool differential
Definition: ad7606.h:230
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
@ AD7606_OSR_4
Definition: ad7606.h:160
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
#define AD7606_REG_CONFIG
Definition: ad7606.h:57
@ ID_AD7606_8
Definition: ad7606.h:137
@ AD7606_NORMAL
Definition: ad7606.h:181
bool interface_check_en
Definition: ad7606.h:264
struct no_os_gpio_init_param * gpio_convst
Definition: ad7606.h:330
uint8_t bits
Definition: ad7606.c:57
@ AD7606_OSR_256
Definition: ad7606.h:172
int32_t ad7606_init(struct ad7606_dev **device, struct ad7606_init_param *init_param)
Initialize the ad7606 device structure.
Definition: ad7606.c:1110
bool clk_fs_os_counter_en
Definition: ad7606.h:262
#define AD7606_WR_FLAG_MSK(x)
Definition: ad7606.h:121
struct ad7606_config config
Definition: ad7606.h:303
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
bool status_header
Definition: ad7606.h:217
Header file of GPIO Interface.
uint8_t max_dout_lines
Definition: ad7606.c:58
Operation range as specified in datasheet (in uV)
Definition: ad7606.h:224
int32_t ad7606_set_ch_phase(struct ad7606_dev *dev, uint8_t ch, uint8_t phase)
Set the channel phase.
Definition: ad7606.c:926
bool spi_write_err_en
Definition: ad7606.h:256
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
void no_os_crc16_populate_msb(uint16_t *table, const uint16_t polynomial)
#define AD7606_SPI_READ_ERR_EN_MSK
Definition: ad7606.h:112
#define AD7606_CONFIG_STATUS_HEADER_MSK
Definition: ad7606.h:89
enum ad7606_dout_format max_dout_lines
Definition: ad7606.h:301
int32_t ad7606_read(struct ad7606_dev *dev, uint32_t *data)
Blocking conversion start and data read.
Definition: ad7606.c:543
Header file of utility functions.
struct no_os_spi_desc * spi_desc
Definition: ad7606.h:273
@ ID_AD7606_6
Definition: ad7606.h:135
#define AD7606_ROM_CRC_ERR_EN_MSK
Definition: ad7606.h:108
@ AD7606_OSR_128
Definition: ad7606.h:170
uint8_t device_id
Definition: ad7606.c:61
@ AD7606_OSR_64
Definition: ad7606.h:168
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
int32_t ad7606_spi_reg_write(struct ad7606_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write a device register via SPI.
Definition: ad7606.c:292
@ ID_AD7605_4
Definition: ad7606.h:131
bool sw_mode
Definition: ad7606.h:350
ad7606_dout_format
Number of DOUT lines.
Definition: ad7606.h:194
Error macro definition for ARM Compiler.
struct no_os_gpio_init_param * gpio_os1
Definition: ad7606.h:340
@ ID_AD7606B
Definition: ad7606.h:139
@ AD7606_OSR_1
Definition: ad7606.h:156
int32_t ad7606_set_config(struct ad7606_dev *dev, struct ad7606_config config)
Set the device config register.
Definition: ad7606.c:996
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
int32_t ad7606_reset(struct ad7606_dev *dev)
Reset the device by toggling the reset GPIO.
Definition: ad7606.c:622
Device driver structure.
Definition: ad7606.h:271
int32_t ad7606_set_ch_gain(struct ad7606_dev *dev, uint8_t ch, uint8_t gain)
Set the channel gain.
Definition: ad7606.c:960
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:81