Go to the documentation of this file.
54 #define AD7799_REG_COMM 0x0
55 #define AD7799_REG_STAT 0x0
56 #define AD7799_REG_MODE 0x1
57 #define AD7799_REG_CONF 0x2
58 #define AD7799_REG_DATA 0x3
59 #define AD7799_REG_ID 0x4
60 #define AD7799_REG_IO 0x5
61 #define AD7799_REG_OFFSET 0x6
62 #define AD7799_REG_FULLSCALE 0x7
65 #define AD7799_BIPOLAR 0x0
66 #define AD7799_UNIPOLAR 0x1
69 #define AD7799_COMM_WEN 0x80
70 #define AD7799_COMM_WRITE 0x00
71 #define AD7799_COMM_READ 0x40
72 #define AD7799_COMM_ADDR(x) (((x) & 0x7) << 3)
73 #define AD7799_COMM_CREAD 0x04
76 #define AD7799_STAT_RDY 0x80
77 #define AD7799_STAT_ERR 0x40
78 #define AD7799_STAT_CH3 0x04
79 #define AD7799_STAT_CH2 (1 << 1)
80 #define AD7799_STAT_CH1 (1 << 0)
83 #define AD7799_MODE_SEL(x) (((x) & 0x7) << 13)
84 #define AD7799_MODE_PSW(x) 0x1000
85 #define AD7799_MODE_RATE(x) ((x) & 0xF)
88 #define AD7799_MODE_CONT 0x0
89 #define AD7799_MODE_SINGLE 0x1
90 #define AD7799_MODE_IDLE 0x2
91 #define AD7799_MODE_PWRDN 0x3
92 #define AD7799_MODE_CAL_INT_ZERO 0x4
93 #define AD7799_MODE_CAL_INT_FULL 0x5
94 #define AD7799_MODE_CAL_SYS_ZERO 0x6
95 #define AD7799_MODE_CAL_SYS_FULL 0x7
98 #define AD7799_CONF_BO_EN 0x2000
99 #define AD7799_CONF_POLARITY(x) (((x) & 0x1) << 12)
100 #define AD7799_CONF_GAIN(x) (((x) & 0x7) << 8)
101 #define AD7799_CONF_REFDET(x) (((x) & 0x1) << 5)
102 #define AD7799_CONF_BUF 0x10
103 #define AD7799_CONF_CHAN(x) ((x) & 0x7)
106 #define AD7799_GAIN_1 0x0
107 #define AD7799_GAIN_2 0x1
108 #define AD7799_GAIN_4 0x2
109 #define AD7799_GAIN_8 0x3
110 #define AD7799_GAIN_16 0x4
111 #define AD7799_GAIN_32 0x5
112 #define AD7799_GAIN_64 0x6
113 #define AD7799_GAIN_128 0x7
116 #define AD7799_REG_SIZE_1B 0x1
117 #define AD7799_REG_SIZE_2B 0x2
118 #define AD7799_REG_SIZE_3B 0x3
121 #define AD7799_REFDET_ENA 0x1
122 #define AD7799_REFDET_DIS 0x0
125 #define AD7799_CH_AIN1P_AIN1M 0x0
126 #define AD7799_CH_AIN2P_AIN2M 0x1
127 #define AD7799_CH_AIN3P_AIN3M 0x2
128 #define AD7799_CH_AIN1M_AIN1M 0x3
129 #define AD7799_CH_AVDD_MONITOR 0x7
132 #define AD7799_ID_MASK 0xF
135 #define AD7799_REG_MASK 0xF
138 #define AD7799_IOEN 0x40
139 #define AD7799_IO1(x) (((x) & 0x1) << 4)
140 #define AD7799_IO2(x) (((x) & 0x1) << 5)
143 #define AD7799_TIMEOUT 0xFFFF
146 #define AD7799_RESET_DATA 0xFF
233 int32_t *data_scaled);
int32_t ad7799_set_gain(struct ad7799_dev *device, uint8_t gain)
Set the ADC gain.
Definition: ad7799.c:283
ad7799_precision
Definition: ad7799.h:159
#define AD7799_COMM_ADDR(x)
Definition: ad7799.h:72
uint32_t timeout
Definition: ad413x.c:55
int32_t ad7799_init(struct ad7799_dev **device, const struct ad7799_init_param *init_param)
Initialize the device.
Definition: ad7799.c:397
uint8_t chip_type
Definition: ad7799.h:174
int32_t ad7799_set_mode(struct ad7799_dev *device, uint8_t mode)
Set the device mode.
Definition: ad7799.c:163
AD7798/AD7799 Device description.
Definition: ad7799.h:170
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:95
#define AD7799_REG_DATA
Definition: ad7799.h:58
Header file of SPI Interface.
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:245
#define AD7799_RESET_DATA
Definition: ad7799.h:146
#define AD7799_REG_FULLSCALE
Definition: ad7799.h:62
int32_t ad7799_get_channel(struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data)
Read specific ADC channel.
Definition: ad7799.c:214
struct no_os_spi_desc * spi_desc
Definition: ad7799.h:172
enum no_os_spi_mode mode
Definition: no_os_spi.h:129
Definition: ad9361_util.h:75
@ ID_AD7798
Definition: ad7799.h:154
const uint8_t * reg_size
Definition: ad7799.h:176
int32_t ad7799_get_gain(struct ad7799_dev *device, uint8_t *gain)
Get the ADC gain.
Definition: ad7799.c:304
void * no_os_calloc(size_t nitems, size_t size)
int32_t ad7799_remove(struct ad7799_dev *device)
Remove the device and release resources.
Definition: ad7799.c:480
#define AD7799_REG_SIZE_1B
Definition: ad7799.h:116
#define AD7799_CONF_GAIN(x)
Definition: ad7799.h:100
int32_t ad7799_set_polarity(struct ad7799_dev *device, uint8_t polarity)
Set ADC polarity.
Definition: ad7799.c:349
enum ad7799_precision precision
Definition: ad7799.h:203
uint32_t vref_mv
Definition: ad7799.h:201
int32_t ad7799_set_mode(struct ad7799_dev *device, uint8_t mode)
Set the device mode.
Definition: ad7799.c:163
uint32_t vref_mv
Definition: ad7799.h:182
uint8_t gain
Definition: ad7799.h:197
#define AD7799_REG_COMM
Definition: ad7799.h:54
int32_t ad7799_set_polarity(struct ad7799_dev *device, uint8_t polarity)
Set ADC polarity.
Definition: ad7799.c:349
int32_t ad7799_read(struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ad7799.c:86
#define AD7799_REG_OFFSET
Definition: ad7799.h:61
int32_t ad7799_set_channel(struct ad7799_dev *device, uint8_t ch)
Select the ADC channel.
Definition: ad7799.c:192
#define AD7799_STAT_RDY
Definition: ad7799.h:76
int32_t ad7799_write(struct ad7799_dev *device, uint8_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ad7799.c:119
#define AD7799_COMM_READ
Definition: ad7799.h:71
Header file of AD7798/AD7799 Driver.
int32_t ad7799_write(struct ad7799_dev *device, uint8_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ad7799.c:119
Structure holding SPI descriptor.
Definition: no_os_spi.h:143
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:370
int32_t ad7799_init(struct ad7799_dev **device, const struct ad7799_init_param *init_param)
Initialize the device.
Definition: ad7799.c:397
@ AD7799_PRECISION_UV
Definition: ad7799.h:163
#define AD7799_MODE_SINGLE
Definition: ad7799.h:89
bool polarity
Definition: ad7799.h:199
#define AD7799_ID_MASK
Definition: ad7799.h:132
#define AD7799_COMM_WRITE
Definition: ad7799.h:70
int32_t ad7799_set_refdet(struct ad7799_dev *device, uint8_t ref_en)
Enable or disable the reference detect function.
Definition: ad7799.c:326
#define AD7799_REG_IO
Definition: ad7799.h:60
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:245
#define AD7799_CONF_POLARITY(x)
Definition: ad7799.h:99
#define AD7799_REG_CONF
Definition: ad7799.h:57
#define AD7799_REG_SIZE_2B
Definition: ad7799.h:117
enum ad7799_precision precision
Definition: ad7799.h:184
int32_t ad7799_get_channel(struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data)
Read specific ADC channel.
Definition: ad7799.c:214
void no_os_free(void *ptr)
struct no_os_spi_init_param spi_init
Definition: ad7799.h:193
#define AD7799_REG_MASK
Definition: ad7799.h:135
uint8_t gain
Definition: ad7799.h:178
int32_t ad7799_get_gain(struct ad7799_dev *device, uint8_t *gain)
Get the ADC gain.
Definition: ad7799.c:304
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
int32_t ad7799_set_refdet(struct ad7799_dev *device, uint8_t ref_en)
Enable or disable the reference detect function.
Definition: ad7799.c:326
bool polarity
Definition: ad7799.h:180
int32_t ad7799_reset(struct ad7799_dev *device)
Software reset of the device.
Definition: ad7799.c:145
int32_t ad7799_remove(struct ad7799_dev *device)
Remove the device and release resources.
Definition: ad7799.c:480
#define AD7799_REG_SIZE_3B
Definition: ad7799.h:118
#define AD7799_TIMEOUT
Definition: ad7799.h:143
#define AD7799_MODE_SEL(x)
Definition: ad7799.h:83
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:77
ad7799_type
Device type (AD7798/AD7799)
Definition: ad7799.h:152
enum ad7799_type chip_type
Definition: ad7799.h:195
#define AD7799_REG_ID
Definition: ad7799.h:59
#define AD7799_CONF_REFDET(x)
Definition: ad7799.h:101
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:51
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:370
#define AD7799_REG_STAT
Definition: ad7799.h:55
#define AD7799_CONF_CHAN(x)
Definition: ad7799.h:103
AD7798/AD7799 Device initialization parameters.
Definition: ad7799.h:191
int32_t ad7799_reset(struct ad7799_dev *device)
Software reset of the device.
Definition: ad7799.c:145
@ AD7799_PRECISION_MV
Definition: ad7799.h:161
#define AD7799_REG_MODE
Definition: ad7799.h:56
int32_t ad7799_set_gain(struct ad7799_dev *device, uint8_t gain)
Set the ADC gain.
Definition: ad7799.c:283
int32_t ad7799_read(struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ad7799.c:86
int32_t ad7799_set_channel(struct ad7799_dev *device, uint8_t ch)
Select the ADC channel.
Definition: ad7799.c:192
chip_id
Definition: ad9172.h:57
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:121
@ ID_AD7799
Definition: ad7799.h:156