no-OS
Loading...
Searching...
No Matches
ad7091r5.c File Reference

Implementation of ad7091r5 Driver. More...

#include "ad7091r5.h"
#include <string.h>
#include <errno.h>
#include "stdlib.h"
#include "no_os_error.h"
#include "no_os_delay.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
Include dependency graph for ad7091r5.c:

Functions

int32_t ad7091r5_i2c_reg_read (struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 
int32_t ad7091r5_i2c_reg_write (struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 
int32_t ad7091r5_i2c_read_mask (struct ad7091r5_dev *dev, uint8_t reg_addr, uint8_t mask, uint16_t *data)
 
int32_t ad7091r5_i2c_write_mask (struct ad7091r5_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
 
int32_t ad7091r5_sleep_mode (struct ad7091r5_dev *dev, enum ad7091r5_sleep_mode mode)
 
int32_t ad7091r5_set_port (struct ad7091r5_dev *dev, enum ad7091r5_port port, bool value)
 
int32_t ad7091r5_set_gpo0_mode (struct ad7091r5_dev *dev, enum ad7091r5_gpo0_mode mode, bool is_cmos)
 
int32_t ad7091r5_set_cycle_timer (struct ad7091r5_dev *dev, enum ad7091r5_cycle_timer timer)
 
int32_t ad7091r5_get_alert (struct ad7091r5_dev *dev, uint8_t channel, enum ad7091r5_alert_type *alert)
 
int32_t ad7091r5_set_limit (struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t value)
 
int32_t ad7091r5_get_limit (struct ad7091r5_dev *dev, enum ad7091r5_limit limit, uint8_t channel, uint16_t *value)
 
int32_t ad7091r5_set_mode (struct ad7091r5_dev *dev, enum ad7091r5_mode mode)
 
int32_t ad7091r5_set_channel (struct ad7091r5_dev *dev, uint8_t channel)
 
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.
 
int32_t ad7091r5_read_one (struct ad7091r5_dev *dev, uint8_t channel, uint16_t *read_val)
 
int32_t ad7091r5_init (struct ad7091r5_dev **device, struct ad7091r5_init_param *init_param)
 
int32_t ad7091r5_remove (struct ad7091r5_dev *dev)
 Free the memory allocated by ad7091r5_init().
 

Detailed Description

Implementation of ad7091r5 Driver.

Author
Cristian Pop (crist.nosp@m.ian..nosp@m.pop@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2020(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ ad7091r5_get_alert()

int32_t ad7091r5_get_alert ( struct ad7091r5_dev * dev,
uint8_t channel,
enum ad7091r5_alert_type * alert )

Get alert.

Parameters
dev- The device structure.
channel- Channel.
alert- Alert type.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_get_limit()

int32_t ad7091r5_get_limit ( struct ad7091r5_dev * dev,
enum ad7091r5_limit limit,
uint8_t channel,
uint16_t * value )

Get high limit, low limit, hysteresis.

Parameters
dev- The device structure.
limit- Limit.
channel- Channel.
value- Value.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_i2c_read_mask()

int32_t ad7091r5_i2c_read_mask ( struct ad7091r5_dev * dev,
uint8_t reg_addr,
uint8_t mask,
uint16_t * data )

I2C read from 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.

◆ ad7091r5_i2c_reg_read()

int32_t ad7091r5_i2c_reg_read ( struct ad7091r5_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.

◆ ad7091r5_i2c_reg_write()

int32_t ad7091r5_i2c_reg_write ( struct ad7091r5_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.

◆ ad7091r5_i2c_write_mask()

int32_t ad7091r5_i2c_write_mask ( struct ad7091r5_dev * dev,
uint8_t reg_addr,
uint16_t mask,
uint16_t data )

I2C 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.

◆ ad7091r5_init()

int32_t ad7091r5_init ( struct ad7091r5_dev ** device,
struct ad7091r5_init_param * init_param )

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_read_one()

int32_t ad7091r5_read_one ( struct ad7091r5_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.

◆ ad7091r5_remove()

int32_t ad7091r5_remove ( struct ad7091r5_dev * dev)

Free the memory allocated by ad7091r5_init().

Parameters
dev- Pointer to the device handler.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_reset()

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.

Parameters
dev- ad7091r5_dev device handler.
is_software- true: Software reset
  • false: hardware reset
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_set_channel()

int32_t ad7091r5_set_channel ( struct ad7091r5_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.

◆ ad7091r5_set_cycle_timer()

int32_t ad7091r5_set_cycle_timer ( struct ad7091r5_dev * dev,
enum ad7091r5_cycle_timer timer )

Set cycle timer for autocycle mode.

Parameters
dev- The device structure.
timer- Converter sampling period.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_set_gpo0_mode()

int32_t ad7091r5_set_gpo0_mode ( struct ad7091r5_dev * dev,
enum ad7091r5_gpo0_mode mode,
bool is_cmos )

Set GPO0 mode.

Parameters
dev- The device structure.
mode- GPO0 new mode.
is_cmos- 0: GPO0 is open drain
  • 1: GPO0 is CMOS.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_set_limit()

int32_t ad7091r5_set_limit ( struct ad7091r5_dev * dev,
enum ad7091r5_limit limit,
uint8_t channel,
uint16_t value )

Set high limit, low limit, hysteresis.

Parameters
dev- The device structure.
limit- Limit.
channel- Channel.
value- Value.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_set_mode()

int32_t ad7091r5_set_mode ( struct ad7091r5_dev * dev,
enum ad7091r5_mode mode )

Set mode.

Parameters
dev- The device structure.
mode- Converter mode.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_set_port()

int32_t ad7091r5_set_port ( struct ad7091r5_dev * dev,
enum ad7091r5_port port,
bool value )

Set output port value.

Parameters
dev- The device structure.
port- Port number.
value- Value.
Returns
0 in case of success, negative error code otherwise.

◆ ad7091r5_sleep_mode()

int32_t ad7091r5_sleep_mode ( struct ad7091r5_dev * dev,
enum ad7091r5_sleep_mode mode )

Set sleep mode.

Parameters
dev- The device structure.
mode- Sleep mode.
Returns
0 in case of success, negative error code otherwise.