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"
|
| 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.
|
| |
| 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.
|
| |
| 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().
|
| |
| 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.
- Author
- Marcelo Schmitt (marce.nosp@m.lo.s.nosp@m.chmit.nosp@m.t@an.nosp@m.alog..nosp@m.com)
Copyright 2024(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ ad7091r8_get_alert()
Get alert.
- Parameters
-
| dev | - The device structure. |
| channel | - Channel. |
| alert | - Alert type. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_get_limit()
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.
- Parameters
-
| dev | - The device structure. |
| limit | - Limit. |
| channel | - Channel. |
| value | - Value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_init()
Initializes the communication peripheral and the initial Values for AD7092R-8 Board.
- Parameters
-
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
- Returns
- ret - The result of the initialization procedure. Example: -1 - SPI peripheral was not initialized or the device is not present. 0 - SPI peripheral was initialized and the device is present.
◆ ad7091r8_pulse_convst()
Pull the CONVST line up then down to signal to the start of a read/write operation.
- Parameters
-
| dev | - The device structure. |
◆ ad7091r8_read_one()
| int ad7091r8_read_one |
( |
struct ad7091r8_dev * | dev, |
|
|
uint8_t | channel, |
|
|
uint16_t * | read_val ) |
Read one sample.
- Parameters
-
| dev | - The device structure. |
| channel | - Channel. |
| read_val | - Value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_remove()
Free the resources allocated by ad7091r8_init().
- Parameters
-
| dev | - The device structure. |
- Returns
- ret - The result of the remove procedure.
◆ ad7091r8_reset()
Initiate a software reset or hardware reset through the RESET pin.
- Parameters
-
| dev | - ad7091r8_dev device handler. |
| is_software | - true: Software reset
|
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_sequenced_read()
| int ad7091r8_sequenced_read |
( |
struct ad7091r8_dev * | dev, |
|
|
uint16_t * | read_val ) |
Read the next channel set in the channel sequencer (channel register).
- Parameters
-
| dev | - The device structure. |
| read_val | - Value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_set_channel()
| int ad7091r8_set_channel |
( |
struct ad7091r8_dev * | dev, |
|
|
uint8_t | channel ) |
Set device channel.
- Parameters
-
| dev | - The device structure. |
| channel | - Channel. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_set_gpo0_mode()
Set GPO0 mode.
- Parameters
-
| dev | - The device structure. |
| mode | - GPO0 new mode. |
| is_cmos | - 0: GPO0 is open drain
|
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_set_limit()
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.
- Parameters
-
| dev | - The device structure. |
| limit | - Limit. |
| channel | - Channel. |
| value | - Value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_set_port()
Set output port value.
- Parameters
-
| dev | - The device structure. |
| port | - Port number. |
| value | - Value. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_set_sleep_mode()
Set device sleep mode.
- Parameters
-
| dev | - The device structure. |
| mode | - The device sleep mode to set. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_spi_reg_read()
| int ad7091r8_spi_reg_read |
( |
struct ad7091r8_dev * | dev, |
|
|
uint8_t | reg_addr, |
|
|
uint16_t * | reg_data ) |
Read from device.
- Parameters
-
| dev | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The register data. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_spi_reg_write()
| int ad7091r8_spi_reg_write |
( |
struct ad7091r8_dev * | dev, |
|
|
uint8_t | reg_addr, |
|
|
uint16_t | reg_data ) |
Write to device.
- Parameters
-
| dev | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The register data. |
- Returns
- 0 in case of success, negative error code otherwise.
◆ ad7091r8_spi_write_mask()
| 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.
- Parameters
-
| dev | - The device structure. |
| reg_addr | - The register address. |
| mask | - The mask. |
| data | - The register data. |
- Returns
- 0 in case of success, negative error code otherwise.