no-OS
Loading...
Searching...
No Matches
ad4692.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef _AD4692_H_
34#define _AD4692_H_
35
36#include <stdbool.h>
37#include "no_os_util.h"
38#include "no_os_pwm.h"
39#include "no_os_spi.h"
40#include "no_os_gpio.h"
41#include "no_os_irq.h"
42
43#define AD4692_FRAME_SIZE 6
44
45#define AD4692_CONV_START_MASK NO_OS_BIT(0)
46#define AD4692_CHANNEL_MASK(n) NO_OS_BIT(n)
47#define AD4692_MAX_CHANNELS 16
48
49#define AD4692_DEFAULT_OSC_FREQ 1000000
50#define AD4692_CNV_DUTY_CYCLE_NS 210
51
52#define AD4692_VREF_MIN 2400000
53#define AD4692_VREF_2P75 2750000
54#define AD4692_VREF_3P25 3250000
55#define AD4692_VREF_3P75 3750000
56#define AD4692_VREF_4P50 4500000
57#define AD4692_VREF_MAX 5250000
58
59#define AD4692_REF_VOLTAGE_2P75 0x00
60#define AD4692_REF_VOLTAGE_3P25 0x04
61#define AD4692_REF_VOLTAGE_3P75 0x08
62#define AD4692_REF_VOLTAGE_4P50 0x0C
63#define AD4692_REF_VOLTAGE_5 0x10
64
65#define AD4692_INTERFACE_CONFIG_A_REG 0x00
66#define AD4692_INTERFACE_STATUS_A_REG 0x11
67#define AD4692_REG_ACCESS_ERR_MASK NO_OS_BIT(1)
68#define AD4692_PRODUCT_ID_LSB_REG 0x04
69#define AD4692_PRODUCTID_HIGH_REG 0x05
70#define AD4692_CLEAR_IA_STATUS 0x8F
71
72#define AD4692_STATUS_REG 0x14
73#define AD4692_CLAMP_STATUS1_REG 0x1A
74#define AD4692_CLAMP_STATUS2_REG 0x1B
75#define AD4692_DEVICE_SETUP_REG 0x20
76#define AD4692_REF_CTRL_REG 0x21
77#define AD4692_SEQUENCER_CONTROL_REG 0x22
78#define AD4692_OSC_FREQ_REG 0x23
79#define AD4692_STD_SEQ_CONFIG_REG 0x25
80#define AD4692_SPARE_CONTROL_REG 0x2A
81#define AD4692_CHANNEL_CONFIG_REG(n) (0x30 + (n))
82
83#define AD4692_OSC_EN_REG 0x180
84#define AD4692_STATE_RESET_REG 0x181
85#define AD4692_ADC_SETUP_REG 0x182
86#define AD4692_ACC_MASK1_REG 0x184
87#define AD4692_ACC_MASK2_REG 0x185
88#define AD4692_ACC_COUNT_LIMIT_REG(n) (0x186 + (n))
89#define AD4692_GPIO_MODE1_REG 0x196
90#define AD4692_GPIO_MODE2_REG 0x197
91#define AD4692_GPIO_READ_REG 0x1A0
92#define AD4692_ACC_STATUS_FULL1_REG 0x1B0
93#define AD4692_ACC_STATUS_FULL2_REG 0x1B1
94#define AD4692_ACC_STATUS_OVERRUN1_REG 0x1B2
95#define AD4692_ACC_STATUS_OVERRUN2_REG 0x1B3
96#define AD4692_ACC_STATUS_SAT1_REG 0x1B4
97#define AD4692_ACC_STATUS_SAT2_REG 0x1BE
98#define AD4692_ACC_SAT_OVR_REG(n) (0x1C0 + (n))
99#define AD4692_AVG_IN_REG(n) (0x201 + 2 * (n))
100#define AD4692_AVG_STS_IN_REG(n) (0x222 + 3 * (n))
101#define AD4692_ACC_IN_REG(n) (0x252 + 3 * (n))
102#define AD4692_ACC_STS_DATA_REG(n) (0x283 + 4 * (n))
103
104#define AD4692_RW_ADDR_MASK NO_OS_BIT(7)
105#define AD4692_MSB_MASK(n) ((n) >> 8)
106#define AD4692_LSB_MASK(n) ((n) & 0xFF)
107
108#define AD4692_SW_RST_MASK (NO_OS_BIT(7) | NO_OS_BIT(0))
109
110#define AD4692_MANUAL_MODE_MASK NO_OS_BIT(2)
111#define AD4692_MANUAL_DATA_MASK NO_OS_GENMASK(23, 8)
112#define AD4692_MODE_MASK NO_OS_GENMASK(1, 0)
113
114#define AD4692_16B_MASK NO_OS_GENMASK(15, 0)
115#define AD4692_24B_MASK NO_OS_GENMASK(23, 0)
116
117#define AD4692_STANDARD_SEQ_MODE 0x80
118#define AD4692_ADV_SEQ_MODE_MASK NO_OS_GENMASK(6, 0)
119
120#define AD4692_OSC_FREQ_MASK NO_OS_GENMASK(3, 0)
121#define AD4692_REF_CTRL_MASK NO_OS_GENMASK(4, 2)
122
123#define AD4692_GPIO0_MASK NO_OS_GENMASK(3, 0)
124#define AD4692_GPIO1_MASK NO_OS_GENMASK(7, 4)
125#define AD4692_GPIO2_MASK NO_OS_GENMASK(3, 0)
126#define AD4692_GPIO3_MASK NO_OS_GENMASK(7, 4)
127#define AD4692_GP_READ_MASK(n) NO_OS_BIT(n)
128
129#define AD4692_SEQ_ALL_CHANNELS_OFF 0x00
130#define AD4692_STATE_RESET_ALL 0x01
131
132#define AD4692_MAX_CONV_PERIOD_US 800
133
134#define AD4692_DEVICE_MANUAL 0x14
135
136#define AD4692_IN_VAL_MASK(n) NO_OS_GENMASK(23, 24 - (n))
137
138#define AD4692_NOOP 0x00
139#define AD4692_EXIT_COMMAND (0x0A << 3)
140#define AD4692_TEMPERATURE_SENSOR (0x0F << 3)
141#define AD4692_IN_COMMAND(n) ((0x10 + (n)) << 3)
142
150
169
177
189
196
203
204extern const int ad4692_int_osc_val[16];
205
223
244
245int ad4692_cnv_burst_period_ns(struct ad4692_desc *desc, int n_active,
246 uint32_t *period_ns);
247
248int ad4692_send_command(struct ad4692_desc *desc, uint32_t command,
249 uint32_t *val);
250
251int ad4692_reg_read(struct ad4692_desc *desc, uint32_t reg, uint32_t *val);
252
253int ad4692_reg_write(struct ad4692_desc *desc, uint32_t reg, uint32_t val);
254
255int ad4692_reg_update(struct ad4692_desc *desc, uint32_t reg, uint32_t mask,
256 uint32_t val);
257
258int ad4692_std_seq_ch(struct ad4692_desc *desc, uint16_t ch_mask, bool std,
259 uint8_t len);
260
261int ad4692_sampling_enable(struct ad4692_desc *desc, bool enable);
262
263int ad4692_get_ch(struct ad4692_desc *desc, uint8_t ch, uint32_t *val);
264
265int ad4692_get_temp(struct ad4692_desc *desc, uint32_t *val);
266
267int ad4692_set_osc(struct ad4692_desc *desc, enum ad4692_int_osc_sel osc);
268
269int ad4692_get_osc(struct ad4692_desc *desc, enum ad4692_int_osc_sel *osc);
270
271int ad4692_set_ref(struct ad4692_desc *desc, enum ad4692_ref_ctrl_sel ref);
272
273int ad4692_get_ref(struct ad4692_desc *desc, enum ad4692_ref_ctrl_sel *ref);
274
275int ad4692_gpio_set(struct ad4692_desc *desc, enum ad4692_gpio_num index,
276 enum ad4692_gpio_sel mode);
277
278int ad4692_gpio_get_value(struct ad4692_desc *desc, enum ad4692_gpio_num index,
279 enum no_os_gpio_values *value);
280
281int ad4692_hardware_reset(struct ad4692_desc *desc);
282
283int ad4692_software_reset(struct ad4692_desc *desc);
284
285int ad4692_init(struct ad4692_desc **desc,
287
288int ad4692_remove(struct ad4692_desc *desc);
289
290#endif /* _AD4692_H_ */
const int ad4692_int_osc_val[16]
Definition ad4692.c:44
#define AD4692_FRAME_SIZE
Definition ad4692.h:43
ad4692_ref_ctrl_sel
Definition ad4692.h:143
@ AD4692_VREF2P5
Definition ad4692.h:144
@ AD4692_VREF3P0
Definition ad4692.h:145
@ AD4692_VREF4P096
Definition ad4692.h:147
@ AD4692_VREF3P3
Definition ad4692.h:146
@ AD4692_VREF5P0
Definition ad4692.h:148
int ad4692_gpio_get_value(struct ad4692_desc *desc, enum ad4692_gpio_num index, enum no_os_gpio_values *value)
Definition ad4692.c:542
int ad4692_software_reset(struct ad4692_desc *desc)
Definition ad4692.c:594
int ad4692_init(struct ad4692_desc **desc, struct ad4692_init_param *init_param)
Definition ad4692.c:691
int ad4692_get_osc(struct ad4692_desc *desc, enum ad4692_int_osc_sel *osc)
Definition ad4692.c:481
ad4692_gpio_sel
Definition ad4692.h:178
@ AD4692_GPIO_OUTPUT_ADC_BUSY
Definition ad4692.h:183
@ AD4692_GPIO_INPUT
Definition ad4692.h:182
@ AD4692_GPIO_OUTPUT_LOW
Definition ad4692.h:180
@ AD4692_GPIO_OUTPUT_ACC_OVF_ERR
Definition ad4692.h:186
@ AD4692_GPIO_HIGHZ
Definition ad4692.h:179
@ AD4692_GPIO_OUTPUT_DATA_READYb
Definition ad4692.h:185
@ AD4692_GPIO_OUTPUT_SEQ_DONEb
Definition ad4692.h:184
@ AD4692_GPIO_OUTPUT_HIGH
Definition ad4692.h:181
@ AD4692_GPIO_OUTPUT_ACC_SAT_ERR
Definition ad4692.h:187
int ad4692_reg_write(struct ad4692_desc *desc, uint32_t reg, uint32_t val)
Definition ad4692.c:295
ad4692_gpio_num
Definition ad4692.h:190
@ AD4692_GPIO3
Definition ad4692.h:194
@ AD4692_GPIO1
Definition ad4692.h:192
@ AD4692_GPIO2
Definition ad4692.h:193
@ AD4692_GPIO0
Definition ad4692.h:191
int ad4692_std_seq_ch(struct ad4692_desc *desc, uint16_t ch_mask, bool std, uint8_t len)
Definition ad4692.c:351
int ad4692_set_osc(struct ad4692_desc *desc, enum ad4692_int_osc_sel osc)
Definition ad4692.c:474
int ad4692_sampling_enable(struct ad4692_desc *desc, bool enable)
Definition ad4692.c:369
int ad4692_send_command(struct ad4692_desc *desc, uint32_t command, uint32_t *val)
Definition ad4692.c:199
int ad4692_set_ref(struct ad4692_desc *desc, enum ad4692_ref_ctrl_sel ref)
Definition ad4692.c:495
int ad4692_get_temp(struct ad4692_desc *desc, uint32_t *val)
Definition ad4692.c:457
int ad4692_remove(struct ad4692_desc *desc)
Definition ad4692.c:784
ad4692_int_osc_sel
Definition ad4692.h:151
@ AD4692_OSC_500KHZ
Definition ad4692.h:153
@ AD4692_OSC_167KHZ
Definition ad4692.h:157
@ AD4692_OSC_25KHZ
Definition ad4692.h:162
@ AD4692_OSC_10KHZ
Definition ad4692.h:164
@ AD4692_OSC_2P5KHZ
Definition ad4692.h:166
@ AD4692_OSC_250KHZ
Definition ad4692.h:155
@ AD4692_OSC_125KHZ
Definition ad4692.h:159
@ AD4692_OSC_200KHZ
Definition ad4692.h:156
@ AD4692_OSC_400KHZ
Definition ad4692.h:154
@ AD4692_OSC_12P5KHZ
Definition ad4692.h:163
@ AD4692_OSC_1P25KHZ
Definition ad4692.h:167
@ AD4692_OSC_50KHZ
Definition ad4692.h:161
@ AD4692_OSC_133KHZ
Definition ad4692.h:158
@ AD4692_OSC_5KHZ
Definition ad4692.h:165
@ AD4692_OSC_1MHZ
Definition ad4692.h:152
@ AD4692_OSC_100KHZ
Definition ad4692.h:160
int ad4692_reg_read(struct ad4692_desc *desc, uint32_t reg, uint32_t *val)
Definition ad4692.c:225
int ad4692_hardware_reset(struct ad4692_desc *desc)
Definition ad4692.c:569
int ad4692_cnv_burst_period_ns(struct ad4692_desc *desc, int n_active, uint32_t *period_ns)
Definition ad4692.c:608
ad4692_spi_mode
Definition ad4692.h:170
@ AD4692_MANUAL_MODE
Definition ad4692.h:175
@ AD4692_CNV_CLOCK
Definition ad4692.h:171
@ AD4692_AUTONOMOUS
Definition ad4692.h:173
@ AD4692_CNV_BURST
Definition ad4692.h:172
@ AD4692_SPI_BURST
Definition ad4692.h:174
int ad4692_get_ref(struct ad4692_desc *desc, enum ad4692_ref_ctrl_sel *ref)
Definition ad4692.c:503
ad4692_type
Definition ad4692.h:197
@ ID_AD4694
Definition ad4692.h:200
@ ID_AD4691
Definition ad4692.h:199
@ ID_AD4693
Definition ad4692.h:201
@ ID_AD4692
Definition ad4692.h:198
int ad4692_reg_update(struct ad4692_desc *desc, uint32_t reg, uint32_t mask, uint32_t val)
Definition ad4692.c:335
int ad4692_gpio_set(struct ad4692_desc *desc, enum ad4692_gpio_num index, enum ad4692_gpio_sel mode)
Definition ad4692.c:517
int ad4692_get_ch(struct ad4692_desc *desc, uint8_t ch, uint32_t *val)
Definition ad4692.c:387
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of GPIO Interface.
no_os_gpio_values
Enum that holds the possible output states of a GPIO.
Definition no_os_gpio.h:101
Header file of IRQ interface.
Header file of PWM Interface.
Header file of SPI Interface.
Header file of utility functions.
Definition ad4692.h:224
uint32_t vref
Definition ad4692.h:240
enum ad4692_type id
Definition ad4692.h:242
uint8_t buff[AD4692_FRAME_SIZE+1]
Definition ad4692.h:237
struct no_os_gpio_desc * gpio1_desc
Definition ad4692.h:230
struct no_os_spi_desc * comm_desc
Definition ad4692.h:225
uint8_t num_channels
Definition ad4692.h:241
struct no_os_gpio_desc * gpio2_desc
Definition ad4692.h:231
struct no_os_pwm_desc * conv_desc
Definition ad4692.h:234
int max_rate
Definition ad4692.h:239
struct no_os_gpio_desc * gpio0_desc
Definition ad4692.h:229
struct no_os_gpio_desc * gpio3_desc
Definition ad4692.h:232
enum ad4692_spi_mode mode
Definition ad4692.h:236
struct no_os_gpio_desc * reset_desc
Definition ad4692.h:227
Definition ad4692.h:206
struct no_os_pwm_init_param * conv_param
Definition ad4692.h:216
struct no_os_gpio_init_param * gpio1_param
Definition ad4692.h:212
uint32_t vref
Definition ad4692.h:218
struct no_os_gpio_init_param * gpio0_param
Definition ad4692.h:211
struct no_os_gpio_init_param * gpio3_param
Definition ad4692.h:214
struct no_os_spi_init_param * comm_param
Definition ad4692.h:207
enum ad4692_spi_mode mode
Definition ad4692.h:220
struct no_os_gpio_init_param * reset_param
Definition ad4692.h:209
struct no_os_gpio_init_param * gpio2_param
Definition ad4692.h:213
enum ad4692_type id
Definition ad4692.h:221
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure representing an PWM generator device.
Definition no_os_pwm.h:83
uint32_t period_ns
Definition no_os_pwm.h:89
Structure containing the init parameters needed by the PWM generator.
Definition no_os_pwm.h:56
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128