Go to the documentation of this file.
40 #ifndef SRC_AD7091R5_H_
41 #define SRC_AD7091R5_H_
53 #define AD7091R5_CHANNEL_NO 4
54 #define AD7091R5_BITS 12
55 #define AD7091R5_CONV_MASK NO_OS_GENMASK(AD7091R5_BITS - 1, 0)
58 #define AD7091R5_REG_RESULT 0
59 #define AD7091R5_REG_CHANNEL 1
60 #define AD7091R5_REG_CONF 2
61 #define AD7091R5_REG_ALERT 3
62 #define AD7091R5_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4)
63 #define AD7091R5_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5)
64 #define AD7091R5_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6)
67 #define REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3)
68 #define REG_RESULT_CONV_DATA(x) ((x) & AD7091R5_CONV_MASK)
71 #define REG_CONF_SLEEP_MODE_MASK NO_OS_BIT(0)
72 #define REG_CONF_SLEEP_MODE(x) ((x & 0x03) << 0)
74 #define REG_CONF_GPO1_MASK NO_OS_BIT(2)
75 #define REG_CONF_GPO1(x) ((x & 0x01) << 2)
77 #define REG_CONF_GPO0_MASK NO_OS_BIT(3)
78 #define REG_CONF_GPO0(x) ((x & 0x01) << 3)
80 #define REG_CONF_GPO0_MODE_MASK (NO_OS_BIT(15) | NO_OS_BIT(5) | NO_OS_BIT(4))
81 #define REG_CONF_GPO0_ALERT(x) ((x & 0x01) << 4)
82 #define REG_CONF_GPO0_BUSY(x) ((x & 0x01) << 5)
83 #define REG_CONF_GPO0_DRIVE_TYPE(x) ((x & 0x01) << 15)
85 #define REG_CONF_CYCLE_TIMER_MASK (NO_OS_BIT(7) | NO_OS_BIT(6))
86 #define REG_CONF_CYCLE_TIMER(x) ((x & 0x03) << 6)
88 #define REG_CONF_GPO2_MASK NO_OS_BIT(14)
89 #define REG_CONF_GPO2(x) ((x & 0x01) << 14)
91 #define REG_CONF_RESET_MASK NO_OS_BIT(9)
92 #define REG_CONF_RESET(x) ((x & 0x01) << 9)
94 #define REG_CONF_MODE_MASK (NO_OS_BIT(10) | NO_OS_BIT(8))
95 #define REG_CONF_AUTO(x) ((x & 0x01) << 8)
96 #define REG_CONF_CMD(x) ((x & 0x01) << 10)
99 #define REG_ALERT_MASK(x, ch) (x >> (ch * 2))
@ AD7091R5_SLEEP_MODE_2
Definition: ad7091r5.h:128
int32_t ad7091r5_sleep_mode(struct ad7091r5_dev *dev, enum ad7091r5_sleep_mode mode)
Definition: ad7091r5.c:169
#define REG_CONF_GPO0_ALERT(x)
Definition: ad7091r5.h:81
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
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:165
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:58
int32_t ad7091r5_read_one(struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
Definition: ad7091r5.c:499
@ AD7091R5_HIGH_ALERT
Definition: ad7091r5.h:182
@ AD7091R5_SLEEP_MODE_0
Definition: ad7091r5.h:124
int32_t ad7091r5_init(struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
Definition: ad7091r5.c:534
int32_t ad7091r5_get_alert(struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
Definition: ad7091r5.c:277
int32_t ad7091r5_set_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r5.c:307
#define AD7091R5_REG_CH_HYSTERESIS(ch)
Definition: ad7091r5.h:64
#define REG_CONF_GPO0_MASK
Definition: ad7091r5.h:77
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:119
struct no_os_gpio_init_param * gpio_resetn
Definition: ad7091r5.h:208
@ AD7091R5_HIGH_LIMIT
Definition: ad7091r5.h:195
int32_t ad7091r5_get_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t *value)
Definition: ad7091r5.c:342
#define REG_CONF_RESET_MASK
Definition: ad7091r5.h:91
@ AD7091R5_CYCLE_TIMER_200uS
Definition: ad7091r5.h:167
#define REG_CONF_GPO0_MODE_MASK
Definition: ad7091r5.h:80
@ AD7091R5_SLEEP_MODE_3
Definition: ad7091r5.h:130
Header file of Delay functions.
#define AD7091R5_REG_RESULT
Definition: ad7091r5.h:58
enum no_os_spi_mode mode
Definition: no_os_spi.h:139
struct no_os_i2c_desc * i2c_desc
Definition: ad7091r5.h:217
@ AD7091R5_MODE_SAMPLE
Definition: ad7091r5.h:110
Definition: ad9361_util.h:75
ad7091r5_limit
Limit type.
Definition: ad7091r5.h:191
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:123
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:53
#define AD7091R5_REG_CONF
Definition: ad7091r5.h:60
@ AD7091R5_GPO0
Definition: ad7091r5.h:139
struct no_os_gpio_desc * gpio_resetn
Definition: ad7091r5.h:219
@ AD7091R5_GPO2
Definition: ad7091r5.h:143
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:121
struct no_os_i2c_init_param * i2c_init
Definition: ad7091r5.h:206
int32_t ad7091r5_i2c_reg_read(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
Definition: ad7091r5.c:63
#define REG_RESULT_CONV_DATA(x)
Definition: ad7091r5.h:68
ad7091r5_port
Converter general purpose outputs.
Definition: ad7091r5.h:137
Header file for ad7091r5 Driver.
#define REG_CONF_RESET(x)
Definition: ad7091r5.h:92
int32_t ad7091r5_set_port(struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
Definition: ad7091r5.c:187
#define REG_CONF_GPO0(x)
Definition: ad7091r5.h:78
int32_t ad7091r5_set_mode(struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
Definition: ad7091r5.c:382
#define REG_CONF_AUTO(x)
Definition: ad7091r5.h:95
#define REG_CONF_SLEEP_MODE_MASK
Definition: ad7091r5.h:71
#define AD7091R5_REG_CH_HIGH_LIMIT(ch)
Definition: ad7091r5.h:63
int32_t ad7091r5_set_port(struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
Definition: ad7091r5.c:187
#define REG_CONF_GPO0_DRIVE_TYPE(x)
Definition: ad7091r5.h:83
#define REG_CONF_SLEEP_MODE(x)
Definition: ad7091r5.h:72
int32_t ad7091r5_set_limit(struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r5.c:307
@ AD7091R5_NO_ALERT
Definition: ad7091r5.h:180
@ AD7091R5_GPO1
Definition: ad7091r5.h:141
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:442
@ AD7091R5_CYCLE_TIMER_400uS
Definition: ad7091r5.h:169
int32_t ad7091r5_set_channel(struct ad7091r5_dev *dev, uint8_t channel)
Definition: ad7091r5.c:412
int32_t ad7091r5_set_channel(struct ad7091r5_dev *dev, uint8_t channel)
Definition: ad7091r5.c:412
@ AD7091R5_SLEEP_MODE_1
Definition: ad7091r5.h:126
ad7091r5_gpo0_mode
Port 0 configuration.
Definition: ad7091r5.h:150
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:110
int32_t port
Definition: no_os_gpio.h:104
#define REG_ALERT_MASK(x, ch)
Definition: ad7091r5.h:99
int32_t ad7091r5_set_cycle_timer(struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
Definition: ad7091r5.c:259
#define AD7091R5_CHANNEL_NO
Definition: ad7091r5.h:53
ad7091r5_cycle_timer
Timer used for autocycle mode.
Definition: ad7091r5.h:163
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
int32_t ad7091r5_remove(struct ad7091r5_dev *dev)
Free the memory allocated by ad7091r5_init().
Definition: ad7091r5.c:580
Structure representing an ad7091r5 device.
Definition: ad7091r5.h:215
int32_t ad7091r5_init(struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
Definition: ad7091r5.c:534
int32_t ad7091r5_i2c_write_mask(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Definition: ad7091r5.c:142
@ AD7091R5_LOW_LIMIT
Definition: ad7091r5.h:193
@ AD7091R5_MODE_COMMAND
Definition: ad7091r5.h:112
#define AD7091R5_REG_ALERT
Definition: ad7091r5.h:61
int32_t ad7091r5_set_cycle_timer(struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
Definition: ad7091r5.c:259
int32_t ad7091r5_get_alert(struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
Definition: ad7091r5.c:277
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:107
#define REG_CONF_GPO2_MASK
Definition: ad7091r5.h:88
#define AD7091R5_REG_CH_LOW_LIMIT(ch)
Definition: ad7091r5.h:62
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:196
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
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:342
Structure containing the init parameters needed by the ad7091r5 device.
Definition: ad7091r5.h:204
#define AD7091R5_REG_CHANNEL
Definition: ad7091r5.h:59
@ AD7091R5_MODE_AUTOCYCLE
Definition: ad7091r5.h:114
int32_t ad7091r5_i2c_read_mask(struct ad7091r5_dev *dev, uint8_t reg_addr, uint8_t mask, uint16_t *data)
Definition: ad7091r5.c:117
#define NO_OS_BIT(x)
Definition: no_os_util.h:51
#define REG_CONF_GPO2(x)
Definition: ad7091r5.h:89
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:75
int32_t ad7091r5_i2c_reg_write(struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t reg_data)
Definition: ad7091r5.c:93
int32_t ad7091r5_remove(struct ad7091r5_dev *dev)
Free the memory allocated by ad7091r5_init().
Definition: ad7091r5.c:580
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
@ AD7091R5_GPO0_ALERT
Definition: ad7091r5.h:154
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:70
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:203
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
ad7091r5_mode
Converter supported modes.
Definition: ad7091r5.h:108
#define REG_CONF_GPO1(x)
Definition: ad7091r5.h:75
int32_t ad7091r5_set_gpo0_mode(struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
Definition: ad7091r5.c:225
@ AD7091R5_CYCLE_TIMER_100uS
Definition: ad7091r5.h:165
#define REG_RESULT_CH_ID(x)
Definition: ad7091r5.h:67
#define REG_CONF_CYCLE_TIMER(x)
Definition: ad7091r5.h:86
Header file of GPIO Interface.
@ AD7091R5_GPO0_ENABLED
Definition: ad7091r5.h:152
#define REG_CONF_CMD(x)
Definition: ad7091r5.h:96
int32_t ad7091r5_set_mode(struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
Definition: ad7091r5.c:382
#define REG_CONF_GPO0_BUSY(x)
Definition: ad7091r5.h:82
Header file of utility functions.
ad7091r5_sleep_mode
Converter supported sleep modes.
Definition: ad7091r5.h:121
@ AD7091R5_GPO0_BUSY
Definition: ad7091r5.h:156
#define REG_CONF_GPO1_MASK
Definition: ad7091r5.h:74
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:153
ad7091r5_alert_type
Alert status.
Definition: ad7091r5.h:178
int32_t ad7091r5_read_one(struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
Definition: ad7091r5.c:499
@ AD7091R5_CYCLE_TIMER_800uS
Definition: ad7091r5.h:171
int32_t ad7091r5_set_gpo0_mode(struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
Definition: ad7091r5.c:225
@ AD7091R5_HYSTERESIS
Definition: ad7091r5.h:197
Error macro definition for ARM Compiler.
#define REG_CONF_MODE_MASK
Definition: ad7091r5.h:94
#define REG_CONF_CYCLE_TIMER_MASK
Definition: ad7091r5.h:85
@ AD7091R5_LOW_ALERT
Definition: ad7091r5.h:184
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:81