no-OS
|
Implementation of AD7091R-8 Driver. More...
#include <stdlib.h>
#include <errno.h>
#include "ad7091r8.h"
#include "no_os_alloc.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_delay.h"
Functions | |
int | ad7091r8_pulse_convst (struct ad7091r8_dev *dev) |
int | ad7091r8_spi_reg_write (struct ad7091r8_dev *dev, uint8_t reg_addr, uint16_t reg_data) |
int | ad7091r8_spi_reg_read (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_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_reset (struct ad7091r8_dev *dev, bool is_software) |
Initiate a software reset or hardware reset through the RESET pin. More... | |
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_channel (struct ad7091r8_dev *dev, uint8_t channel) |
int | ad7091r8_read_one (struct ad7091r8_dev *dev, uint8_t channel, uint16_t *read_val) |
int | ad7091r8_sequenced_read (struct ad7091r8_dev *dev, uint16_t *read_val) |
Implementation of AD7091R-8 Driver.
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.
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_reset | ( | struct ad7091r8_dev * | dev, |
bool | is_software | ||
) |
Initiate a software reset or hardware reset through the RESET pin.
dev | - ad7091r8_dev device handler. |
is_software | - true: Software reset
|
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. |