Go to the documentation of this file.
50 #define AD719X_SLAVE_ID 1
53 #define AD719X_REG_COMM 0 // Communications Register (WO, 8-bit)
54 #define AD719X_REG_STAT 0 // Status Register (RO, 8-bit)
55 #define AD719X_REG_MODE 1 // Mode Register (RW, 24-bit
56 #define AD719X_REG_CONF 2 // Configuration Register (RW, 24-bit)
57 #define AD719X_REG_DATA 3 // Data Register (RO, 24/32-bit)
58 #define AD719X_REG_ID 4 // ID Register (RO, 8-bit)
59 #define AD719X_REG_GPOCON 5 // GPOCON Register (RW, 8-bit)
60 #define AD719X_REG_OFFSET 6 // Offset Register (RW, 24-bit
61 #define AD719X_REG_FULLSCALE 7 // Full-Scale Register (RW, 24-bit)
64 #define AD719X_COMM_WEN (1 << 7) // Write Enable.
65 #define AD719X_COMM_WRITE (0 << 6) // Write Operation.
66 #define AD719X_COMM_READ (1 << 6) // Read Operation.
67 #define AD719X_COMM_ADDR(x) (((x) & 0x7) << 3) // Register Address.
68 #define AD719X_COMM_CREAD (1 << 2) // Continuous Read of Data Register.
71 #define AD719X_STAT_RDY (1 << 7) // Ready.
72 #define AD719X_STAT_ERR (1 << 6) // ADC error bit.
73 #define AD719X_STAT_NOREF (1 << 5) // Error no external reference.
74 #define AD719X_STAT_PARITY (1 << 4) // Parity check of the data register.
75 #define AD719X_STAT_CH3 (1 << 3) // Channel 3.
76 #define AD719X_STAT_CH2 (1 << 2) // Channel 2.
77 #define AD719X_STAT_CH1 (1 << 1) // Channel 1.
78 #define AD719X_STAT_CH0 (1 << 0) // Channel 0.
81 #define AD719X_MODE_SEL(x) (((uint32_t)(x) & 0x7) << 21) // Operation Mode Select.
82 #define AD719X_MODE_DAT_STA ((uint32_t)1 << 20) // Status Register transmission.
83 #define AD719X_MODE_CLKSRC(x) (((uint32_t)(x) & 0x3) << 18) // Clock Source Select.
84 #define AD719X_MODE_AVG(x) (((uint32_t)(x) & 0x3) << 16) // Fast settling filter.
85 #define AD719X_MODE_SINC3 (1 << 15) // SINC3 Filter Select.
86 #define AD719X_MODE_ENPAR (1 << 13) // Parity Enable.
87 #define AD719X_MODE_CLKDIV (1 << 12) // Clock divide by 2 (AD7190/2 only).
88 #define AD719X_MODE_SCYCLE (1 << 11) // Single cycle conversion.
89 #define AD719X_MODE_REJ60 (1 << 10) // 50/60Hz notch filter.
90 #define AD719X_MODE_RATE(x) ((x) & 0x3FF) // Filter Update Rate Select.
93 #define AD719X_AVG_NONE 0 // No averaging (fast settling mode disabled).
94 #define AD719X_AVG_BY_2 1 // Average by 2.
95 #define AD719X_AVG_BY_8 2 // Average by 8.
96 #define AD719X_AVG_BY_16 3 // Average by 16.
99 #define AD719X_CONF_CHOP ((uint32_t)1 << 23) // CHOP enable.
100 #define AD719X_CONF_REFSEL ((uint32_t)1 << 20) // REFIN1/REFIN2 Reference Select.
101 #define AD719X_CONF_PSEUDO ((uint32_t)1 << 18) // Pseudo differential analog inputs.
102 #define AD719X_CONF_CHAN(x) ((uint32_t)((x) & 0x3FF) << 8) // Channel select.
103 #define AD719X_CONF_BURN (1 << 7) // Burnout current enable.
104 #define AD719X_CONF_REFDET (1 << 6) // Reference detect enable.
105 #define AD719X_CONF_BUF (1 << 4) // Buffered Mode Enable.
106 #define AD719X_CONF_UNIPOLAR (1 << 3) // Unipolar/Bipolar Enable.
107 #define AD719X_CONF_GAIN(x) ((x) & 0x7) // Gain Select.
110 #define AD719X_CH_MASK(channel) NO_OS_BIT(channel)
113 #define AD719X_CH_0 0
114 #define AD719X_CH_1 1
115 #define AD719X_CH_2 2
116 #define AD719X_CH_3 3
117 #define AD719X_CH_4 4
118 #define AD719X_CH_5 5
119 #define AD719X_CH_6 6
120 #define AD719X_CH_7 7
121 #define AD719X_CH_TEMP 8
122 #define AD719X_CH_SHORT 9
125 #define AD7190_4_ID_MASK 0x0F
126 #define AD7195_ID_MASK 0xFF
129 #define AD719X_GPOCON_BPDSW (1 << 6) // Bridge power-down switch enable
130 #define AD719X_GPOCON_GP32EN (1 << 5) // Digital Output P3 and P2 enable
131 #define AD719X_GPOCON_GP10EN (1 << 4) // Digital Output P1 and P0 enable
132 #define AD719X_GPOCON_P3DAT (1 << 3) // P3 state
133 #define AD719X_GPOCON_P2DAT (1 << 2) // P2 state
134 #define AD719X_GPOCON_P1DAT (1 << 1) // P1 state
135 #define AD719X_GPOCON_P0DAT (1 << 0) // P0 state
239 uint32_t reg_value, uint8_t bytes_number);
243 uint8_t bytes_number, uint32_t *reg_data);
247 uint8_t reg_addr, uint32_t mask, uint32_t data,
265 uint8_t mode, uint8_t channel);
275 uint16_t out_rate_code);
293 uint8_t sample_number, uint32_t *samples_avg);
300 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:539
@ AD719X_MODE_IDLE
Definition: ad719x.h:168
uint32_t timeout
Definition: ad413x.c:49
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
@ AD719X_MODE_SINGLE
Definition: ad719x.h:166
int ad719x_reset(struct ad719x_dev *dev)
Resets the device.
Definition: ad719x.c:310
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:159
struct no_os_gpio_init_param * sync_pin
Definition: ad719x.h:213
Header file of SPI Interface.
int ad719x_reset(struct ad719x_dev *dev)
Resets the device.
Definition: ad719x.c:310
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:566
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:221
@ AD719X_MODE_CAL_INT_ZERO
Definition: ad719x.h:172
uint8_t input_mode
Definition: ad719x.h:220
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:250
#define AD719X_MODE_SEL(x)
Definition: ad719x.h:81
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:216
Header file of Delay functions.
#define AD719X_CONF_GAIN(x)
Definition: ad719x.h:107
@ AD719X_MODE_CAL_SYS_ZERO
Definition: ad719x.h:176
#define AD719X_MODE_CLKSRC(x)
Definition: ad719x.h:83
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:486
int ad719x_wait_rdy_go_low(struct ad719x_dev *dev)
Waits for RDY pin to go low.
Definition: ad719x.c:364
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:58
uint8_t current_polarity
Definition: ad719x.h:215
Definition: ad9361_util.h:69
@ AD719X_MODE_PWRDN
Definition: ad719x.h:170
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
int ad719x_channels_select(struct ad719x_dev *dev, uint16_t chn_mask)
Selects the channels to be enabled.
Definition: ad719x.c:392
int ad719x_calibrate(struct ad719x_dev *dev, uint8_t mode, uint8_t channel)
Performs the given calibration to the specified channel.
Definition: ad719x.c:431
int ad719x_temperature_read(struct ad719x_dev *dev, float *temp)
Read data from temperature sensor and converts it to Celsius degrees.
Definition: ad719x.c:697
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:124
@ AD719X_ADC_GAIN_128
Definition: ad719x.h:148
#define AD719X_REG_CONF
Definition: ad719x.h:56
@ AD719X_MODE_CAL_SYS_FULL
Definition: ad719x.h:178
#define AD719X_REG_GPOCON
Definition: ad719x.h:59
uint8_t bpdsw_mode
Definition: ad719x.h:203
int ad719x_temperature_read(struct ad719x_dev *dev, float *temp)
Read data from temperature sensor and converts it to Celsius degrees.
Definition: ad719x.c:697
@ AD719X_EXT_CRYSTAL_MCLK1_MCLK2
Definition: ad719x.h:153
#define AD7190_4_ID_MASK
Definition: ad719x.h:125
@ AD719X_ADC_GAIN_64
Definition: ad719x.h:147
#define AD719X_COMM_ADDR(x)
Definition: ad719x.h:67
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:216
struct no_os_gpio_init_param * gpio_miso
Definition: ad719x.h:211
int ad719x_config_input_mode(struct ad719x_dev *dev, uint8_t mode)
Configures the input mode of the ADC.
Definition: ad719x.c:459
int ad719x_channels_select(struct ad719x_dev *dev, uint16_t chn_mask)
Selects the channels to be enabled.
Definition: ad719x.c:392
#define AD719X_CH_MASK(channel)
Definition: ad719x.h:110
struct no_os_gpio_desc * sync_pin
Definition: ad719x.h:194
@ AD719X_ADC_GAIN_16
Definition: ad719x.h:145
#define AD719X_REG_DATA
Definition: ad719x.h:57
#define AD719X_CONF_BUF
Definition: ad719x.h:105
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:656
@ AD719X_MODE_CAL_INT_FULL
Definition: ad719x.h:174
uint8_t bpdsw_mode
Definition: ad719x.h:222
struct no_os_gpio_desc * gpio_miso
Definition: ad719x.h:193
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:566
uint8_t current_polarity
Definition: ad719x.h:196
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:656
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:598
@ AD7190
Definition: ad719x.h:182
#define AD719X_REG_ID
Definition: ad719x.h:58
int ad719x_clock_select(struct ad719x_dev *dev, enum ad719x_adc_clock clk_select)
Selects the clock source of the ADC.
Definition: ad719x.c:539
ad719x_adc_gain
Definition: ad719x.h:141
#define AD7195_ID_MASK
Definition: ad719x.h:126
enum ad719x_adc_gain current_gain
Definition: ad719x.h:216
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:598
ad719x_adc_clock
Definition: ad719x.h:151
uint8_t input_mode
Definition: ad719x.h:201
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:104
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
uint16_t data_rate_code
Definition: ad719x.h:199
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:285
#define AD719X_COMM_READ
Definition: ad719x.h:66
ad719x_adc_modes
Definition: ad719x.h:162
@ AD7192
Definition: ad719x.h:183
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
int ad719x_remove(struct ad719x_dev *dev)
Free the resources allocated by ad719x_init().
Definition: ad719x.c:189
uint8_t buffer
Definition: ad719x.h:202
#define AD719X_GPOCON_BPDSW
Definition: ad719x.h:129
#define AD719X_CONF_PSEUDO
Definition: ad719x.h:101
#define AD719X_CH_2
Definition: ad719x.h:115
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:49
enum ad719x_adc_clock clock_source
Definition: ad719x.h:200
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
enum ad719x_chip_id chip_id
Definition: ad719x.h:223
int ad719x_remove(struct ad719x_dev *dev)
Free the resources allocated by ad719x_init().
Definition: ad719x.c:189
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:342
int ad719x_single_conversion(struct ad719x_dev *dev, uint32_t *reg_data)
Returns the result of a single conversion.
Definition: ad719x.c:625
ad719x_chip_id
Definition: ad719x.h:181
@ AD719X_INT_CLK_4_92_MHZ_TRIST
Definition: ad719x.h:157
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:250
@ AD7193
Definition: ad719x.h:184
@ AD7194
Definition: ad719x.h:185
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:69
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:342
int ad719x_wait_rdy_go_low(struct ad719x_dev *dev)
Waits for RDY pin to go low.
Definition: ad719x.c:364
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:58
enum ad719x_adc_modes operating_mode
Definition: ad719x.h:217
#define AD719X_COMM_WRITE
Definition: ad719x.h:65
#define AD719X_MODE_RATE(x)
Definition: ad719x.h:90
struct no_os_spi_init_param * spi_init
Definition: ad719x.h:209
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
enum ad719x_adc_gain current_gain
Definition: ad719x.h:197
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:197
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int ad719x_calibrate(struct ad719x_dev *dev, uint8_t mode, uint8_t channel)
Performs the given calibration to the specified channel.
Definition: ad719x.c:431
@ AD719X_MODE_CONT
Definition: ad719x.h:164
enum ad719x_adc_clock clock_source
Definition: ad719x.h:219
struct no_os_spi_desc * spi_desc
Definition: ad719x.h:191
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:737
int ad719x_single_conversion(struct ad719x_dev *dev, uint32_t *reg_data)
Returns the result of a single conversion.
Definition: ad719x.c:625
uint16_t data_rate_code
Definition: ad719x.h:218
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:285
#define AD719X_CH_TEMP
Definition: ad719x.h:121
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:116
enum ad719x_chip_id chip_id
Definition: ad719x.h:204
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:737
@ AD719X_INT_CLK_4_92_MHZ
Definition: ad719x.h:159
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:52
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:510
int ad719x_config_input_mode(struct ad719x_dev *dev, uint8_t mode)
Configures the input mode of the ADC.
Definition: ad719x.c:459
@ AD7195
Definition: ad719x.h:186
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:486
@ AD719X_ADC_GAIN_32
Definition: ad719x.h:146
@ AD719X_EXT_CRYSTAL_MCLK2
Definition: ad719x.h:155
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:510
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:147
@ AD719X_ADC_GAIN_8
Definition: ad719x.h:144
enum ad719x_adc_modes operating_mode
Definition: ad719x.h:198
int ad719x_sync_control(struct ad719x_dev *dev, uint8_t value)
Control SYNC pin for synchronization of multiple devices.
Definition: ad719x.c:763
Header file of AD7190/2/3/4/5 Driver.
#define AD719X_CONF_CHAN(x)
Definition: ad719x.h:102
uint8_t buffer
Definition: ad719x.h:221
#define AD719X_REG_MODE
Definition: ad719x.h:55
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
#define AD719X_CONF_UNIPOLAR
Definition: ad719x.h:106
@ AD719X_ADC_GAIN_1
Definition: ad719x.h:143
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:75