no-OS
|
Header file of AD463x Driver. More...
#include <stdint.h>
#include "no_os_util.h"
#include "spi_engine.h"
#include "clk_axi_clkgen.h"
#include "no_os_pwm.h"
#include "no_os_gpio.h"
Go to the source code of this file.
Classes | |
struct | ad463x_init_param |
struct | ad463x_dev |
Device initialization parameters. More... | |
Enumerations | |
enum | ad463x_id { ID_AD4630_24, ID_AD4630_20, ID_AD4630_16, ID_AD4631_24, ID_AD4631_20, ID_AD4631_16, ID_AD4632_24, ID_AD4632_20, ID_AD4632_16, ID_AD4030, ID_ADAQ4224 } |
Device type. More... | |
enum | ad463x_pgia_gain { AD463X_GAIN_0_33 = 0, AD463X_GAIN_0_56 = 1, AD463X_GAIN_2_22 = 2, AD463X_GAIN_6_67 = 3 } |
Available pgia gains. More... | |
Functions | |
int32_t | ad463x_spi_reg_read (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t *reg_data) |
Read device register. More... | |
int32_t | ad463x_spi_reg_write (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t reg_data) |
Write device register. More... | |
int32_t | ad463x_spi_reg_read_masked (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t *data) |
SPI read device register using a mask. More... | |
int32_t | ad463x_spi_reg_write_masked (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data) |
SPI write device register using a mask. More... | |
int32_t | ad463x_set_pwr_mode (struct ad463x_dev *dev, uint8_t mode) |
Set power mode. More... | |
int32_t | ad463x_set_avg_frame_len (struct ad463x_dev *dev, uint8_t mode) |
Set average frame length. More... | |
int32_t | ad463x_set_drive_strength (struct ad463x_dev *dev, uint8_t mode) |
Set drive strength. More... | |
int32_t | ad463x_exit_reg_cfg_mode (struct ad463x_dev *dev) |
Exit register configuration mode. More... | |
int32_t | ad463x_set_ch_gain (struct ad463x_dev *dev, uint8_t ch_idx, uint64_t gain) |
Set channel gain. More... | |
int32_t | ad463x_set_ch_offset (struct ad463x_dev *dev, uint8_t ch_idx, uint32_t offset) |
Set channel offset. More... | |
int32_t | ad463x_read_data (struct ad463x_dev *dev, uint32_t *buf, uint16_t samples) |
Read from device. Enter register mode to read/write registers. More... | |
int32_t | ad463x_init (struct ad463x_dev **device, struct ad463x_init_param *init_param) |
Initialize the device. More... | |
int32_t | ad463x_calc_pgia_gain (int32_t gain_int, int32_t gain_fract, int32_t vref, int32_t precision, enum ad463x_pgia_gain *gain_idx) |
Calculate the PGIA gain. More... | |
int32_t | ad463x_set_pgia_gain (struct ad463x_dev *dev, enum ad463x_pgia_gain gain_idx) |
Set the PGIA gain. More... | |
int32_t | ad463x_remove (struct ad463x_dev *dev) |
Free the memory allocated by ad463x_init(). More... | |
int32_t | ad463x_enter_config_mode (struct ad463x_dev *dev) |
Enter register configuration mode. More... | |
Header file of AD463x Driver.
Copyright 2021(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AD463X_16_DIFF_8_COM 0x01 |
#define AD463X_24_DIFF 0x00 |
#define AD463X_24_DIFF_8_COM 0x02 |
#define AD463X_30_AVERAGED_DIFF 0x03 |
#define AD463X_32_PATTERN 0x04 |
#define AD463X_AVG_FILTER_RESET NO_OS_BIT(7) |
#define AD463X_CFG_SDO_ENABLE NO_OS_BIT(4) |
#define AD463X_CHANNEL_0 0x00 |
#define AD463X_CHANNEL_1 0x01 |
#define AD463X_CLOCK_MASTER_MODE NO_OS_BIT(5) |
#define AD463X_CONFIG_TIMING 0x2000 |
#define AD463X_DDR_MODE NO_OS_BIT(3) |
#define AD463X_DDR_MODE_MSK NO_OS_BIT(3) |
#define AD463X_DOUBLE_OUTPUT_STRENGTH NO_OS_BIT(1) |
#define AD463X_DRIVER_STRENGTH_MASK NO_OS_BIT(0) |
#define AD463X_ECHO_CLOCK_MODE NO_OS_BIT(4) |
#define AD463X_EXIT_CFG_MODE NO_OS_BIT(0) |
#define AD463X_FOUR_LANES_PER_CH NO_OS_BIT(7) |
#define AD463X_GAIN_LSB 0x00 |
#define AD463X_GAIN_MAX_VAL_SCALED 19997 |
#define AD463X_GAIN_MSB 0x01 |
#define AD463x_H_ |
#define AD463X_NORMAL_MODE 0x00 |
#define AD463X_NORMAL_OUTPUT_STRENGTH 0x00 |
#define AD463X_OFFSET_0 0x00 |
#define AD463X_OFFSET_1 0x01 |
#define AD463X_OFFSET_2 0x02 |
#define AD463X_ONE_LANE_PER_CH 0x00 |
#define AD463X_OUT_DATA_PAT 0x5A5A0F0F |
#define AD463X_REG_AVG 0x15 |
#define AD463X_REG_CHAN_GAIN | ( | ch, | |
pos | |||
) | (AD463X_REG_GAIN_BASE + (2 * ch) + pos) |
#define AD463X_REG_CHAN_OFFSET | ( | ch, | |
pos | |||
) | (AD463X_REG_OFFSET_BASE + (3 * ch) + pos) |
#define AD463X_REG_CHIP_GRADE 0x06 |
#define AD463X_REG_CHIP_TYPE 0x03 |
#define AD463X_REG_DEVICE_CONFIG 0x02 |
#define AD463X_REG_DIG_DIAG 0x34 |
#define AD463X_REG_DIG_ERR 0x35 |
#define AD463X_REG_EXIT_CFG_MODE 0x14 |
#define AD463X_REG_GAIN_BASE 0x1C |
#define AD463X_REG_GAIN_X0_LSB 0x1C |
#define AD463X_REG_GAIN_X0_MSB 0x1D |
#define AD463X_REG_GAIN_X1_LSB 0x1E |
#define AD463X_REG_GAIN_X1_MSB 0x1F |
#define AD463X_REG_INTERFACE_CONFIG_A 0x00 |
#define AD463X_REG_INTERFACE_CONFIG_B 0x01 |
#define AD463X_REG_IO 0x22 |
#define AD463X_REG_MODES 0x20 |
#define AD463X_REG_OFFSET_BASE 0x16 |
#define AD463X_REG_OFFSET_X0_0 0x16 |
#define AD463X_REG_OFFSET_X0_1 0x17 |
#define AD463X_REG_OFFSET_X0_2 0x18 |
#define AD463X_REG_OFFSET_X1_0 0x19 |
#define AD463X_REG_OFFSET_X1_1 0x1A |
#define AD463X_REG_OFFSET_X1_2 0x1B |
#define AD463X_REG_OSCILATOR 0x21 |
#define AD463X_REG_PAT0 0x23 |
#define AD463X_REG_PAT1 0x24 |
#define AD463X_REG_PAT2 0x25 |
#define AD463X_REG_PAT3 0x26 |
#define AD463X_REG_PRODUCT_ID_H 0x05 |
#define AD463X_REG_PRODUCT_ID_L 0x04 |
#define AD463X_REG_READ NO_OS_BIT(7) |
#define AD463X_REG_READ_DUMMY 0x00 |
#define AD463X_REG_SCRATCH_PAD 0x0A |
#define AD463X_REG_SPI_REVISION 0x0B |
#define AD463X_REG_STREAM_MODE 0x0E |
#define AD463X_REG_VENDOR_H 0x0D |
#define AD463X_REG_VENDOR_L 0x0C |
#define AD463X_REG_WRITE 0x00 |
#define AD463X_SDR_MODE 0x00 |
#define AD463X_SPI_COMPATIBLE_MODE 0x00 |
#define AD463X_TRIGGER_PULSE_WIDTH_NS 0x0A |
#define AD463X_TWO_LANES_PER_CH NO_OS_BIT(6) |
enum ad463x_id |
Device type.
enum ad463x_pgia_gain |
int32_t ad463x_calc_pgia_gain | ( | int32_t | gain_int, |
int32_t | gain_fract, | ||
int32_t | vref, | ||
int32_t | precision, | ||
enum ad463x_pgia_gain * | gain_idx | ||
) |
Calculate the PGIA gain.
Calculate PGIA gain
gain_int | - Interger part of the gain. |
gain_fract | - Fractional part of the gain. |
vref | - Reference Voltage. |
precision | - Precision value shifter. |
gain_idx | - Index of gain resulting from the calculation. |
int32_t ad463x_enter_config_mode | ( | struct ad463x_dev * | dev | ) |
Enter register configuration mode.
Enter configuration Register mode
dev | - The device structure. |
int32_t ad463x_exit_reg_cfg_mode | ( | struct ad463x_dev * | dev | ) |
Exit register configuration mode.
Exit register configuration mode
dev | - The device structure. |
int32_t ad463x_init | ( | struct ad463x_dev ** | device, |
struct ad463x_init_param * | init_param | ||
) |
Initialize the device.
Device initialization
[out] | device | - The device structure. |
[in] | init_param | - The structure that contains the device initial parameters. |
Perform Hardware Reset and configure pins
int32_t ad463x_read_data | ( | struct ad463x_dev * | dev, |
uint32_t * | buf, | ||
uint16_t | samples | ||
) |
Read from device. Enter register mode to read/write registers.
Read data
dev | - ad469x_dev device handler. |
buf | - data buffer. |
samples | - sample number. |
int32_t ad463x_remove | ( | struct ad463x_dev * | dev | ) |
Free the memory allocated by ad463x_init().
Free resources
[in] | dev | - Pointer to the device handler. |
int32_t ad463x_set_avg_frame_len | ( | struct ad463x_dev * | dev, |
uint8_t | mode | ||
) |
Set average frame length.
Set average frame length
dev | - The device structure. |
mode | - Average filter frame length mode. |
int32_t ad463x_set_ch_gain | ( | struct ad463x_dev * | dev, |
uint8_t | ch_idx, | ||
uint64_t | gain | ||
) |
Set channel gain.
Set channel gain
dev | - The device structure. |
ch_idx | - The channel index. |
gain | - The gain value scaled by 10000. Example: to set gain 1.5, use 150000 |
int32_t ad463x_set_ch_offset | ( | struct ad463x_dev * | dev, |
uint8_t | ch_idx, | ||
uint32_t | offset | ||
) |
Set channel offset.
Set channel offset
dev | - The device structure. |
ch_idx | - The channel index. |
offset | - The channel offset. |
int32_t ad463x_set_drive_strength | ( | struct ad463x_dev * | dev, |
uint8_t | mode | ||
) |
Set drive strength.
Set drive strength
dev | - The device structure. |
mode | - The register data. |
int32_t ad463x_set_pgia_gain | ( | struct ad463x_dev * | dev, |
enum ad463x_pgia_gain | gain_idx | ||
) |
Set the PGIA gain.
Control PGIA gain
dev | - Pointer to the device handler. |
gain_idx | - Gain control index. |
Check if gain available in the ADC
Check if gain gain_idx is in the valid range
update gain index value in the device handler
Set A0 and A1 pins according to gain index value
int32_t ad463x_set_pwr_mode | ( | struct ad463x_dev * | dev, |
uint8_t | mode | ||
) |
Set power mode.
Set power mode
dev | - The device structure. |
mode | - The power mode. |
int32_t ad463x_spi_reg_read | ( | struct ad463x_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t * | reg_data | ||
) |
Read device register.
Read device register.
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The data read from the register. |
int32_t ad463x_spi_reg_read_masked | ( | struct ad463x_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t * | data | ||
) |
SPI read device register using a mask.
Read from device using a mask
dev | - The device structure. |
reg_addr | - The register address. |
mask | - The mask. |
data | - The data read from the register. |
int32_t ad463x_spi_reg_write | ( | struct ad463x_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t | reg_data | ||
) |
Write device register.
Write device register
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The register data. |
int32_t ad463x_spi_reg_write_masked | ( | struct ad463x_dev * | dev, |
uint16_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t | data | ||
) |
SPI write device register using a mask.
Write to device using a mask
dev | - The device structure. |
reg_addr | - The register address. |
mask | - The mask. |
data | - The register data. |