no-OS
|
Implementation of AD7091R-8 driver header file. More...
Go to the source code of this file.
Classes | |
struct | ad7091r8_dev |
struct | ad7091r8_init_param |
Enumerations | |
enum | ad7091r8_device_id { AD7091R2, AD7091R4, AD7091R8 } |
enum | ad7091r8_sleep_mode { AD7091R8_SLEEP_MODE_0, AD7091R8_SLEEP_MODE_1, AD7091R8_SLEEP_MODE_2, AD7091R8_SLEEP_MODE_3 } |
Converter supported sleep modes. More... | |
enum | ad7091r8_port { AD7091R8_GPO0, AD7091R8_GPO1 } |
Converter general purpose outputs. More... | |
enum | ad7091r8_gpo0_mode { AD7091R8_GPO0_ENABLED = 0, AD7091R8_GPO0_ALERT = 16, AD7091R8_GPO0_BUSY = 48 } |
Port 0 configuration. More... | |
enum | ad7091r8_limit { AD7091R8_LOW_LIMIT, AD7091R8_HIGH_LIMIT, AD7091R8_HYSTERESIS } |
Limit type. More... | |
enum | ad7091r8_alert_type { AD7091R8_NO_ALERT, AD7091R8_HIGH_ALERT, AD7091R8_LOW_ALERT } |
Alert status. More... | |
Functions | |
int | ad7091r8_init (struct ad7091r8_dev **device, struct ad7091r8_init_param *init_param) |
int | ad7091r8_remove (struct ad7091r8_dev *dev) |
Free the resources allocated by ad7091r8_init(). More... | |
int | ad7091r8_set_sleep_mode (struct ad7091r8_dev *dev, enum ad7091r8_sleep_mode mode) |
Set device sleep mode. More... | |
int | ad7091r8_set_port (struct ad7091r8_dev *dev, enum ad7091r8_port port, bool value) |
int | ad7091r8_set_gpo0_mode (struct ad7091r8_dev *dev, enum ad7091r8_gpo0_mode mode, bool is_cmos) |
int | ad7091r8_set_limit (struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t value) |
int | ad7091r8_get_alert (struct ad7091r8_dev *dev, uint8_t channel, enum ad7091r8_alert_type *alert) |
int | ad7091r8_get_limit (struct ad7091r8_dev *dev, enum ad7091r8_limit limit, uint8_t channel, uint16_t *value) |
int | ad7091r8_set_channel (struct ad7091r8_dev *dev, uint8_t channel) |
int | ad7091r8_read_one (struct ad7091r8_dev *dev, uint8_t chan, uint16_t *read_val) |
int | ad7091r8_sequenced_read (struct ad7091r8_dev *dev, uint16_t *read_val) |
int | ad7091r8_spi_reg_read (struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t *reg_data) |
int | ad7091r8_spi_reg_write (struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t reg_data) |
int | ad7091r8_spi_write_mask (struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data) |
int | ad7091r8_pulse_convst (struct ad7091r8_dev *dev) |
Implementation of AD7091R-8 driver header file.
Copyright 2024(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AD7091R8_BITS 12 |
#define AD7091R8_CONV_MASK NO_OS_GENMASK(AD7091R8_BITS - 1, 0) |
#define AD7091R8_RD_WR_FLAG_MSK NO_OS_BIT(10) |
#define AD7091R8_REG_ADDR_MSK NO_OS_GENMASK(15, 11) |
#define AD7091R8_REG_ALERT 0x03 |
#define AD7091R8_REG_CH_HIGH_LIMIT | ( | ch | ) | ((ch) * 3 + 5) |
#define AD7091R8_REG_CH_HYSTERESIS | ( | ch | ) | ((ch) * 3 + 6) |
#define AD7091R8_REG_CH_LOW_LIMIT | ( | ch | ) | ((ch) * 3 + 4) |
#define AD7091R8_REG_CHANNEL 0x01 |
#define AD7091R8_REG_CONF 0x02 |
#define AD7091R8_REG_DATA_MSK NO_OS_GENMASK(9, 0) |
#define AD7091R8_REG_RESULT 0x00 |
#define AD7091R8_REG_RESULT_ALT_MASK NO_OS_BIT(12) |
#define AD7091R8_REG_RESULT_CH_ID_MASK NO_OS_GENMASK(15, 13) |
#define AD7091R8_REG_RESULT_DATA_MASK NO_OS_GENMASK(11, 0) |
#define AD7091R_NUM_CHANNELS | ( | id | ) | (1 << ((id) + 1)) |
#define REG_ALERT_MASK | ( | x, | |
ch | |||
) | (x >> (ch * 2)) |
#define REG_CONF_ALERT_STICKY_MASK NO_OS_BIT(7) |
#define REG_CONF_GPO0_MASK NO_OS_BIT(3) |
#define REG_CONF_GPO0_MODE_MASK NO_OS_GENMASK(6, 4) |
#define REG_CONF_GPO1_MASK NO_OS_BIT(2) |
#define REG_CONF_RESET_MASK NO_OS_BIT(9) |
#define REG_CONF_SLEEP_MODE_MASK NO_OS_GENMASK(1, 0) |
enum ad7091r8_alert_type |
enum ad7091r8_device_id |
enum ad7091r8_gpo0_mode |
enum ad7091r8_limit |
enum ad7091r8_port |
enum ad7091r8_sleep_mode |
Converter supported sleep modes.
int ad7091r8_get_alert | ( | struct ad7091r8_dev * | dev, |
uint8_t | channel, | ||
enum ad7091r8_alert_type * | alert | ||
) |
Get alert.
dev | - The device structure. |
channel | - Channel. |
alert | - Alert type. |
int ad7091r8_get_limit | ( | struct ad7091r8_dev * | dev, |
enum ad7091r8_limit | limit, | ||
uint8_t | channel, | ||
uint16_t * | value | ||
) |
Get high limit, low limit, hysteresis. The 3 LSBs of the internal 12-bit registers are set either to 000 or 111. Adjust limit data to reflect actual limit in use by the device.
dev | - The device structure. |
limit | - Limit. |
channel | - Channel. |
value | - Value. |
int ad7091r8_init | ( | struct ad7091r8_dev ** | device, |
struct ad7091r8_init_param * | init_param | ||
) |
Initializes the communication peripheral and the initial Values for AD7092R-8 Board.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int ad7091r8_pulse_convst | ( | struct ad7091r8_dev * | dev | ) |
Pull the CONVST line up then down to signal to the start of a read/write operation.
dev | - The device structure. |
int ad7091r8_read_one | ( | struct ad7091r8_dev * | dev, |
uint8_t | channel, | ||
uint16_t * | read_val | ||
) |
Read one sample.
dev | - The device structure. |
channel | - Channel. |
read_val | - Value. |
int ad7091r8_remove | ( | struct ad7091r8_dev * | dev | ) |
Free the resources allocated by ad7091r8_init().
dev | - The device structure. |
int ad7091r8_sequenced_read | ( | struct ad7091r8_dev * | dev, |
uint16_t * | read_val | ||
) |
Read the next channel set in the channel sequencer (channel register).
dev | - The device structure. |
read_val | - Value. |
int ad7091r8_set_channel | ( | struct ad7091r8_dev * | dev, |
uint8_t | channel | ||
) |
Set device channel.
dev | - The device structure. |
channel | - Channel. |
int ad7091r8_set_gpo0_mode | ( | struct ad7091r8_dev * | dev, |
enum ad7091r8_gpo0_mode | mode, | ||
bool | is_cmos | ||
) |
Set GPO0 mode.
dev | - The device structure. |
mode | - GPO0 new mode. |
is_cmos | - 0: GPO0 is open drain
|
int ad7091r8_set_limit | ( | struct ad7091r8_dev * | dev, |
enum ad7091r8_limit | limit, | ||
uint8_t | channel, | ||
uint16_t | value | ||
) |
Set high limit, low limit, hysteresis. Device accepts 9 bits provided by the user and sets them as the MSBs. The 3 LSBs of the internal 12-bit registers are set either to 000 or 111. Round user input according to each case.
dev | - The device structure. |
limit | - Limit. |
channel | - Channel. |
value | - Value. |
int ad7091r8_set_port | ( | struct ad7091r8_dev * | dev, |
enum ad7091r8_port | port, | ||
bool | value | ||
) |
Set output port value.
dev | - The device structure. |
port | - Port number. |
value | - Value. |
int ad7091r8_set_sleep_mode | ( | struct ad7091r8_dev * | dev, |
enum ad7091r8_sleep_mode | mode | ||
) |
Set device sleep mode.
dev | - The device structure. |
mode | - The device sleep mode to set. |
int ad7091r8_spi_reg_read | ( | struct ad7091r8_dev * | dev, |
uint8_t | reg_addr, | ||
uint16_t * | reg_data | ||
) |
Read from device.
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The register data. |
int ad7091r8_spi_reg_write | ( | struct ad7091r8_dev * | dev, |
uint8_t | reg_addr, | ||
uint16_t | reg_data | ||
) |
Write to device.
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The register data. |
int ad7091r8_spi_write_mask | ( | struct ad7091r8_dev * | dev, |
uint8_t | reg_addr, | ||
uint16_t | mask, | ||
uint16_t | data | ||
) |
SPI write to device using a mask.
dev | - The device structure. |
reg_addr | - The register address. |
mask | - The mask. |
data | - The register data. |