Go to the documentation of this file.
48 #define AD7799_REG_COMM 0x0
49 #define AD7799_REG_STAT 0x0
50 #define AD7799_REG_MODE 0x1
51 #define AD7799_REG_CONF 0x2
52 #define AD7799_REG_DATA 0x3
53 #define AD7799_REG_ID 0x4
54 #define AD7799_REG_IO 0x5
55 #define AD7799_REG_OFFSET 0x6
56 #define AD7799_REG_FULLSCALE 0x7
59 #define AD7799_BIPOLAR 0x0
60 #define AD7799_UNIPOLAR 0x1
63 #define AD7799_COMM_WEN 0x80
64 #define AD7799_COMM_WRITE 0x00
65 #define AD7799_COMM_READ 0x40
66 #define AD7799_COMM_ADDR(x) (((x) & 0x7) << 3)
67 #define AD7799_COMM_CREAD 0x04
70 #define AD7799_STAT_RDY 0x80
71 #define AD7799_STAT_ERR 0x40
72 #define AD7799_STAT_CH3 0x04
73 #define AD7799_STAT_CH2 (1 << 1)
74 #define AD7799_STAT_CH1 (1 << 0)
77 #define AD7799_MODE_SEL(x) (((x) & 0x7) << 13)
78 #define AD7799_MODE_PSW(x) 0x1000
79 #define AD7799_MODE_RATE(x) ((x) & 0xF)
82 #define AD7799_MODE_CONT 0x0
83 #define AD7799_MODE_SINGLE 0x1
84 #define AD7799_MODE_IDLE 0x2
85 #define AD7799_MODE_PWRDN 0x3
86 #define AD7799_MODE_CAL_INT_ZERO 0x4
87 #define AD7799_MODE_CAL_INT_FULL 0x5
88 #define AD7799_MODE_CAL_SYS_ZERO 0x6
89 #define AD7799_MODE_CAL_SYS_FULL 0x7
92 #define AD7799_CONF_BO_EN 0x2000
93 #define AD7799_CONF_POLARITY(x) (((x) & 0x1) << 12)
94 #define AD7799_CONF_GAIN(x) (((x) & 0x7) << 8)
95 #define AD7799_CONF_REFDET(x) (((x) & 0x1) << 5)
96 #define AD7799_CONF_BUF 0x10
97 #define AD7799_CONF_CHAN(x) ((x) & 0x7)
100 #define AD7799_GAIN_1 0x0
101 #define AD7799_GAIN_2 0x1
102 #define AD7799_GAIN_4 0x2
103 #define AD7799_GAIN_8 0x3
104 #define AD7799_GAIN_16 0x4
105 #define AD7799_GAIN_32 0x5
106 #define AD7799_GAIN_64 0x6
107 #define AD7799_GAIN_128 0x7
110 #define AD7799_REG_SIZE_1B 0x1
111 #define AD7799_REG_SIZE_2B 0x2
112 #define AD7799_REG_SIZE_3B 0x3
115 #define AD7799_REFDET_ENA 0x1
116 #define AD7799_REFDET_DIS 0x0
119 #define AD7799_CH_AIN1P_AIN1M 0x0
120 #define AD7799_CH_AIN2P_AIN2M 0x1
121 #define AD7799_CH_AIN3P_AIN3M 0x2
122 #define AD7799_CH_AIN1M_AIN1M 0x3
123 #define AD7799_CH_AVDD_MONITOR 0x7
126 #define AD7799_ID_MASK 0xF
129 #define AD7799_REG_MASK 0xF
132 #define AD7799_IOEN 0x40
133 #define AD7799_IO1(x) (((x) & 0x1) << 4)
134 #define AD7799_IO2(x) (((x) & 0x1) << 5)
137 #define AD7799_TIMEOUT 0xFFFF
140 #define AD7799_RESET_DATA 0xFF
227 int32_t *data_scaled);
int32_t ad7799_set_gain(struct ad7799_dev *device, uint8_t gain)
Set the ADC gain.
Definition: ad7799.c:277
ad7799_precision
Definition: ad7799.h:153
#define AD7799_COMM_ADDR(x)
Definition: ad7799.h:66
uint32_t timeout
Definition: ad413x.c:49
int32_t ad7799_init(struct ad7799_dev **device, const struct ad7799_init_param *init_param)
Initialize the device.
Definition: ad7799.c:391
uint8_t chip_type
Definition: ad7799.h:168
int32_t ad7799_set_mode(struct ad7799_dev *device, uint8_t mode)
Set the device mode.
Definition: ad7799.c:157
AD7798/AD7799 Device description.
Definition: ad7799.h:164
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
#define AD7799_REG_DATA
Definition: ad7799.h:52
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:239
#define AD7799_RESET_DATA
Definition: ad7799.h:140
#define AD7799_REG_FULLSCALE
Definition: ad7799.h:56
int32_t ad7799_get_channel(struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data)
Read specific ADC channel.
Definition: ad7799.c:208
struct no_os_spi_desc * spi_desc
Definition: ad7799.h:166
enum no_os_spi_mode mode
Definition: no_os_spi.h:148
Definition: ad9361_util.h:69
@ ID_AD7798
Definition: ad7799.h:148
const uint8_t * reg_size
Definition: ad7799.h:170
int32_t ad7799_get_gain(struct ad7799_dev *device, uint8_t *gain)
Get the ADC gain.
Definition: ad7799.c:298
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
int32_t ad7799_remove(struct ad7799_dev *device)
Remove the device and release resources.
Definition: ad7799.c:474
#define AD7799_REG_SIZE_1B
Definition: ad7799.h:110
#define AD7799_CONF_GAIN(x)
Definition: ad7799.h:94
int32_t ad7799_set_polarity(struct ad7799_dev *device, uint8_t polarity)
Set ADC polarity.
Definition: ad7799.c:343
enum ad7799_precision precision
Definition: ad7799.h:197
uint32_t vref_mv
Definition: ad7799.h:195
int32_t ad7799_set_mode(struct ad7799_dev *device, uint8_t mode)
Set the device mode.
Definition: ad7799.c:157
uint32_t vref_mv
Definition: ad7799.h:176
uint8_t gain
Definition: ad7799.h:191
#define AD7799_REG_COMM
Definition: ad7799.h:48
int32_t ad7799_set_polarity(struct ad7799_dev *device, uint8_t polarity)
Set ADC polarity.
Definition: ad7799.c:343
int32_t ad7799_read(struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ad7799.c:80
#define AD7799_REG_OFFSET
Definition: ad7799.h:55
int32_t ad7799_set_channel(struct ad7799_dev *device, uint8_t ch)
Select the ADC channel.
Definition: ad7799.c:186
#define AD7799_STAT_RDY
Definition: ad7799.h:70
int32_t ad7799_write(struct ad7799_dev *device, uint8_t reg_addr, uint32_t reg_data)
Write device register.
Definition: ad7799.c:113
#define AD7799_COMM_READ
Definition: ad7799.h:65
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:113
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
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:364
int32_t ad7799_init(struct ad7799_dev **device, const struct ad7799_init_param *init_param)
Initialize the device.
Definition: ad7799.c:391
@ AD7799_PRECISION_UV
Definition: ad7799.h:157
#define AD7799_MODE_SINGLE
Definition: ad7799.h:83
bool polarity
Definition: ad7799.h:193
#define AD7799_ID_MASK
Definition: ad7799.h:126
#define AD7799_COMM_WRITE
Definition: ad7799.h:64
int32_t ad7799_set_refdet(struct ad7799_dev *device, uint8_t ref_en)
Enable or disable the reference detect function.
Definition: ad7799.c:320
#define AD7799_REG_IO
Definition: ad7799.h:54
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:239
#define AD7799_CONF_POLARITY(x)
Definition: ad7799.h:93
#define AD7799_REG_CONF
Definition: ad7799.h:51
#define AD7799_REG_SIZE_2B
Definition: ad7799.h:111
enum ad7799_precision precision
Definition: ad7799.h:178
int32_t ad7799_get_channel(struct ad7799_dev *device, uint8_t ch, uint32_t *reg_data)
Read specific ADC channel.
Definition: ad7799.c:208
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
struct no_os_spi_init_param spi_init
Definition: ad7799.h:187
#define AD7799_REG_MASK
Definition: ad7799.h:129
uint8_t gain
Definition: ad7799.h:172
int32_t ad7799_get_gain(struct ad7799_dev *device, uint8_t *gain)
Get the ADC gain.
Definition: ad7799.c:298
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int32_t ad7799_set_refdet(struct ad7799_dev *device, uint8_t ref_en)
Enable or disable the reference detect function.
Definition: ad7799.c:320
bool polarity
Definition: ad7799.h:174
int32_t ad7799_reset(struct ad7799_dev *device)
Software reset of the device.
Definition: ad7799.c:139
int32_t ad7799_remove(struct ad7799_dev *device)
Remove the device and release resources.
Definition: ad7799.c:474
#define AD7799_REG_SIZE_3B
Definition: ad7799.h:112
#define AD7799_TIMEOUT
Definition: ad7799.h:137
#define AD7799_MODE_SEL(x)
Definition: ad7799.h:77
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
ad7799_type
Device type (AD7798/AD7799)
Definition: ad7799.h:146
enum ad7799_type chip_type
Definition: ad7799.h:189
#define AD7799_REG_ID
Definition: ad7799.h:53
#define AD7799_CONF_REFDET(x)
Definition: ad7799.h:95
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
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:364
#define AD7799_REG_STAT
Definition: ad7799.h:49
#define AD7799_CONF_CHAN(x)
Definition: ad7799.h:97
AD7798/AD7799 Device initialization parameters.
Definition: ad7799.h:185
int32_t ad7799_reset(struct ad7799_dev *device)
Software reset of the device.
Definition: ad7799.c:139
@ AD7799_PRECISION_MV
Definition: ad7799.h:155
#define AD7799_REG_MODE
Definition: ad7799.h:50
int32_t ad7799_set_gain(struct ad7799_dev *device, uint8_t gain)
Set the ADC gain.
Definition: ad7799.c:277
int32_t ad7799_read(struct ad7799_dev *device, uint8_t reg_addr, uint32_t *reg_data)
Read device register.
Definition: ad7799.c:80
int32_t ad7799_set_channel(struct ad7799_dev *device, uint8_t ch)
Select the ADC channel.
Definition: ad7799.c:186
chip_id
Definition: ad9172.h:51
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
@ ID_AD7799
Definition: ad7799.h:150