no-OS
Loading...
Searching...
No Matches
ad5421.h File Reference

Header file of AD5421 Driver for Microblaze processor. More...

#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
Include dependency graph for ad5421.h:

Classes

struct  ad5421_dev
 
struct  ad5421_init_param
 

Macros

#define AD5421_CMDWRDAC   1
 
#define AD5421_CMDWRCTRL   2
 
#define AD5421_CMDWROFFSET   3
 
#define AD5421_CMDWRGAIN   4
 
#define AD5421_CMDRST   7
 
#define AD5421_CMDMEASVTEMP   8
 
#define AD5421_NO_OP   9
 
#define AD5421_CMDRDDAC   129
 
#define AD5421_CMDRDCTRL   130
 
#define AD5421_CMDRDOFFSET   131
 
#define AD5421_CMDRDGAIN   132
 
#define AD5421_CMDRDFAULT   133
 
#define AD5421_CMD(x)
 
#define AD5421_LDAC_OUT
 
#define AD5421_LDAC_LOW
 
#define AD5421_LDAC_HIGH
 
#define AD5421_FAULT_IN   no_os_gpio_direction_input(dev->gpio_faultin)
 
#define CTRL_SPI_WATCHDOG   (1 << 12)
 
#define CTRL_AUTO_FAULT_RDBK   (1 << 11)
 
#define CTRL_SEL_ADC_INPUT   (1 << 8)
 
#define CTRL_ONCHIP_ADC   (1 << 7)
 

Functions

int32_t ad5421_init (struct ad5421_dev **device, struct ad5421_init_param init_param)
 Initialize SPI and Initial Values for AD5421 Board.
 
int32_t ad5421_remove (struct ad5421_dev *dev)
 Free the resources allocated by ad5421_init().
 
void ad5421_set_dac (struct ad5421_dev *dev, int32_t dac_value)
 Write to the DAC register.
 
void ad5421_set_offset (struct ad5421_dev *dev, int32_t offset_value)
 Write to the Offset Adjust register.
 
void ad5421_set_gain (struct ad5421_dev *dev, int32_t gain_value)
 Write to the Gain Adjust register.
 
int32_t ad5421_get_dac (struct ad5421_dev *dev)
 Read from the DAC register.
 
int32_t ad5421_get_offset (struct ad5421_dev *dev)
 Read from the Offset Adjust register.
 
int32_t ad5421_get_gain (struct ad5421_dev *dev)
 Read from the Gain Adjust register.
 
int32_t ad5421_get_fault (struct ad5421_dev *dev)
 Read from the Fault register.
 
int32_t ad5421_get_temp (struct ad5421_dev *dev)
 Read the temperature from Fault register.
 
float ad5421_get_vloop (struct ad5421_dev *dev)
 Read VLoop-COM from Fault register.
 
int32_t ad5421_set (struct ad5421_dev *dev, int32_t *i_value)
 Send data via SPI.
 
int32_t ad5421_get (struct ad5421_dev *dev)
 Read data via SPI.
 
void ad5421_reset (struct ad5421_dev *dev)
 Resets the ad5421 device.
 

Detailed Description

Header file of AD5421 Driver for Microblaze processor.

Author
Lucian Sin (Lucia.nosp@m.n.Si.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Copyright 2013(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ AD5421_CMD

#define AD5421_CMD ( x)
Value:
((x & 0xFF) << 16)

◆ AD5421_CMDMEASVTEMP

#define AD5421_CMDMEASVTEMP   8

◆ AD5421_CMDRDCTRL

#define AD5421_CMDRDCTRL   130

◆ AD5421_CMDRDDAC

#define AD5421_CMDRDDAC   129

◆ AD5421_CMDRDFAULT

#define AD5421_CMDRDFAULT   133

◆ AD5421_CMDRDGAIN

#define AD5421_CMDRDGAIN   132

◆ AD5421_CMDRDOFFSET

#define AD5421_CMDRDOFFSET   131

◆ AD5421_CMDRST

#define AD5421_CMDRST   7

◆ AD5421_CMDWRCTRL

#define AD5421_CMDWRCTRL   2

◆ AD5421_CMDWRDAC

#define AD5421_CMDWRDAC   1

◆ AD5421_CMDWRGAIN

#define AD5421_CMDWRGAIN   4

◆ AD5421_CMDWROFFSET

#define AD5421_CMDWROFFSET   3

◆ AD5421_FAULT_IN

#define AD5421_FAULT_IN   no_os_gpio_direction_input(dev->gpio_faultin)

◆ AD5421_LDAC_HIGH

#define AD5421_LDAC_HIGH
Value:
no_os_gpio_set_value(dev->gpio_ldac, \
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition no_os_gpio.c:170
@ NO_OS_GPIO_HIGH
Definition no_os_gpio.h:82

◆ AD5421_LDAC_LOW

#define AD5421_LDAC_LOW
Value:
no_os_gpio_set_value(dev->gpio_ldac, \
@ NO_OS_GPIO_LOW
Definition no_os_gpio.h:80

◆ AD5421_LDAC_OUT

#define AD5421_LDAC_OUT
Value:
no_os_gpio_direction_output(dev->gpio_ldac, \
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition no_os_gpio.c:120

◆ AD5421_NO_OP

#define AD5421_NO_OP   9

◆ CTRL_AUTO_FAULT_RDBK

#define CTRL_AUTO_FAULT_RDBK   (1 << 11)

◆ CTRL_ONCHIP_ADC

#define CTRL_ONCHIP_ADC   (1 << 7)

◆ CTRL_SEL_ADC_INPUT

#define CTRL_SEL_ADC_INPUT   (1 << 8)

◆ CTRL_SPI_WATCHDOG

#define CTRL_SPI_WATCHDOG   (1 << 12)

Function Documentation

◆ ad5421_get()

int32_t ad5421_get ( struct ad5421_dev * dev)

Read data via SPI.

Parameters
dev- The device structure.
Returns
returnVal - Data read

◆ ad5421_get_dac()

int32_t ad5421_get_dac ( struct ad5421_dev * dev)

Read from the DAC register.

Parameters
dev- The device structure.
Returns
dacValue - value read from the register.

◆ ad5421_get_fault()

int32_t ad5421_get_fault ( struct ad5421_dev * dev)

Read from the Fault register.

Parameters
dev- The device structure.
Returns
value - register content

◆ ad5421_get_gain()

int32_t ad5421_get_gain ( struct ad5421_dev * dev)

Read from the Gain Adjust register.

Parameters
dev- The device structure.
Returns
gainValue - value calculated according to the datasheet formula

◆ ad5421_get_offset()

int32_t ad5421_get_offset ( struct ad5421_dev * dev)

Read from the Offset Adjust register.

Parameters
dev- The device structure.
Returns
offsetValue - value calculated according to the datasheet formula.

◆ ad5421_get_temp()

int32_t ad5421_get_temp ( struct ad5421_dev * dev)

Read the temperature from Fault register.

Parameters
dev- The device structure.
Returns
tempValue - temperature value in Celsius degrees.

◆ ad5421_get_vloop()

float ad5421_get_vloop ( struct ad5421_dev * dev)

Read VLoop-COM from Fault register.

Parameters
dev- The device structure.
Returns
vlopValue - value of the voltage drop between Vloop and COM.

◆ ad5421_init()

int32_t ad5421_init ( struct ad5421_dev ** device,
struct ad5421_init_param init_param )

Initialize SPI and Initial Values for AD5421 Board.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
retValue - Result of the initialization. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.

◆ ad5421_remove()

int32_t ad5421_remove ( struct ad5421_dev * dev)

Free the resources allocated by ad5421_init().

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

◆ ad5421_reset()

void ad5421_reset ( struct ad5421_dev * dev)

Resets the ad5421 device.

Parameters
dev- The device structure.

◆ ad5421_set()

int32_t ad5421_set ( struct ad5421_dev * dev,
int32_t * value )

Send data via SPI.

Parameters
dev- The device structure.
value- value to be sent via SPI
Returns
- Result of the initialization. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.

◆ ad5421_set_dac()

void ad5421_set_dac ( struct ad5421_dev * dev,
int32_t dac_value )

Write to the DAC register.

Parameters
dev- The device structure.
dac_value- desired value to be written in register.

◆ ad5421_set_gain()

void ad5421_set_gain ( struct ad5421_dev * dev,
int32_t gain_value )

Write to the Gain Adjust register.

Parameters
dev- The device structure.
gain_value- desired value to be written in register.

◆ ad5421_set_offset()

void ad5421_set_offset ( struct ad5421_dev * dev,
int32_t offset_value )

Write to the Offset Adjust register.

Parameters
dev- The device structure.
offset_value- desired value to be written in register.