This document describes the No-OS software used to control the AD5592R and AD5593R parts.
The AD5592R/ AD5593R have eight I/Ox pins (I/O0 to I/O7) that can be independently configured as digital-to-analog converter (DAC) outputs, analog-to-digital converter (ADC) inputs, digital outputs, or digital inputs
The driver contains three parts:
The AD7124 driver contains the following files:
The following functions are implemented in this version of AD5592R driver:
Function | Description |
---|---|
int32_t ad5592r_base_reg_write(struct ad5592r_dev *dev, uint8_t reg, uint16_t value) | Write register. |
int32_t ad5592r_base_reg_read(struct ad5592r_dev *dev, uint8_t reg, uint16_t value) | Read register. |
int32_t ad5592r_gpio_get(struct ad5592r_dev *dev, uint8_t offset) | Get GPIO value. |
int32_t ad5592r_gpio_set(struct ad5592r_dev *dev, uint8_t offset, int32_t value) | Set GPIO value. |
int32_t ad5592r_gpio_direction_input(struct ad5592r_dev *dev, uint8_t offset) | Set GPIO as input. |
int32_t ad5592r_gpio_direction_output(struct ad5592r_dev *dev, uint8_t offset, int32_t value) | Set GPIO as output. |
int32_t ad5592r_software_reset(struct ad5592r_dev *dev) | Software reset device. |
int32_t ad5592r_set_channel_modes(struct ad5592r_dev *dev) | Set channels modes. |
int32_t ad5592r_reset_channel_modes(struct ad5592r_dev *dev) | Reset channels and set GPIO to unused. |
static int32_t ad5592r_spi_wnop_r16(struct ad5592r_dev *dev, uint16_t *buf) | Write NOP and read value. |
int32_t ad5592r_write_dac(struct ad5592r_dev *dev, uint8_t chan, uint16_t value) | Write DAC channel. |
int32_t ad5592r_read_adc(struct ad5592r_dev *dev, uint8_t chan, uint16_t *value) | Read ADC channel. |
int32_t ad5592r_reg_write(struct ad5592r_dev *dev, uint8_t reg, uint16_t value) | Write register. |
int32_t ad5592r_reg_read(struct ad5592r_dev *dev, uint8_t reg, uint16_t *value) | Read register. |
int32_t ad5592r_gpio_read(struct ad5592r_dev *dev, uint8_t *value) | Read GPIOs. |
int32_t ad5592r_init(struct ad5592r_dev *dev) | Initialize AD5592r device. |
int32_t ad5593r_write_dac(struct ad5592r_dev *dev, uint8_t chan, uint16_t value) | Write DAC channel. |
int32_t ad5593r_read_adc(struct ad5592r_dev *dev, uint8_t chan, uint16_t *value) | Read ADC channel. |
int32_t ad5593r_reg_write(struct ad5592r_dev *dev, uint8_t reg, uint16_t value) | Write register. |
int32_t ad5593r_reg_read(struct ad5592r_dev *dev, uint8_t reg, uint16_t *value) | Read register. |
int32_t ad5593r_gpio_read(struct ad5592r_dev *dev, uint8_t *value) | Read GPIOs. |
int32_t ad5593r_init(struct ad5592r_dev *dev) | Initialize AD5593r device. |
The driver can only work together with a structure that holds the state of a device, where state means all information about the device. This structure will henceforth be referred as an instance of a driver.
All driver functions take a handler of a driver instance as the first argument. This allows the driver to be used with multiple devices simultaneously, without the need to replicate the .c and .h files.
Before using any API call, an instance of the driver must first be created and then initialized using the ad5592r_init() which has the following parameters:
struct ad5592r_dev my_ad5592;
A ad5592r_init() call will also reset the part.