no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5421.h
Go to the documentation of this file.
1/**************************************************************************/
34#ifndef _AD5421_H_
35#define _AD5421_H_
36
37#include <stdint.h>
38#include "no_os_gpio.h"
39#include "no_os_spi.h"
40
41/* COMMAND Bytes */
42#define AD5421_CMDWRDAC 1
43#define AD5421_CMDWRCTRL 2
44#define AD5421_CMDWROFFSET 3
45#define AD5421_CMDWRGAIN 4
46#define AD5421_CMDRST 7
47#define AD5421_CMDMEASVTEMP 8
48#define AD5421_NO_OP 9
49#define AD5421_CMDRDDAC 129
50#define AD5421_CMDRDCTRL 130
51#define AD5421_CMDRDOFFSET 131
52#define AD5421_CMDRDGAIN 132
53#define AD5421_CMDRDFAULT 133
54
55/* AD5421 COMMAND mask */
56#define AD5421_CMD(x) ((x & 0xFF) << 16)
57
58/* AD5421 GPIO */
59#define AD5421_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \
60 NO_OS_GPIO_HIGH)
61#define AD5421_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \
62 NO_OS_GPIO_LOW)
63#define AD5421_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \
64 NO_OS_GPIO_HIGH)
65#define AD5421_FAULT_IN no_os_gpio_direction_input(dev->gpio_faultin)
66
67/* CONTROL register bits */
68#define CTRL_SPI_WATCHDOG (1 << 12)
69#define CTRL_AUTO_FAULT_RDBK (1 << 11)
70#define CTRL_SEL_ADC_INPUT (1 << 8)
71#define CTRL_ONCHIP_ADC (1 << 7)
72
73struct ad5421_dev {
74 /* SPI */
76 /* GPIO */
79};
80
88
89/* Initialize the communication with the device. */
90int32_t ad5421_init(struct ad5421_dev **device,
92/* Free the resources allocated by ad5421_init(). */
93int32_t ad5421_remove(struct ad5421_dev *dev);
94/* Set the value of DAC register. */
95void ad5421_set_dac(struct ad5421_dev *dev,
96 int32_t dac_value);
97/* Set the value of OFFSET register. */
98void ad5421_set_offset(struct ad5421_dev *dev,
99 int32_t offset_value);
100/* Set the value of GAIN register. */
101void ad5421_set_gain(struct ad5421_dev *dev,
102 int32_t gain_value);
103/* Read the DAC register. */
104int32_t ad5421_get_dac(struct ad5421_dev *dev);
105/* Read OFFSET register. */
106int32_t ad5421_get_offset(struct ad5421_dev *dev);
107/* Read GAIN register. */
108int32_t ad5421_get_gain(struct ad5421_dev *dev);
109/* Read FAULT register. */
110int32_t ad5421_get_fault(struct ad5421_dev *dev);
111/* Read the temperature from Fault register. */
112int32_t ad5421_get_temp(struct ad5421_dev *dev);
113/* Read VLoop-COM from Fault register. */
114float ad5421_get_vloop(struct ad5421_dev *dev);
115/* Send command via SPI. */
116int32_t ad5421_set(struct ad5421_dev *dev,
117 int32_t *i_value);
118/* Receive value via SPI. */
119int32_t ad5421_get(struct ad5421_dev *dev);
120/* Resets the AD5421 device. */
121void ad5421_reset(struct ad5421_dev *dev);
122
123#endif /* _AD5421_H_ */
int32_t ad5421_get_temp(struct ad5421_dev *dev)
Read the temperature from Fault register.
Definition ad5421.c:273
int32_t ad5421_get_fault(struct ad5421_dev *dev)
Read from the Fault register.
Definition ad5421.c:251
int32_t ad5421_remove(struct ad5421_dev *dev)
Free the resources allocated by ad5421_init().
Definition ad5421.c:110
int32_t ad5421_init(struct ad5421_dev **device, struct ad5421_init_param init_param)
Initialize SPI and Initial Values for AD5421 Board.
Definition ad5421.c:50
void ad5421_set_gain(struct ad5421_dev *dev, int32_t gain_value)
Write to the Gain Adjust register.
Definition ad5421.c:169
void ad5421_reset(struct ad5421_dev *dev)
Resets the ad5421 device.
Definition ad5421.c:407
int32_t ad5421_get_gain(struct ad5421_dev *dev)
Read from the Gain Adjust register.
Definition ad5421.c:230
int32_t ad5421_set(struct ad5421_dev *dev, int32_t *i_value)
Send data via SPI.
Definition ad5421.c:355
int32_t ad5421_get(struct ad5421_dev *dev)
Read data via SPI.
Definition ad5421.c:383
int32_t ad5421_get_offset(struct ad5421_dev *dev)
Read from the Offset Adjust register.
Definition ad5421.c:209
int32_t ad5421_get_dac(struct ad5421_dev *dev)
Read from the DAC register.
Definition ad5421.c:188
float ad5421_get_vloop(struct ad5421_dev *dev)
Read VLoop-COM from Fault register.
Definition ad5421.c:314
void ad5421_set_dac(struct ad5421_dev *dev, int32_t dac_value)
Write to the DAC register.
Definition ad5421.c:131
void ad5421_set_offset(struct ad5421_dev *dev, int32_t offset_value)
Write to the Offset Adjust register.
Definition ad5421.c:150
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad5421.h:73
struct no_os_gpio_desc * gpio_ldac
Definition ad5421.h:77
struct no_os_spi_desc * spi_desc
Definition ad5421.h:75
struct no_os_gpio_desc * gpio_faultin
Definition ad5421.h:78
Definition ad5421.h:81
struct no_os_gpio_init_param gpio_faultin
Definition ad5421.h:86
struct no_os_gpio_init_param gpio_ldac
Definition ad5421.h:85
struct no_os_spi_init_param spi_init
Definition ad5421.h:83
Definition ad9361_util.h:63
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128