34#ifndef SRC_AD7091R5_H_
35#define SRC_AD7091R5_H_
41#define AD7091R5_CHANNEL_NO 4
42#define AD7091R5_BITS 12
43#define AD7091R5_CONV_MASK NO_OS_GENMASK(AD7091R5_BITS - 1, 0)
46#define AD7091R5_REG_RESULT 0
47#define AD7091R5_REG_CHANNEL 1
48#define AD7091R5_REG_CONF 2
49#define AD7091R5_REG_ALERT 3
50#define AD7091R5_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4)
51#define AD7091R5_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5)
52#define AD7091R5_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6)
55#define REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3)
56#define REG_RESULT_CONV_DATA(x) ((x) & AD7091R5_CONV_MASK)
59#define REG_CONF_SLEEP_MODE_MASK NO_OS_BIT(0)
60#define REG_CONF_SLEEP_MODE(x) ((x & 0x03) << 0)
62#define REG_CONF_GPO1_MASK NO_OS_BIT(2)
63#define REG_CONF_GPO1(x) ((x & 0x01) << 2)
65#define REG_CONF_GPO0_MASK NO_OS_BIT(3)
66#define REG_CONF_GPO0(x) ((x & 0x01) << 3)
68#define REG_CONF_GPO0_MODE_MASK (NO_OS_BIT(15) | NO_OS_BIT(5) | NO_OS_BIT(4))
69#define REG_CONF_GPO0_ALERT(x) ((x & 0x01) << 4)
70#define REG_CONF_GPO0_BUSY(x) ((x & 0x01) << 5)
71#define REG_CONF_GPO0_DRIVE_TYPE(x) ((x & 0x01) << 15)
73#define REG_CONF_CYCLE_TIMER_MASK (NO_OS_BIT(7) | NO_OS_BIT(6))
74#define REG_CONF_CYCLE_TIMER(x) ((x & 0x03) << 6)
76#define REG_CONF_GPO2_MASK NO_OS_BIT(14)
77#define REG_CONF_GPO2(x) ((x & 0x01) << 14)
79#define REG_CONF_RESET_MASK NO_OS_BIT(9)
80#define REG_CONF_RESET(x) ((x & 0x01) << 9)
82#define REG_CONF_MODE_MASK (NO_OS_BIT(10) | NO_OS_BIT(8))
83#define REG_CONF_AUTO(x) ((x & 0x01) << 8)
84#define REG_CONF_CMD(x) ((x & 0x01) << 10)
87#define REG_ALERT_MASK(x, ch) (x >> (ch * 2))
int32_t ad7091r5_set_port(struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
Definition ad7091r5.c:174
int32_t ad7091r5_remove(struct ad7091r5_dev *dev)
Free the memory allocated by ad7091r5_init().
Definition ad7091r5.c:567
ad7091r5_cycle_timer
Timer used for autocycle mode.
Definition ad7091r5.h:148
@ AD7091R5_CYCLE_TIMER_400uS
Definition ad7091r5.h:154
@ AD7091R5_CYCLE_TIMER_200uS
Definition ad7091r5.h:152
@ AD7091R5_CYCLE_TIMER_800uS
Definition ad7091r5.h:156
@ AD7091R5_CYCLE_TIMER_100uS
Definition ad7091r5.h:150
int32_t ad7091r5_set_cycle_timer(struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
Definition ad7091r5.c:246
ad7091r5_mode
Converter supported modes.
Definition ad7091r5.h:93
@ AD7091R5_MODE_COMMAND
Definition ad7091r5.h:97
@ AD7091R5_MODE_AUTOCYCLE
Definition ad7091r5.h:99
@ AD7091R5_MODE_SAMPLE
Definition ad7091r5.h:95
int32_t ad7091r5_set_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
Definition ad7091r5.c:294
int32_t ad7091r5_set_channel(struct ad7091r5_dev *dev, uint8_t channel)
Definition ad7091r5.c:399
ad7091r5_sleep_mode
Converter supported sleep modes.
Definition ad7091r5.h:106
@ AD7091R5_SLEEP_MODE_0
Definition ad7091r5.h:109
@ AD7091R5_SLEEP_MODE_2
Definition ad7091r5.h:113
@ AD7091R5_SLEEP_MODE_3
Definition ad7091r5.h:115
@ AD7091R5_SLEEP_MODE_1
Definition ad7091r5.h:111
int32_t ad7091r5_get_alert(struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
Definition ad7091r5.c:264
ad7091r5_limit
Limit type.
Definition ad7091r5.h:176
@ AD7091R5_HYSTERESIS
Definition ad7091r5.h:182
@ AD7091R5_HIGH_LIMIT
Definition ad7091r5.h:180
@ AD7091R5_LOW_LIMIT
Definition ad7091r5.h:178
int32_t ad7091r5_init(struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
Definition ad7091r5.c:521
ad7091r5_gpo0_mode
Port 0 configuration.
Definition ad7091r5.h:135
@ AD7091R5_GPO0_ENABLED
Definition ad7091r5.h:137
@ AD7091R5_GPO0_ALERT
Definition ad7091r5.h:139
@ AD7091R5_GPO0_BUSY
Definition ad7091r5.h:141
int32_t ad7091r5_get_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t *value)
Definition ad7091r5.c:329
ad7091r5_alert_type
Alert status.
Definition ad7091r5.h:163
@ AD7091R5_NO_ALERT
Definition ad7091r5.h:165
@ AD7091R5_LOW_ALERT
Definition ad7091r5.h:169
@ AD7091R5_HIGH_ALERT
Definition ad7091r5.h:167
int32_t ad7091r5_set_mode(struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
Definition ad7091r5.c:369
ad7091r5_port
Converter general purpose outputs.
Definition ad7091r5.h:122
@ AD7091R5_GPO1
Definition ad7091r5.h:126
@ AD7091R5_GPO0
Definition ad7091r5.h:124
@ AD7091R5_GPO2
Definition ad7091r5.h:128
int32_t ad7091r5_set_gpo0_mode(struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
Definition ad7091r5.c:212
int32_t ad7091r5_read_one(struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
Definition ad7091r5.c:486
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of GPIO Interface.
Header file of I2C Interface.
Structure representing an ad7091r5 device.
Definition ad7091r5.h:200
struct no_os_gpio_desc * gpio_resetn
Definition ad7091r5.h:204
struct no_os_i2c_desc * i2c_desc
Definition ad7091r5.h:202
Structure containing the init parameters needed by the ad7091r5 device.
Definition ad7091r5.h:189
struct no_os_gpio_init_param * gpio_resetn
Definition ad7091r5.h:193
struct no_os_i2c_init_param * i2c_init
Definition ad7091r5.h:191
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
int32_t port
Definition no_os_gpio.h:86
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52