41#define AD7799_REG_COMM 0x0
42#define AD7799_REG_STAT 0x0
43#define AD7799_REG_MODE 0x1
44#define AD7799_REG_CONF 0x2
45#define AD7799_REG_DATA 0x3
46#define AD7799_REG_ID 0x4
47#define AD7799_REG_IO 0x5
48#define AD7799_REG_OFFSET 0x6
49#define AD7799_REG_FULLSCALE 0x7
52#define AD7799_BIPOLAR 0x0
53#define AD7799_UNIPOLAR 0x1
56#define AD7799_COMM_WEN 0x80
57#define AD7799_COMM_WRITE 0x00
58#define AD7799_COMM_READ 0x40
59#define AD7799_COMM_ADDR(x) (((x) & 0x7) << 3)
60#define AD7799_COMM_CREAD 0x04
63#define AD7799_STAT_RDY 0x80
64#define AD7799_STAT_ERR 0x40
65#define AD7799_STAT_CH3 0x04
66#define AD7799_STAT_CH2 (1 << 1)
67#define AD7799_STAT_CH1 (1 << 0)
70#define AD7799_MODE_SEL(x) (((x) & 0x7) << 13)
71#define AD7799_MODE_PSW(x) 0x1000
72#define AD7799_MODE_RATE(x) ((x) & 0xF)
75#define AD7799_MODE_CONT 0x0
76#define AD7799_MODE_SINGLE 0x1
77#define AD7799_MODE_IDLE 0x2
78#define AD7799_MODE_PWRDN 0x3
79#define AD7799_MODE_CAL_INT_ZERO 0x4
80#define AD7799_MODE_CAL_INT_FULL 0x5
81#define AD7799_MODE_CAL_SYS_ZERO 0x6
82#define AD7799_MODE_CAL_SYS_FULL 0x7
85#define AD7799_CONF_BO_EN 0x2000
86#define AD7799_CONF_POLARITY(x) (((x) & 0x1) << 12)
87#define AD7799_CONF_GAIN(x) (((x) & 0x7) << 8)
88#define AD7799_CONF_REFDET(x) (((x) & 0x1) << 5)
89#define AD7799_CONF_BUF 0x10
90#define AD7799_CONF_CHAN(x) ((x) & 0x7)
93#define AD7799_GAIN_1 0x0
94#define AD7799_GAIN_2 0x1
95#define AD7799_GAIN_4 0x2
96#define AD7799_GAIN_8 0x3
97#define AD7799_GAIN_16 0x4
98#define AD7799_GAIN_32 0x5
99#define AD7799_GAIN_64 0x6
100#define AD7799_GAIN_128 0x7
103#define AD7799_REG_SIZE_1B 0x1
104#define AD7799_REG_SIZE_2B 0x2
105#define AD7799_REG_SIZE_3B 0x3
108#define AD7799_REFDET_ENA 0x1
109#define AD7799_REFDET_DIS 0x0
112#define AD7799_CH_AIN1P_AIN1M 0x0
113#define AD7799_CH_AIN2P_AIN2M 0x1
114#define AD7799_CH_AIN3P_AIN3M 0x2
115#define AD7799_CH_AIN1M_AIN1M 0x3
116#define AD7799_CH_AVDD_MONITOR 0x7
119#define AD7799_ID_MASK 0xF
122#define AD7799_REG_MASK 0xF
125#define AD7799_IOEN 0x40
126#define AD7799_IO1(x) (((x) & 0x1) << 4)
127#define AD7799_IO2(x) (((x) & 0x1) << 5)
130#define AD7799_TIMEOUT 0xFFFF
133#define AD7799_RESET_DATA 0xFF
216 int32_t *data_scaled);
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int32_t ad7799_get_channel(struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data)
Read specific ADC channel.
Definition ad7799.c:198
int32_t ad7799_set_channel(struct ad7799_dev *device, uint8_t ch)
Select the ADC channel.
Definition ad7799.c:176
ad7799_precision
Definition ad7799.h:146
@ AD7799_PRECISION_MV
Definition ad7799.h:148
@ AD7799_PRECISION_UV
Definition ad7799.h:150
int32_t ad7799_dev_ready(struct ad7799_dev *device)
Read the /RDY bit of status register and check the status of the device.
Definition ad7799.c:354
int32_t ad7799_init(struct ad7799_dev **device, const struct ad7799_init_param *init_param)
Initialize the device.
Definition ad7799.c:381
int32_t ad7799_reset(struct ad7799_dev *device)
Software reset of the device.
Definition ad7799.c:129
int32_t ad7799_set_mode(struct ad7799_dev *device, uint8_t mode)
Set the device mode.
Definition ad7799.c:147
ad7799_type
Device type (AD7798/AD7799)
Definition ad7799.h:139
@ ID_AD7799
Definition ad7799.h:143
@ ID_AD7798
Definition ad7799.h:141
int32_t ad7799_write(struct ad7799_dev *device, uint8_t reg_addr, uint32_t reg_data)
Write device register.
Definition ad7799.c:103
int32_t ad7799_set_gain(struct ad7799_dev *device, uint8_t gain)
Set the ADC gain.
Definition ad7799.c:267
int32_t ad7799_set_refdet(struct ad7799_dev *device, uint8_t ref_en)
Enable or disable the reference detect function.
Definition ad7799.c:310
int32_t ad7799_read_channel(struct ad7799_dev *device, uint8_t ch, int32_t *data_scaled)
Read data from specific ADC channel with specified precision.
Definition ad7799.c:229
int32_t ad7799_set_polarity(struct ad7799_dev *device, uint8_t polarity)
Set ADC polarity.
Definition ad7799.c:333
int32_t ad7799_get_gain(struct ad7799_dev *device, uint8_t *gain)
Get the ADC gain.
Definition ad7799.c:288
int32_t ad7799_remove(struct ad7799_dev *device)
Remove the device and release resources.
Definition ad7799.c:464
int32_t ad7799_read(struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition ad7799.c:70
Header file of SPI Interface.
AD7798/AD7799 Device description.
Definition ad7799.h:157
enum ad7799_precision precision
Definition ad7799.h:171
bool polarity
Definition ad7799.h:167
const uint8_t * reg_size
Definition ad7799.h:163
struct no_os_spi_desc * spi_desc
Definition ad7799.h:159
uint8_t chip_type
Definition ad7799.h:161
uint32_t vref_mv
Definition ad7799.h:169
uint8_t gain
Definition ad7799.h:165
AD7798/AD7799 Device initialization parameters.
Definition ad7799.h:178
struct no_os_spi_init_param spi_init
Definition ad7799.h:180
bool polarity
Definition ad7799.h:186
uint32_t vref_mv
Definition ad7799.h:188
enum ad7799_precision precision
Definition ad7799.h:190
enum ad7799_type chip_type
Definition ad7799.h:182
uint8_t gain
Definition ad7799.h:184
Definition ad9361_util.h:63
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128
enum no_os_spi_mode mode
Definition no_os_spi.h:136