no-OS
Classes | Macros | Functions
ad7280a.h File Reference
#include <stdint.h>
#include "no-os/delay.h"
#include "no-os/gpio.h"
#include "no-os/spi.h"
Include dependency graph for ad7280a.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad7280a_dev
 
struct  ad7280a_init_param
 

Macros

#define AD7280A_PD_OUT
 
#define AD7280A_PD_HIGH
 
#define AD7280A_PD_LOW
 
#define AD7280A_CNVST_OUT
 
#define AD7280A_CNVST_HIGH
 
#define AD7280A_CNVST_LOW
 
#define AD7280A_ALERT_IN   gpio_direction_input(dev->gpio_alert)
 
#define AD7280_ALERT   (1 << 6)
 
#define AD7280A_ACQ_TIME_400ns   0
 
#define AD7280A_ACQ_TIME_800ns   1
 
#define AD7280A_ACQ_TIME_1200ns   2
 
#define AD7280A_ACQ_TIME_1600ns   3
 
#define AD7280A_CONV_AVG_DIS   0
 
#define AD7280A_CONV_AVG_2   1
 
#define AD7280A_CONV_AVG_4   2
 
#define AD7280A_CONV_AVG_8   3
 
#define AD7280A_ALERT_REMOVE_VIN5   (1 << 2)
 
#define AD7280A_ALERT_REMOVE_VIN4_VIN5   (2 << 2)
 
#define AD7280A_ALERT_REMOVE_AUX5   (1 << 0)
 
#define AD7280A_ALERT_REMOVE_AUX4_AUX5   (2 << 0)
 
#define AD7280A_CELL_VOLTAGE_1   0x0 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_2   0x1 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_3   0x2 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_4   0x3 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_5   0x4 /* D11 to D0, Read only */
 
#define AD7280A_CELL_VOLTAGE_6   0x5 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_1   0x6 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_2   0x7 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_3   0x8 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_4   0x9 /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_5   0xA /* D11 to D0, Read only */
 
#define AD7280A_AUX_ADC_6   0xB /* D11 to D0, Read only */
 
#define AD7280A_SELF_TEST   0xC /* D11 to D0, Read only */
 
#define AD7280A_CONTROL_HB   0xD /* D15 to D8, Read/write */
 
#define AD7280A_CONTROL_LB   0xE /* D7 to D0, Read/write */
 
#define AD7280A_CELL_OVERVOLTAGE   0xF /* D7 to D0, Read/write */
 
#define AD7280A_CELL_UNDERVOLTAGE   0x10 /* D7 to D0, Read/write */
 
#define AD7280A_AUX_ADC_OVERVOLTAGE   0x11 /* D7 to D0, Read/write */
 
#define AD7280A_AUX_ADC_UNDERVOLTAGE   0x12 /* D7 to D0, Read/write */
 
#define AD7280A_ALERT   0x13 /* D7 to D0, Read/write */
 
#define AD7280A_CELL_BALANCE   0x14 /* D7 to D0, Read/write */
 
#define AD7280A_CB1_TIMER   0x15 /* D7 to D0, Read/write */
 
#define AD7280A_CB2_TIMER   0x16 /* D7 to D0, Read/write */
 
#define AD7280A_CB3_TIMER   0x17 /* D7 to D0, Read/write */
 
#define AD7280A_CB4_TIMER   0x18 /* D7 to D0, Read/write */
 
#define AD7280A_CB5_TIMER   0x19 /* D7 to D0, Read/write */
 
#define AD7280A_CB6_TIMER   0x1A /* D7 to D0, Read/write */
 
#define AD7280A_PD_TIMER   0x1B /* D7 to D0, Read/write */
 
#define AD7280A_READ   0x1C /* D7 to D0, Read/write */
 
#define AD7280A_CNVST_N_CONTROL   0x1D /* D7 to D0, Read/write */
 
#define AD7280A_CTRL_HB_CONV_INPUT_ALL   (0 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4   (1 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_6CELL   (2 << 6)
 
#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST   (3 << 6)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_ALL   (0 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   (1 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL   (2 << 4)
 
#define AD7280A_CTRL_HB_CONV_RES_READ_NO   (3 << 4)
 
#define AD7280A_CTRL_HB_CONV_START_CNVST   (0 << 3)
 
#define AD7280A_CTRL_HB_CONV_START_CS   (1 << 3)
 
#define AD7280A_CTRL_HB_CONV_AVG_DIS   (0 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_2   (1 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_4   (2 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG_8   (3 << 1)
 
#define AD7280A_CTRL_HB_CONV_AVG(x)   ((x) << 1)
 
#define AD7280A_CTRL_HB_PWRDN_SW   (1 << 0)
 
#define AD7280A_CTRL_LB_SWRST   (1 << 7)
 
#define AD7280A_CTRL_LB_ACQ_TIME_400ns   (0 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_800ns   (1 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_1200ns   (2 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME_1600ns   (3 << 5)
 
#define AD7280A_CTRL_LB_ACQ_TIME(x)   ((x) << 5)
 
#define AD7280A_CTRL_LB_MUST_SET   (1 << 4)
 
#define AD7280A_CTRL_LB_THERMISTOR_EN   (1 << 3)
 
#define AD7280A_CTRL_LB_LOCK_DEV_ADDR   (1 << 2)
 
#define AD7280A_CTRL_LB_INC_DEV_ADDR   (1 << 1)
 
#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN   (1 << 0)
 
#define AD7280A_ALERT_GEN_STATIC_HIGH   (1 << 6)
 
#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN   (3 << 6)
 
#define AD7280A_ALL_CELLS   (0xAD << 16)
 
#define AD7280A_DEVADDR_MASTER   0
 
#define AD7280A_DEVADDR_ALL   0x1F
 
#define AD7280A_READ_TXVAL   0xF800030A
 
#define NUMBITS_READ   22
 
#define NUMBITS_WRITE   21
 

Functions

int8_t ad7280a_init (struct ad7280a_dev **device, struct ad7280a_init_param init_param)
 
int32_t ad7280a_remove (struct ad7280a_dev *dev)
 Free the resources allocated by AD7280A_Init(). More...
 
uint32_t ad7280a_transfer_32bits (struct ad7280a_dev *dev, uint32_t data)
 
uint32_t ad7280a_crc_write (uint32_t message)
 
int32_t ad7280a_crc_read (uint32_t message)
 
int8_t ad7280a_convert_read_all (struct ad7280a_dev *dev)
 
int8_t ad7280a_convert_data_all (struct ad7280a_dev *dev)
 
int16_t ad7280a_read_register (struct ad7280a_dev *dev, uint8_t dev_addr, uint8_t read_reg)
 
int16_t ad7280a_read_conversion (struct ad7280a_dev *dev, uint8_t dev_addr, uint8_t read_reg)
 
float ad7280a_convert_data (uint8_t type, uint16_t data)
 
void ad7280a_write_register (struct ad7280a_dev *dev, uint8_t dev_addr, uint8_t read_reg, uint8_t reg_val)
 
void ad7280a_selftest_all (struct ad7280a_dev *dev, float *self_test_reg_a, float *self_test_reg_b)
 
uint8_t ad7280a_alert_pin (struct ad7280a_dev *dev)
 

Macro Definition Documentation

◆ AD7280_ALERT

#define AD7280_ALERT   (1 << 6)

◆ AD7280A_ACQ_TIME_1200ns

#define AD7280A_ACQ_TIME_1200ns   2

◆ AD7280A_ACQ_TIME_1600ns

#define AD7280A_ACQ_TIME_1600ns   3

◆ AD7280A_ACQ_TIME_400ns

#define AD7280A_ACQ_TIME_400ns   0

◆ AD7280A_ACQ_TIME_800ns

#define AD7280A_ACQ_TIME_800ns   1

◆ AD7280A_ALERT

#define AD7280A_ALERT   0x13 /* D7 to D0, Read/write */

◆ AD7280A_ALERT_GEN_STATIC_HIGH

#define AD7280A_ALERT_GEN_STATIC_HIGH   (1 << 6)

◆ AD7280A_ALERT_IN

#define AD7280A_ALERT_IN   gpio_direction_input(dev->gpio_alert)

◆ AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN

#define AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN   (3 << 6)

◆ AD7280A_ALERT_REMOVE_AUX4_AUX5

#define AD7280A_ALERT_REMOVE_AUX4_AUX5   (2 << 0)

◆ AD7280A_ALERT_REMOVE_AUX5

#define AD7280A_ALERT_REMOVE_AUX5   (1 << 0)

◆ AD7280A_ALERT_REMOVE_VIN4_VIN5

#define AD7280A_ALERT_REMOVE_VIN4_VIN5   (2 << 2)

◆ AD7280A_ALERT_REMOVE_VIN5

#define AD7280A_ALERT_REMOVE_VIN5   (1 << 2)

◆ AD7280A_ALL_CELLS

#define AD7280A_ALL_CELLS   (0xAD << 16)

◆ AD7280A_AUX_ADC_1

#define AD7280A_AUX_ADC_1   0x6 /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_2

#define AD7280A_AUX_ADC_2   0x7 /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_3

#define AD7280A_AUX_ADC_3   0x8 /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_4

#define AD7280A_AUX_ADC_4   0x9 /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_5

#define AD7280A_AUX_ADC_5   0xA /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_6

#define AD7280A_AUX_ADC_6   0xB /* D11 to D0, Read only */

◆ AD7280A_AUX_ADC_OVERVOLTAGE

#define AD7280A_AUX_ADC_OVERVOLTAGE   0x11 /* D7 to D0, Read/write */

◆ AD7280A_AUX_ADC_UNDERVOLTAGE

#define AD7280A_AUX_ADC_UNDERVOLTAGE   0x12 /* D7 to D0, Read/write */

◆ AD7280A_CB1_TIMER

#define AD7280A_CB1_TIMER   0x15 /* D7 to D0, Read/write */

◆ AD7280A_CB2_TIMER

#define AD7280A_CB2_TIMER   0x16 /* D7 to D0, Read/write */

◆ AD7280A_CB3_TIMER

#define AD7280A_CB3_TIMER   0x17 /* D7 to D0, Read/write */

◆ AD7280A_CB4_TIMER

#define AD7280A_CB4_TIMER   0x18 /* D7 to D0, Read/write */

◆ AD7280A_CB5_TIMER

#define AD7280A_CB5_TIMER   0x19 /* D7 to D0, Read/write */

◆ AD7280A_CB6_TIMER

#define AD7280A_CB6_TIMER   0x1A /* D7 to D0, Read/write */

◆ AD7280A_CELL_BALANCE

#define AD7280A_CELL_BALANCE   0x14 /* D7 to D0, Read/write */

◆ AD7280A_CELL_OVERVOLTAGE

#define AD7280A_CELL_OVERVOLTAGE   0xF /* D7 to D0, Read/write */

◆ AD7280A_CELL_UNDERVOLTAGE

#define AD7280A_CELL_UNDERVOLTAGE   0x10 /* D7 to D0, Read/write */

◆ AD7280A_CELL_VOLTAGE_1

#define AD7280A_CELL_VOLTAGE_1   0x0 /* D11 to D0, Read only */

◆ AD7280A_CELL_VOLTAGE_2

#define AD7280A_CELL_VOLTAGE_2   0x1 /* D11 to D0, Read only */

◆ AD7280A_CELL_VOLTAGE_3

#define AD7280A_CELL_VOLTAGE_3   0x2 /* D11 to D0, Read only */

◆ AD7280A_CELL_VOLTAGE_4

#define AD7280A_CELL_VOLTAGE_4   0x3 /* D11 to D0, Read only */

◆ AD7280A_CELL_VOLTAGE_5

#define AD7280A_CELL_VOLTAGE_5   0x4 /* D11 to D0, Read only */

◆ AD7280A_CELL_VOLTAGE_6

#define AD7280A_CELL_VOLTAGE_6   0x5 /* D11 to D0, Read only */

◆ AD7280A_CNVST_HIGH

#define AD7280A_CNVST_HIGH
Value:
gpio_set_value(dev->gpio_cnvst, \

◆ AD7280A_CNVST_LOW

#define AD7280A_CNVST_LOW
Value:
gpio_set_value(dev->gpio_cnvst, \

◆ AD7280A_CNVST_N_CONTROL

#define AD7280A_CNVST_N_CONTROL   0x1D /* D7 to D0, Read/write */

◆ AD7280A_CNVST_OUT

#define AD7280A_CNVST_OUT
Value:

◆ AD7280A_CONTROL_HB

#define AD7280A_CONTROL_HB   0xD /* D15 to D8, Read/write */

◆ AD7280A_CONTROL_LB

#define AD7280A_CONTROL_LB   0xE /* D7 to D0, Read/write */

◆ AD7280A_CONV_AVG_2

#define AD7280A_CONV_AVG_2   1

◆ AD7280A_CONV_AVG_4

#define AD7280A_CONV_AVG_4   2

◆ AD7280A_CONV_AVG_8

#define AD7280A_CONV_AVG_8   3

◆ AD7280A_CONV_AVG_DIS

#define AD7280A_CONV_AVG_DIS   0

◆ AD7280A_CTRL_HB_CONV_AVG

#define AD7280A_CTRL_HB_CONV_AVG (   x)    ((x) << 1)

◆ AD7280A_CTRL_HB_CONV_AVG_2

#define AD7280A_CTRL_HB_CONV_AVG_2   (1 << 1)

◆ AD7280A_CTRL_HB_CONV_AVG_4

#define AD7280A_CTRL_HB_CONV_AVG_4   (2 << 1)

◆ AD7280A_CTRL_HB_CONV_AVG_8

#define AD7280A_CTRL_HB_CONV_AVG_8   (3 << 1)

◆ AD7280A_CTRL_HB_CONV_AVG_DIS

#define AD7280A_CTRL_HB_CONV_AVG_DIS   (0 << 1)

◆ AD7280A_CTRL_HB_CONV_INPUT_6CELL

#define AD7280A_CTRL_HB_CONV_INPUT_6CELL   (2 << 6)

◆ AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4

#define AD7280A_CTRL_HB_CONV_INPUT_6CELL_AUX1_3_4   (1 << 6)

◆ AD7280A_CTRL_HB_CONV_INPUT_ALL

#define AD7280A_CTRL_HB_CONV_INPUT_ALL   (0 << 6)

◆ AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST

#define AD7280A_CTRL_HB_CONV_INPUT_SELF_TEST   (3 << 6)

◆ AD7280A_CTRL_HB_CONV_RES_READ_6CELL

#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL   (2 << 4)

◆ AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4

#define AD7280A_CTRL_HB_CONV_RES_READ_6CELL_AUX1_3_4   (1 << 4)

◆ AD7280A_CTRL_HB_CONV_RES_READ_ALL

#define AD7280A_CTRL_HB_CONV_RES_READ_ALL   (0 << 4)

◆ AD7280A_CTRL_HB_CONV_RES_READ_NO

#define AD7280A_CTRL_HB_CONV_RES_READ_NO   (3 << 4)

◆ AD7280A_CTRL_HB_CONV_START_CNVST

#define AD7280A_CTRL_HB_CONV_START_CNVST   (0 << 3)

◆ AD7280A_CTRL_HB_CONV_START_CS

#define AD7280A_CTRL_HB_CONV_START_CS   (1 << 3)

◆ AD7280A_CTRL_HB_PWRDN_SW

#define AD7280A_CTRL_HB_PWRDN_SW   (1 << 0)

◆ AD7280A_CTRL_LB_ACQ_TIME

#define AD7280A_CTRL_LB_ACQ_TIME (   x)    ((x) << 5)

◆ AD7280A_CTRL_LB_ACQ_TIME_1200ns

#define AD7280A_CTRL_LB_ACQ_TIME_1200ns   (2 << 5)

◆ AD7280A_CTRL_LB_ACQ_TIME_1600ns

#define AD7280A_CTRL_LB_ACQ_TIME_1600ns   (3 << 5)

◆ AD7280A_CTRL_LB_ACQ_TIME_400ns

#define AD7280A_CTRL_LB_ACQ_TIME_400ns   (0 << 5)

◆ AD7280A_CTRL_LB_ACQ_TIME_800ns

#define AD7280A_CTRL_LB_ACQ_TIME_800ns   (1 << 5)

◆ AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN

#define AD7280A_CTRL_LB_DAISY_CHAIN_RB_EN   (1 << 0)

◆ AD7280A_CTRL_LB_INC_DEV_ADDR

#define AD7280A_CTRL_LB_INC_DEV_ADDR   (1 << 1)

◆ AD7280A_CTRL_LB_LOCK_DEV_ADDR

#define AD7280A_CTRL_LB_LOCK_DEV_ADDR   (1 << 2)

◆ AD7280A_CTRL_LB_MUST_SET

#define AD7280A_CTRL_LB_MUST_SET   (1 << 4)

◆ AD7280A_CTRL_LB_SWRST

#define AD7280A_CTRL_LB_SWRST   (1 << 7)

◆ AD7280A_CTRL_LB_THERMISTOR_EN

#define AD7280A_CTRL_LB_THERMISTOR_EN   (1 << 3)

◆ AD7280A_DEVADDR_ALL

#define AD7280A_DEVADDR_ALL   0x1F

◆ AD7280A_DEVADDR_MASTER

#define AD7280A_DEVADDR_MASTER   0

◆ AD7280A_PD_HIGH

#define AD7280A_PD_HIGH
Value:

◆ AD7280A_PD_LOW

#define AD7280A_PD_LOW
Value:
gpio_set_value(dev->gpio_pd, \

◆ AD7280A_PD_OUT

#define AD7280A_PD_OUT
Value:

◆ AD7280A_PD_TIMER

#define AD7280A_PD_TIMER   0x1B /* D7 to D0, Read/write */

◆ AD7280A_READ

#define AD7280A_READ   0x1C /* D7 to D0, Read/write */

◆ AD7280A_READ_TXVAL

#define AD7280A_READ_TXVAL   0xF800030A

◆ AD7280A_SELF_TEST

#define AD7280A_SELF_TEST   0xC /* D11 to D0, Read only */

◆ NUMBITS_READ

#define NUMBITS_READ   22

◆ NUMBITS_WRITE

#define NUMBITS_WRITE   21

Function Documentation

◆ ad7280a_alert_pin()

uint8_t ad7280a_alert_pin ( struct ad7280a_dev dev)

◆ ad7280a_convert_data()

float ad7280a_convert_data ( uint8_t  type,
uint16_t  data 
)

◆ ad7280a_convert_data_all()

int8_t ad7280a_convert_data_all ( struct ad7280a_dev dev)
Here is the caller graph for this function:

◆ ad7280a_convert_read_all()

int8_t ad7280a_convert_read_all ( struct ad7280a_dev dev)

◆ ad7280a_crc_read()

int32_t ad7280a_crc_read ( uint32_t  message)
Here is the caller graph for this function:

◆ ad7280a_crc_write()

uint32_t ad7280a_crc_write ( uint32_t  message)
Here is the caller graph for this function:

◆ ad7280a_init()

int8_t ad7280a_init ( struct ad7280a_dev **  device,
struct ad7280a_init_param  init_param 
)

◆ ad7280a_read_conversion()

int16_t ad7280a_read_conversion ( struct ad7280a_dev dev,
uint8_t  dev_addr,
uint8_t  read_reg 
)

◆ ad7280a_read_register()

int16_t ad7280a_read_register ( struct ad7280a_dev dev,
uint8_t  dev_addr,
uint8_t  read_reg 
)

◆ ad7280a_remove()

int32_t ad7280a_remove ( struct ad7280a_dev dev)

Free the resources allocated by AD7280A_Init().

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

◆ ad7280a_selftest_all()

void ad7280a_selftest_all ( struct ad7280a_dev dev,
float *  self_test_reg_a,
float *  self_test_reg_b 
)

◆ ad7280a_transfer_32bits()

uint32_t ad7280a_transfer_32bits ( struct ad7280a_dev dev,
uint32_t  data 
)
Here is the caller graph for this function:

◆ ad7280a_write_register()

void ad7280a_write_register ( struct ad7280a_dev dev,
uint8_t  dev_addr,
uint8_t  read_reg,
uint8_t  reg_val 
)
gpio_direction_output
int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: gpio.c:124
GPIO_LOW
@ GPIO_LOW
Definition: gpio.h:99
gpio_set_value
int32_t gpio_set_value(struct gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: gpio.c:160
GPIO_HIGH
@ GPIO_HIGH
Definition: gpio.h:101
iio_app_device::dev
void * dev
Definition: iio_app.h:60