Go to the documentation of this file.
34 #ifndef __AD7091R8_H__
35 #define __AD7091R8_H__
48 #define AD7091R_NUM_CHANNELS(id) (1 << ((id) + 1))
49 #define AD7091R8_BITS 12
51 #define AD7091R8_CONV_MASK NO_OS_GENMASK(AD7091R8_BITS - 1, 0)
54 #define AD7091R8_REG_RESULT 0x00
55 #define AD7091R8_REG_CHANNEL 0x01
56 #define AD7091R8_REG_CONF 0x02
57 #define AD7091R8_REG_ALERT 0x03
58 #define AD7091R8_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4)
59 #define AD7091R8_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5)
60 #define AD7091R8_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6)
63 #define AD7091R8_REG_RESULT_DATA_MASK NO_OS_GENMASK(11, 0)
64 #define AD7091R8_REG_RESULT_ALT_MASK NO_OS_BIT(12)
65 #define AD7091R8_REG_RESULT_CH_ID_MASK NO_OS_GENMASK(15, 13)
68 #define REG_CONF_SLEEP_MODE_MASK NO_OS_GENMASK(1, 0)
69 #define REG_CONF_GPO1_MASK NO_OS_BIT(2)
70 #define REG_CONF_GPO0_MASK NO_OS_BIT(3)
71 #define REG_CONF_GPO0_MODE_MASK NO_OS_GENMASK(6, 4)
72 #define REG_CONF_ALERT_STICKY_MASK NO_OS_BIT(7)
73 #define REG_CONF_RESET_MASK NO_OS_BIT(9)
76 #define REG_ALERT_MASK(x, ch) (x >> (ch * 2))
79 #define AD7091R8_REG_DATA_MSK NO_OS_GENMASK(9, 0)
80 #define AD7091R8_RD_WR_FLAG_MSK NO_OS_BIT(10)
81 #define AD7091R8_REG_ADDR_MSK NO_OS_GENMASK(15, 11)
92 static char *
const ad7091r8_names[] = {
271 #endif // __AD7091R8_H__
struct no_os_gpio_desc * gpio_reset
Definition: ad7091r8.h:173
enum ad7091r8_sleep_mode sleep_mode
Definition: ad7091r8.h:196
@ AD7091R8_HIGH_LIMIT
Definition: ad7091r8.h:146
int ad7091r8_set_channel(struct ad7091r8_dev *dev, uint8_t channel)
Definition: ad7091r8.c:484
void no_os_put_unaligned_be16(uint16_t val, uint8_t *buf)
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
@ AD7091R8_GPO0_BUSY
Definition: ad7091r8.h:135
int ad7091r8_remove(struct ad7091r8_dev *dev)
Free the resources allocated by ad7091r8_init().
Definition: ad7091r8.c:458
int ad7091r8_get_alert(struct ad7091r8_dev *dev, uint8_t channel, enum ad7091r8_alert_type *alert)
Definition: ad7091r8.c:284
#define AD7091R8_REG_DATA_MSK
Definition: ad7091r8.h:79
int ad7091r8_pulse_convst(struct ad7091r8_dev *dev)
Definition: ad7091r8.c:48
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
@ AD7091R8_GPO1
Definition: ad7091r8.h:122
Header file of SPI Interface.
#define REG_CONF_GPO0_MASK
Definition: ad7091r5.h:71
#define REG_CONF_RESET_MASK
Definition: ad7091r5.h:85
#define REG_CONF_GPO0_MODE_MASK
Definition: ad7091r5.h:74
@ AD7091R8_LOW_ALERT
Definition: ad7091r8.h:161
Header file of Delay functions.
struct no_os_spi_desc * spi_desc
Definition: ad7091r8.h:167
int32_t port
Definition: no_os_gpio.h:81
int ad7091r8_spi_reg_write(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t reg_data)
Definition: ad7091r8.c:69
Definition: ad9361_util.h:69
ad7091r8_device_id
Definition: ad7091r8.h:86
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
#define AD7091R8_REG_CH_HYSTERESIS(ch)
Definition: ad7091r8.h:60
#define AD7091R8_REG_RESULT
Definition: ad7091r8.h:54
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
Implementation of AD7091R-8 driver header file.
#define AD7091R8_REG_CHANNEL
Definition: ad7091r8.h:55
#define AD7091R8_REG_ALERT
Definition: ad7091r8.h:57
@ AD7091R8_HIGH_ALERT
Definition: ad7091r8.h:159
struct no_os_gpio_init_param * gpio_alert
Definition: ad7091r8.h:192
Definition: ad7091r8.h:182
struct no_os_gpio_desc * gpio_alert
Definition: ad7091r8.h:175
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
Definition: ad7091r8.h:164
enum ad7091r8_device_id device_id
Definition: ad7091r8.h:177
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
int ad7091r8_get_limit(struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t *value)
Definition: ad7091r8.c:315
int ad7091r8_remove(struct ad7091r8_dev *dev)
Free the resources allocated by ad7091r8_init().
Definition: ad7091r8.c:458
#define REG_CONF_SLEEP_MODE_MASK
Definition: ad7091r5.h:65
ad7091r8_limit
Limit type.
Definition: ad7091r8.h:142
ad7091r8_sleep_mode
Converter supported sleep modes.
Definition: ad7091r8.h:102
int ad7091r8_get_limit(struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t *value)
Definition: ad7091r8.c:315
struct no_os_gpio_desc * gpio_convst
Definition: ad7091r8.h:171
int ad7091r8_spi_write_mask(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Definition: ad7091r8.c:148
@ AD7091R8_GPO0
Definition: ad7091r8.h:120
#define AD7091R8_RD_WR_FLAG_MSK
Definition: ad7091r8.h:80
@ AD7091R8_SLEEP_MODE_1
Definition: ad7091r8.h:107
int ad7091r8_set_port(struct ad7091r8_dev *dev, enum ad7091r8_port port, bool value)
Definition: ad7091r8.c:199
#define AD7091R_NUM_CHANNELS(id)
Definition: ad7091r8.h:48
enum ad7091r8_device_id device_id
Definition: ad7091r8.h:194
int ad7091r8_set_sleep_mode(struct ad7091r8_dev *dev, enum ad7091r8_sleep_mode mode)
Set device sleep mode.
Definition: ad7091r8.c:174
struct no_os_gpio_init_param * gpio_convst
Definition: ad7091r8.h:188
@ AD7091R8_SLEEP_MODE_3
Definition: ad7091r8.h:111
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
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
int ad7091r8_set_sleep_mode(struct ad7091r8_dev *dev, enum ad7091r8_sleep_mode mode)
Set device sleep mode.
Definition: ad7091r8.c:174
#define REG_ALERT_MASK(x, ch)
Definition: ad7091r5.h:93
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
#define AD7091R8_CONV_MASK
Definition: ad7091r8.h:51
@ AD7091R4
Definition: ad7091r8.h:88
int ad7091r8_sequenced_read(struct ad7091r8_dev *dev, uint16_t *read_val)
Definition: ad7091r8.c:533
int ad7091r8_set_limit(struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r8.c:252
int ad7091r8_set_port(struct ad7091r8_dev *dev, enum ad7091r8_port port, bool value)
Definition: ad7091r8.c:199
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
@ AD7091R2
Definition: ad7091r8.h:87
@ AD7091R8_GPO0_ALERT
Definition: ad7091r8.h:133
int ad7091r8_sequenced_read(struct ad7091r8_dev *dev, uint16_t *read_val)
Definition: ad7091r8.c:533
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
enum ad7091r8_sleep_mode sleep_mode
Definition: ad7091r8.h:179
int ad7091r8_set_limit(struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t value)
Definition: ad7091r8.c:252
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
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
@ AD7091R8
Definition: ad7091r8.h:89
#define AD7091R8_REG_CONF
Definition: ad7091r8.h:56
int ad7091r8_reset(struct ad7091r8_dev *dev, bool is_software)
Initiate a software reset or hardware reset through the RESET pin.
Definition: ad7091r8.c:346
int ad7091r8_spi_reg_write(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t reg_data)
Definition: ad7091r8.c:69
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
struct no_os_spi_init_param * spi_init
Definition: ad7091r8.h:184
int ad7091r8_get_alert(struct ad7091r8_dev *dev, uint8_t channel, enum ad7091r8_alert_type *alert)
Definition: ad7091r8.c:284
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
@ AD7091R8_SLEEP_MODE_2
Definition: ad7091r8.h:109
int ad7091r8_init(struct ad7091r8_dev **device, struct ad7091r8_init_param *init_param)
Definition: ad7091r8.c:380
#define AD7091R8_REG_CH_HIGH_LIMIT(ch)
Definition: ad7091r8.h:59
#define AD7091R8_REG_ADDR_MSK
Definition: ad7091r8.h:81
@ AD7091R8_HYSTERESIS
Definition: ad7091r8.h:148
int ad7091r8_set_gpo0_mode(struct ad7091r8_dev *dev, enum ad7091r8_gpo0_mode mode, bool is_cmos)
Definition: ad7091r8.c:229
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
ad7091r8_alert_type
Alert status.
Definition: ad7091r8.h:155
Header file of GPIO Interface.
@ AD7091R8_SLEEP_MODE_0
Definition: ad7091r8.h:105
struct no_os_gpio_init_param * gpio_reset
Definition: ad7091r8.h:190
@ AD7091R8_GPO0_ENABLED
Definition: ad7091r8.h:131
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
@ AD7091R8_LOW_LIMIT
Definition: ad7091r8.h:144
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
int ad7091r8_read_one(struct ad7091r8_dev *dev, uint8_t chan, uint16_t *read_val)
Definition: ad7091r8.c:509
int ad7091r8_set_channel(struct ad7091r8_dev *dev, uint8_t channel)
Definition: ad7091r8.c:484
Header file of utility functions.
int ad7091r8_spi_reg_read(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
Definition: ad7091r8.c:97
int ad7091r8_init(struct ad7091r8_dev **device, struct ad7091r8_init_param *init_param)
Definition: ad7091r8.c:380
ad7091r8_gpo0_mode
Port 0 configuration.
Definition: ad7091r8.h:129
#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
int ad7091r8_pulse_convst(struct ad7091r8_dev *dev)
Definition: ad7091r8.c:48
int ad7091r8_spi_reg_read(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
Definition: ad7091r8.c:97
int ad7091r8_spi_write_mask(struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
Definition: ad7091r8.c:148
int vref_mv
Definition: ad7091r8.h:186
@ AD7091R8_NO_ALERT
Definition: ad7091r8.h:157
int ad7091r8_set_gpo0_mode(struct ad7091r8_dev *dev, enum ad7091r8_gpo0_mode mode, bool is_cmos)
Definition: ad7091r8.c:229
ad7091r8_port
Converter general purpose outputs.
Definition: ad7091r8.h:118
int vref_mv
Definition: ad7091r8.h:169
int ad7091r8_read_one(struct ad7091r8_dev *dev, uint8_t channel, uint16_t *read_val)
Definition: ad7091r8.c:509
Error macro definition for ARM Compiler.
#define AD7091R8_REG_CH_LOW_LIMIT(ch)
Definition: ad7091r8.h:58
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
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