Go to the documentation of this file.
34 #ifndef SRC_AD7091R5_H_
35 #define SRC_AD7091R5_H_
47 #define AD7091R5_CHANNEL_NO 4
48 #define AD7091R5_BITS 12
49 #define AD7091R5_CONV_MASK NO_OS_GENMASK(AD7091R5_BITS - 1, 0)
52 #define AD7091R5_REG_RESULT 0
53 #define AD7091R5_REG_CHANNEL 1
54 #define AD7091R5_REG_CONF 2
55 #define AD7091R5_REG_ALERT 3
56 #define AD7091R5_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4)
57 #define AD7091R5_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5)
58 #define AD7091R5_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6)
61 #define REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3)
62 #define REG_RESULT_CONV_DATA(x) ((x) & AD7091R5_CONV_MASK)
65 #define REG_CONF_SLEEP_MODE_MASK NO_OS_BIT(0)
66 #define REG_CONF_SLEEP_MODE(x) ((x & 0x03) << 0)
68 #define REG_CONF_GPO1_MASK NO_OS_BIT(2)
69 #define REG_CONF_GPO1(x) ((x & 0x01) << 2)
71 #define REG_CONF_GPO0_MASK NO_OS_BIT(3)
72 #define REG_CONF_GPO0(x) ((x & 0x01) << 3)
74 #define REG_CONF_GPO0_MODE_MASK (NO_OS_BIT(15) | NO_OS_BIT(5) | NO_OS_BIT(4))
75 #define REG_CONF_GPO0_ALERT(x) ((x & 0x01) << 4)
76 #define REG_CONF_GPO0_BUSY(x) ((x & 0x01) << 5)
77 #define REG_CONF_GPO0_DRIVE_TYPE(x) ((x & 0x01) << 15)
79 #define REG_CONF_CYCLE_TIMER_MASK (NO_OS_BIT(7) | NO_OS_BIT(6))
80 #define REG_CONF_CYCLE_TIMER(x) ((x & 0x03) << 6)
82 #define REG_CONF_GPO2_MASK NO_OS_BIT(14)
83 #define REG_CONF_GPO2(x) ((x & 0x01) << 14)
85 #define REG_CONF_RESET_MASK NO_OS_BIT(9)
86 #define REG_CONF_RESET(x) ((x & 0x01) << 9)
88 #define REG_CONF_MODE_MASK (NO_OS_BIT(10) | NO_OS_BIT(8))
89 #define REG_CONF_AUTO(x) ((x & 0x01) << 8)
90 #define REG_CONF_CMD(x) ((x & 0x01) << 10)
93 #define REG_ALERT_MASK(x, ch) (x >> (ch * 2))
@ AD7091R5_SLEEP_MODE_2
Definition: ad7091r5.h:122
int32_t ad7091r5_sleep_mode(struct ad7091r5_dev *dev, enum ad7091r5_sleep_mode mode)
Definition: ad7091r5.c:163
#define REG_CONF_GPO0_ALERT(x)
Definition: ad7091r5.h:75
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
int32_t ad7091r5_read_one(struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
Definition: ad7091r5.c:493
@ AD7091R5_HIGH_ALERT
Definition: ad7091r5.h:176
@ AD7091R5_SLEEP_MODE_0
Definition: ad7091r5.h:118
int32_t ad7091r5_init(struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
Definition: ad7091r5.c:528
int32_t ad7091r5_get_alert(struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
Definition: ad7091r5.c:271
int32_t ad7091r5_set_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r5.c:301
#define AD7091R5_REG_CH_HYSTERESIS(ch)
Definition: ad7091r5.h:58
#define REG_CONF_GPO0_MASK
Definition: ad7091r5.h:71
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
struct no_os_gpio_init_param * gpio_resetn
Definition: ad7091r5.h:202
@ AD7091R5_HIGH_LIMIT
Definition: ad7091r5.h:189
int32_t ad7091r5_get_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t *value)
Definition: ad7091r5.c:336
#define REG_CONF_RESET_MASK
Definition: ad7091r5.h:85
@ AD7091R5_CYCLE_TIMER_200uS
Definition: ad7091r5.h:161
#define REG_CONF_GPO0_MODE_MASK
Definition: ad7091r5.h:74
@ AD7091R5_SLEEP_MODE_3
Definition: ad7091r5.h:124
Header file of Delay functions.
#define AD7091R5_REG_RESULT
Definition: ad7091r5.h:52
enum no_os_spi_mode mode
Definition: no_os_spi.h:148
struct no_os_i2c_desc * i2c_desc
Definition: ad7091r5.h:211
@ AD7091R5_MODE_SAMPLE
Definition: ad7091r5.h:104
Definition: ad9361_util.h:69
ad7091r5_limit
Limit type.
Definition: ad7091r5.h:185
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
#define AD7091R5_REG_CONF
Definition: ad7091r5.h:54
@ AD7091R5_GPO0
Definition: ad7091r5.h:133
struct no_os_gpio_desc * gpio_resetn
Definition: ad7091r5.h:213
@ AD7091R5_GPO2
Definition: ad7091r5.h:137
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
struct no_os_i2c_init_param * i2c_init
Definition: ad7091r5.h:200
int32_t ad7091r5_i2c_reg_read(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
Definition: ad7091r5.c:57
#define REG_RESULT_CONV_DATA(x)
Definition: ad7091r5.h:62
ad7091r5_port
Converter general purpose outputs.
Definition: ad7091r5.h:131
Header file for ad7091r5 Driver.
#define REG_CONF_RESET(x)
Definition: ad7091r5.h:86
int32_t ad7091r5_set_port(struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
Definition: ad7091r5.c:181
#define REG_CONF_GPO0(x)
Definition: ad7091r5.h:72
int32_t ad7091r5_set_mode(struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
Definition: ad7091r5.c:376
#define REG_CONF_AUTO(x)
Definition: ad7091r5.h:89
#define REG_CONF_SLEEP_MODE_MASK
Definition: ad7091r5.h:65
#define AD7091R5_REG_CH_HIGH_LIMIT(ch)
Definition: ad7091r5.h:57
int32_t ad7091r5_set_port(struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
Definition: ad7091r5.c:181
#define REG_CONF_GPO0_DRIVE_TYPE(x)
Definition: ad7091r5.h:77
#define REG_CONF_SLEEP_MODE(x)
Definition: ad7091r5.h:66
int32_t ad7091r5_set_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r5.c:301
@ AD7091R5_NO_ALERT
Definition: ad7091r5.h:174
@ AD7091R5_GPO1
Definition: ad7091r5.h:135
int32_t ad7091r5_reset(struct ad7091r5_dev *dev, bool is_software)
Initialize GPIO driver handlers for the GPIOs in the system. ad7091r5_init() helper function.
Definition: ad7091r5.c:436
@ AD7091R5_CYCLE_TIMER_400uS
Definition: ad7091r5.h:163
int32_t ad7091r5_set_channel(struct ad7091r5_dev *dev, uint8_t channel)
Definition: ad7091r5.c:406
int32_t ad7091r5_set_channel(struct ad7091r5_dev *dev, uint8_t channel)
Definition: ad7091r5.c:406
@ AD7091R5_SLEEP_MODE_1
Definition: ad7091r5.h:120
ad7091r5_gpo0_mode
Port 0 configuration.
Definition: ad7091r5.h:144
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
int32_t port
Definition: no_os_gpio.h:98
#define REG_ALERT_MASK(x, ch)
Definition: ad7091r5.h:93
int32_t ad7091r5_set_cycle_timer(struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
Definition: ad7091r5.c:253
#define AD7091R5_CHANNEL_NO
Definition: ad7091r5.h:47
ad7091r5_cycle_timer
Timer used for autocycle mode.
Definition: ad7091r5.h:157
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
int32_t ad7091r5_remove(struct ad7091r5_dev *dev)
Free the memory allocated by ad7091r5_init().
Definition: ad7091r5.c:574
Structure representing an ad7091r5 device.
Definition: ad7091r5.h:209
int32_t ad7091r5_init(struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
Definition: ad7091r5.c:528
int32_t ad7091r5_i2c_write_mask(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Definition: ad7091r5.c:136
@ AD7091R5_LOW_LIMIT
Definition: ad7091r5.h:187
@ AD7091R5_MODE_COMMAND
Definition: ad7091r5.h:106
#define AD7091R5_REG_ALERT
Definition: ad7091r5.h:55
int32_t ad7091r5_set_cycle_timer(struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
Definition: ad7091r5.c:253
int32_t ad7091r5_get_alert(struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
Definition: ad7091r5.c:271
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
#define REG_CONF_GPO2_MASK
Definition: ad7091r5.h:82
#define AD7091R5_REG_CH_LOW_LIMIT(ch)
Definition: ad7091r5.h:56
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
Header file of I2C Interface.
int32_t ad7091r5_get_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t *value)
Definition: ad7091r5.c:336
Structure containing the init parameters needed by the ad7091r5 device.
Definition: ad7091r5.h:198
#define AD7091R5_REG_CHANNEL
Definition: ad7091r5.h:53
@ AD7091R5_MODE_AUTOCYCLE
Definition: ad7091r5.h:108
int32_t ad7091r5_i2c_read_mask(struct ad7091r5_dev *dev, uint8_t reg_addr, uint8_t mask, uint16_t *data)
Definition: ad7091r5.c:111
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
#define REG_CONF_GPO2(x)
Definition: ad7091r5.h:83
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
int32_t ad7091r5_i2c_reg_write(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t reg_data)
Definition: ad7091r5.c:87
int32_t ad7091r5_remove(struct ad7091r5_dev *dev)
Free the memory allocated by ad7091r5_init().
Definition: ad7091r5.c:574
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
@ AD7091R5_GPO0_ALERT
Definition: ad7091r5.h:148
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ad7091r5_mode
Converter supported modes.
Definition: ad7091r5.h:102
#define REG_CONF_GPO1(x)
Definition: ad7091r5.h:69
int32_t ad7091r5_set_gpo0_mode(struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
Definition: ad7091r5.c:219
@ AD7091R5_CYCLE_TIMER_100uS
Definition: ad7091r5.h:159
#define REG_RESULT_CH_ID(x)
Definition: ad7091r5.h:61
#define REG_CONF_CYCLE_TIMER(x)
Definition: ad7091r5.h:80
Header file of GPIO Interface.
@ AD7091R5_GPO0_ENABLED
Definition: ad7091r5.h:146
#define REG_CONF_CMD(x)
Definition: ad7091r5.h:90
int32_t ad7091r5_set_mode(struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
Definition: ad7091r5.c:376
#define REG_CONF_GPO0_BUSY(x)
Definition: ad7091r5.h:76
Header file of utility functions.
ad7091r5_sleep_mode
Converter supported sleep modes.
Definition: ad7091r5.h:115
@ AD7091R5_GPO0_BUSY
Definition: ad7091r5.h:150
#define REG_CONF_GPO1_MASK
Definition: ad7091r5.h:68
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
ad7091r5_alert_type
Alert status.
Definition: ad7091r5.h:172
int32_t ad7091r5_read_one(struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
Definition: ad7091r5.c:493
@ AD7091R5_CYCLE_TIMER_800uS
Definition: ad7091r5.h:165
int32_t ad7091r5_set_gpo0_mode(struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
Definition: ad7091r5.c:219
@ AD7091R5_HYSTERESIS
Definition: ad7091r5.h:191
Error macro definition for ARM Compiler.
#define REG_CONF_MODE_MASK
Definition: ad7091r5.h:88
#define REG_CONF_CYCLE_TIMER_MASK
Definition: ad7091r5.h:79
@ AD7091R5_LOW_ALERT
Definition: ad7091r5.h:178
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75