Go to the documentation of this file.
56 #define AD719X_SLAVE_ID 1
59 #define AD719X_REG_COMM 0 // Communications Register (WO, 8-bit)
60 #define AD719X_REG_STAT 0 // Status Register (RO, 8-bit)
61 #define AD719X_REG_MODE 1 // Mode Register (RW, 24-bit
62 #define AD719X_REG_CONF 2 // Configuration Register (RW, 24-bit)
63 #define AD719X_REG_DATA 3 // Data Register (RO, 24/32-bit)
64 #define AD719X_REG_ID 4 // ID Register (RO, 8-bit)
65 #define AD719X_REG_GPOCON 5 // GPOCON Register (RW, 8-bit)
66 #define AD719X_REG_OFFSET 6 // Offset Register (RW, 24-bit
67 #define AD719X_REG_FULLSCALE 7 // Full-Scale Register (RW, 24-bit)
70 #define AD719X_COMM_WEN (1 << 7) // Write Enable.
71 #define AD719X_COMM_WRITE (0 << 6) // Write Operation.
72 #define AD719X_COMM_READ (1 << 6) // Read Operation.
73 #define AD719X_COMM_ADDR(x) (((x) & 0x7) << 3) // Register Address.
74 #define AD719X_COMM_CREAD (1 << 2) // Continuous Read of Data Register.
77 #define AD719X_STAT_RDY (1 << 7) // Ready.
78 #define AD719X_STAT_ERR (1 << 6) // ADC error bit.
79 #define AD719X_STAT_NOREF (1 << 5) // Error no external reference.
80 #define AD719X_STAT_PARITY (1 << 4) // Parity check of the data register.
81 #define AD719X_STAT_CH3 (1 << 3) // Channel 3.
82 #define AD719X_STAT_CH2 (1 << 2) // Channel 2.
83 #define AD719X_STAT_CH1 (1 << 1) // Channel 1.
84 #define AD719X_STAT_CH0 (1 << 0) // Channel 0.
87 #define AD719X_MODE_SEL(x) (((uint32_t)(x) & 0x7) << 21) // Operation Mode Select.
88 #define AD719X_MODE_DAT_STA ((uint32_t)1 << 20) // Status Register transmission.
89 #define AD719X_MODE_CLKSRC(x) (((uint32_t)(x) & 0x3) << 18) // Clock Source Select.
90 #define AD719X_MODE_AVG(x) (((uint32_t)(x) & 0x3) << 16) // Fast settling filter.
91 #define AD719X_MODE_SINC3 (1 << 15) // SINC3 Filter Select.
92 #define AD719X_MODE_ENPAR (1 << 13) // Parity Enable.
93 #define AD719X_MODE_CLKDIV (1 << 12) // Clock divide by 2 (AD7190/2 only).
94 #define AD719X_MODE_SCYCLE (1 << 11) // Single cycle conversion.
95 #define AD719X_MODE_REJ60 (1 << 10) // 50/60Hz notch filter.
96 #define AD719X_MODE_RATE(x) ((x) & 0x3FF) // Filter Update Rate Select.
99 #define AD719X_AVG_NONE 0 // No averaging (fast settling mode disabled).
100 #define AD719X_AVG_BY_2 1 // Average by 2.
101 #define AD719X_AVG_BY_8 2 // Average by 8.
102 #define AD719X_AVG_BY_16 3 // Average by 16.
105 #define AD719X_CONF_CHOP ((uint32_t)1 << 23) // CHOP enable.
106 #define AD719X_CONF_REFSEL ((uint32_t)1 << 20) // REFIN1/REFIN2 Reference Select.
107 #define AD719X_CONF_PSEUDO ((uint32_t)1 << 18) // Pseudo differential analog inputs.
108 #define AD719X_CONF_CHAN(x) ((uint32_t)((x) & 0x3FF) << 8) // Channel select.
109 #define AD719X_CONF_BURN (1 << 7) // Burnout current enable.
110 #define AD719X_CONF_REFDET (1 << 6) // Reference detect enable.
111 #define AD719X_CONF_BUF (1 << 4) // Buffered Mode Enable.
112 #define AD719X_CONF_UNIPOLAR (1 << 3) // Unipolar/Bipolar Enable.
113 #define AD719X_CONF_GAIN(x) ((x) & 0x7) // Gain Select.
116 #define AD719X_CH_MASK(channel) NO_OS_BIT(channel)
119 #define AD719X_CH_0 0
120 #define AD719X_CH_1 1
121 #define AD719X_CH_2 2
122 #define AD719X_CH_3 3
123 #define AD719X_CH_4 4
124 #define AD719X_CH_5 5
125 #define AD719X_CH_6 6
126 #define AD719X_CH_7 7
127 #define AD719X_CH_TEMP 8
128 #define AD719X_CH_SHORT 9
131 #define AD7190_4_ID_MASK 0x0F
132 #define AD7195_ID_MASK 0xFF
135 #define AD719X_GPOCON_BPDSW (1 << 6) // Bridge power-down switch enable
136 #define AD719X_GPOCON_GP32EN (1 << 5) // Digital Output P3 and P2 enable
137 #define AD719X_GPOCON_GP10EN (1 << 4) // Digital Output P1 and P0 enable
138 #define AD719X_GPOCON_P3DAT (1 << 3) // P3 state
139 #define AD719X_GPOCON_P2DAT (1 << 2) // P2 state
140 #define AD719X_GPOCON_P1DAT (1 << 1) // P1 state
141 #define AD719X_GPOCON_P0DAT (1 << 0) // P0 state
245 uint32_t reg_value, uint8_t bytes_number);
249 uint8_t bytes_number, uint32_t *reg_data);
253 uint8_t reg_addr, uint32_t mask, uint32_t data,
271 uint8_t mode, uint8_t channel);
281 uint16_t out_rate_code);
299 uint8_t sample_number, uint32_t *samples_avg);
306 uint32_t raw_data,
float v_ref);
int ad719x_clock_select(struct ad719x_dev *dev, enum ad719x_adc_clock clk_select)
Selects the clock source of the ADC.
Definition: ad719x.c:545
@ AD719X_MODE_IDLE
Definition: ad719x.h:174
uint32_t timeout
Definition: ad413x.c:55
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
@ AD719X_MODE_SINGLE
Definition: ad719x.h:172
int ad719x_reset(struct ad719x_dev *dev)
Resets the device.
Definition: ad719x.c:316
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
struct no_os_gpio_init_param * sync_pin
Definition: ad719x.h:219
Header file of SPI Interface.
int ad719x_reset(struct ad719x_dev *dev)
Resets the device.
Definition: ad719x.c:316
int ad719x_set_bridge_switch(struct ad719x_dev *dev, uint8_t bpdsw_select)
Opens or closes the bridge power-down switch of the ADC.
Definition: ad719x.c:572
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
@ AD719X_MODE_CAL_INT_ZERO
Definition: ad719x.h:178
uint8_t input_mode
Definition: ad719x.h:226
int ad719x_get_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint8_t bytes_number, uint32_t *reg_data)
Reads the value of a register.
Definition: ad719x.c:256
#define AD719X_MODE_SEL(x)
Definition: ad719x.h:87
int ad719x_set_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint32_t reg_value, uint8_t bytes_number)
Writes data into a register.
Definition: ad719x.c:222
Header file of Delay functions.
#define AD719X_CONF_GAIN(x)
Definition: ad719x.h:113
@ AD719X_MODE_CAL_SYS_ZERO
Definition: ad719x.h:182
#define AD719X_MODE_CLKSRC(x)
Definition: ad719x.h:89
int ad719x_buffer_select(struct ad719x_dev *dev, uint8_t buff_en)
Enables or disables the buffer on the ADC input channels.
Definition: ad719x.c:492
int ad719x_wait_rdy_go_low(struct ad719x_dev *dev)
Waits for RDY pin to go low.
Definition: ad719x.c:370
int ad719x_init(struct ad719x_dev **device, struct ad719x_init_param init_param)
Initializes the communication peripheral and the initial Values for AD719X Board and resets the devic...
Definition: ad719x.c:64
uint8_t current_polarity
Definition: ad719x.h:221
Definition: ad9361_util.h:75
@ AD719X_MODE_PWRDN
Definition: ad719x.h:176
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:123
int ad719x_channels_select(struct ad719x_dev *dev, uint16_t chn_mask)
Selects the channels to be enabled.
Definition: ad719x.c:398
int ad719x_calibrate(struct ad719x_dev *dev, uint8_t mode, uint8_t channel)
Performs the given calibration to the specified channel.
Definition: ad719x.c:437
int ad719x_temperature_read(struct ad719x_dev *dev, float *temp)
Read data from temperature sensor and converts it to Celsius degrees.
Definition: ad719x.c:703
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
@ AD719X_ADC_GAIN_128
Definition: ad719x.h:154
#define AD719X_REG_CONF
Definition: ad719x.h:62
@ AD719X_MODE_CAL_SYS_FULL
Definition: ad719x.h:184
#define AD719X_REG_GPOCON
Definition: ad719x.h:65
uint8_t bpdsw_mode
Definition: ad719x.h:209
int ad719x_temperature_read(struct ad719x_dev *dev, float *temp)
Read data from temperature sensor and converts it to Celsius degrees.
Definition: ad719x.c:703
@ AD719X_EXT_CRYSTAL_MCLK1_MCLK2
Definition: ad719x.h:159
#define AD7190_4_ID_MASK
Definition: ad719x.h:131
@ AD719X_ADC_GAIN_64
Definition: ad719x.h:153
#define AD719X_COMM_ADDR(x)
Definition: ad719x.h:73
int ad719x_set_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint32_t reg_val, uint8_t bytes_number)
Writes data into a register.
Definition: ad719x.c:222
struct no_os_gpio_init_param * gpio_miso
Definition: ad719x.h:217
int ad719x_config_input_mode(struct ad719x_dev *dev, uint8_t mode)
Configures the input mode of the ADC.
Definition: ad719x.c:465
int ad719x_channels_select(struct ad719x_dev *dev, uint16_t chn_mask)
Selects the channels to be enabled.
Definition: ad719x.c:398
#define AD719X_CH_MASK(channel)
Definition: ad719x.h:116
struct no_os_gpio_desc * sync_pin
Definition: ad719x.h:200
@ AD719X_ADC_GAIN_16
Definition: ad719x.h:151
#define AD719X_REG_DATA
Definition: ad719x.h:63
#define AD719X_CONF_BUF
Definition: ad719x.h:111
int ad719x_continuous_read_avg(struct ad719x_dev *dev, uint8_t sample_number, uint32_t *samples_avg)
Returns the average of several conversion results.
Definition: ad719x.c:662
@ AD719X_MODE_CAL_INT_FULL
Definition: ad719x.h:180
uint8_t bpdsw_mode
Definition: ad719x.h:228
struct no_os_gpio_desc * gpio_miso
Definition: ad719x.h:199
int ad719x_set_bridge_switch(struct ad719x_dev *dev, uint8_t bpdsw_select)
Opens or closes the bridge power-down switch of the ADC.
Definition: ad719x.c:572
uint8_t current_polarity
Definition: ad719x.h:202
int ad719x_continuous_read_avg(struct ad719x_dev *dev, uint8_t sample_number, uint32_t *samples_avg)
Returns the average of several conversion results.
Definition: ad719x.c:662
int ad719x_range_setup(struct ad719x_dev *dev, uint8_t polarity, enum ad719x_adc_gain gain)
Selects the polarity of the conversion and the ADC input range.
Definition: ad719x.c:604
@ AD7190
Definition: ad719x.h:188
#define AD719X_REG_ID
Definition: ad719x.h:64
int ad719x_clock_select(struct ad719x_dev *dev, enum ad719x_adc_clock clk_select)
Selects the clock source of the ADC.
Definition: ad719x.c:545
ad719x_adc_gain
Definition: ad719x.h:147
#define AD7195_ID_MASK
Definition: ad719x.h:132
enum ad719x_adc_gain current_gain
Definition: ad719x.h:222
int ad719x_range_setup(struct ad719x_dev *dev, uint8_t polarity, enum ad719x_adc_gain range)
Selects the polarity of the conversion and the ADC input range.
Definition: ad719x.c:604
ad719x_adc_clock
Definition: ad719x.h:157
uint8_t input_mode
Definition: ad719x.h:207
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
uint16_t data_rate_code
Definition: ad719x.h:205
int ad719x_set_masked_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint32_t mask, uint32_t data, uint8_t bytes)
Write masked data into device register.
Definition: ad719x.c:291
#define AD719X_COMM_READ
Definition: ad719x.h:72
ad719x_adc_modes
Definition: ad719x.h:168
@ AD7192
Definition: ad719x.h:189
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
int ad719x_remove(struct ad719x_dev *dev)
Free the resources allocated by ad719x_init().
Definition: ad719x.c:195
uint8_t buffer
Definition: ad719x.h:208
#define AD719X_GPOCON_BPDSW
Definition: ad719x.h:135
#define AD719X_CONF_PSEUDO
Definition: ad719x.h:107
#define AD719X_CH_2
Definition: ad719x.h:121
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
enum ad719x_adc_clock clock_source
Definition: ad719x.h:206
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
enum ad719x_chip_id chip_id
Definition: ad719x.h:229
int ad719x_remove(struct ad719x_dev *dev)
Free the resources allocated by ad719x_init().
Definition: ad719x.c:195
int ad719x_set_operating_mode(struct ad719x_dev *dev, enum ad719x_adc_modes opt_mode)
Sets device into the specified operating mode.
Definition: ad719x.c:348
int ad719x_single_conversion(struct ad719x_dev *dev, uint32_t *reg_data)
Returns the result of a single conversion.
Definition: ad719x.c:631
ad719x_chip_id
Definition: ad719x.h:187
@ AD719X_INT_CLK_4_92_MHZ_TRIST
Definition: ad719x.h:163
int ad719x_get_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint8_t bytes_number, uint32_t *reg_data)
Reads the value of a register.
Definition: ad719x.c:256
@ AD7193
Definition: ad719x.h:190
@ AD7194
Definition: ad719x.h:191
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
int ad719x_set_operating_mode(struct ad719x_dev *dev, enum ad719x_adc_modes opt_mode)
Sets device into the specified operating mode.
Definition: ad719x.c:348
int ad719x_wait_rdy_go_low(struct ad719x_dev *dev)
Waits for RDY pin to go low.
Definition: ad719x.c:370
int ad719x_init(struct ad719x_dev **device, struct ad719x_init_param init_param)
Initializes the communication peripheral and the initial Values for AD719X Board and resets the devic...
Definition: ad719x.c:64
enum ad719x_adc_modes operating_mode
Definition: ad719x.h:223
#define AD719X_COMM_WRITE
Definition: ad719x.h:71
#define AD719X_MODE_RATE(x)
Definition: ad719x.h:96
struct no_os_spi_init_param * spi_init
Definition: ad719x.h:215
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
enum ad719x_adc_gain current_gain
Definition: ad719x.h:203
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
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
int ad719x_calibrate(struct ad719x_dev *dev, uint8_t mode, uint8_t channel)
Performs the given calibration to the specified channel.
Definition: ad719x.c:437
@ AD719X_MODE_CONT
Definition: ad719x.h:170
enum ad719x_adc_clock clock_source
Definition: ad719x.h:225
struct no_os_spi_desc * spi_desc
Definition: ad719x.h:197
float ad719x_convert_to_volts(struct ad719x_dev *dev, uint32_t raw_data, float v_ref)
Converts 24-bit raw data to milivolts.
Definition: ad719x.c:743
int ad719x_single_conversion(struct ad719x_dev *dev, uint32_t *reg_data)
Returns the result of a single conversion.
Definition: ad719x.c:631
uint16_t data_rate_code
Definition: ad719x.h:224
int ad719x_set_masked_register_value(struct ad719x_dev *dev, uint8_t reg_addr, uint32_t mask, uint32_t reg_data, uint8_t bytes)
Write masked data into device register.
Definition: ad719x.c:291
#define AD719X_CH_TEMP
Definition: ad719x.h:127
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
enum ad719x_chip_id chip_id
Definition: ad719x.h:210
Header file of GPIO Interface.
float ad719x_convert_to_volts(struct ad719x_dev *dev, uint32_t raw_data, float v_ref)
Converts 24-bit raw data to milivolts.
Definition: ad719x.c:743
@ AD719X_INT_CLK_4_92_MHZ
Definition: ad719x.h:165
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
int ad719x_output_rate_select(struct ad719x_dev *dev, uint16_t out_rate_code)
Selects the filter output data rate of the ADC.
Definition: ad719x.c:516
int ad719x_config_input_mode(struct ad719x_dev *dev, uint8_t mode)
Configures the input mode of the ADC.
Definition: ad719x.c:465
@ AD7195
Definition: ad719x.h:192
Header file of utility functions.
int ad719x_buffer_select(struct ad719x_dev *dev, uint8_t buff_en)
Enables or disables the buffer on the ADC input channels.
Definition: ad719x.c:492
@ AD719X_ADC_GAIN_32
Definition: ad719x.h:152
@ AD719X_EXT_CRYSTAL_MCLK2
Definition: ad719x.h:161
int ad719x_output_rate_select(struct ad719x_dev *dev, uint16_t out_rate_code)
Selects the filter output data rate of the ADC.
Definition: ad719x.c:516
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
@ AD719X_ADC_GAIN_8
Definition: ad719x.h:150
enum ad719x_adc_modes operating_mode
Definition: ad719x.h:204
int ad719x_sync_control(struct ad719x_dev *dev, uint8_t value)
Control SYNC pin for synchronization of multiple devices.
Definition: ad719x.c:769
Header file of AD7190/2/3/4/5 Driver.
#define AD719X_CONF_CHAN(x)
Definition: ad719x.h:108
uint8_t buffer
Definition: ad719x.h:227
#define AD719X_REG_MODE
Definition: ad719x.h:61
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
#define AD719X_CONF_UNIPOLAR
Definition: ad719x.h:112
@ AD719X_ADC_GAIN_1
Definition: ad719x.h:149
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