no-OS
ad5446.h
Go to the documentation of this file.
1 /***************************************************************************/
45 /*****************************************************************************/
46 /***************************** Include Files *********************************/
47 /*****************************************************************************/
48 #include <stdint.h>
49 #include "no_os_gpio.h"
50 #include "no_os_spi.h"
51 
52 /******************************************************************************/
53 /*************************** Types Declarations *******************************/
54 /******************************************************************************/
55 
56 /* Custom type for active clock edge */
60 };
61 
62 /* Custom boolean type */
63 enum bool_t {
64  false,
65  true
66 };
67 
68 /* Data structure for chip's attributes */
70  uint8_t resolution;
73 };
74 
75 /* Supported output types */
77  unipolar, /* 0 .. Vref */
78  unipolar_inv, /* 0 .. -Vref */
79  bipolar /* -Vref .. Vref*/
80 };
81 
82 /* Supported devices */
96 };
97 
98 struct ad5446_dev {
99  /* SPI */
101  /* GPIO */
104  /* Device Settings */
106 };
107 
109  /* SPI */
111  /* GPIO */
114  /* Device Settings */
116 };
117 
118 /* Control Bits */
119 #define AD5446_CTRL_LOAD_UPDATE 0x0
120 #define AD5446_CTRL_ACTIVE_POSEDGE 0x3
121 
122 /* AD5446 GPIO */
123 #define AD5446_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ladc, \
124  NO_OS_GPIO_HIGH)
125 #define AD5446_LDAC_LOW no_os_gpio_set_value(dev->gpio_ladc, \
126  NO_OS_GPIO_LOW)
127 #define AD5446_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ladc, \
128  NO_OS_GPIO_HIGH)
129 
130 #define AD5446_CLR_OUT no_os_gpio_direction_output(dev->gpio_clrout, \
131  NO_OS_GPIO_HIGH)
132 #define AD5446_CLR_LOW no_os_gpio_set_value(dev->gpio_clrout, \
133  NO_OS_GPIO_LOW)
134 #define AD5446_CLR_HIGH no_os_gpio_set_value(dev->gpio_clrout, \
135  NO_OS_GPIO_HIGH)
136 
137 /******************************************************************************/
138 /************************ Functions Declarations ******************************/
139 /******************************************************************************/
140 /* Initialize SPI and Initial Values for AD5446 Board. */
141 int8_t ad5446_init(struct ad5446_dev **device,
143 
144 /* Free the resources allocated by ad5446_init(). */
145 int32_t ad5446_remove(struct ad5446_dev *dev);
146 
147 /* Write to shift register via SPI. */
148 void ad5446_set_register(struct ad5446_dev *dev,
149  uint8_t command,
150  uint16_t data);
151 
152 /* Sets the output voltage. */
153 float ad5446_set_voltage(struct ad5446_dev *dev,
154  float voltage,
155  float vref,
156  enum vout_type_t vout_type);
LSB_OFFSET
#define LSB_OFFSET
Definition: ad5446.c:57
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
active_clk_t
active_clk_t
Definition: ad5446.h:57
AD5446_CLR_HIGH
#define AD5446_CLR_HIGH
Definition: ad5446.h:134
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:165
ad5446_dev::gpio_ladc
struct no_os_gpio_desc * gpio_ladc
Definition: ad5446.h:102
AD5446_LDAC_OUT
#define AD5446_LDAC_OUT
Definition: ad5446.h:123
no_os_spi.h
Header file of SPI Interface.
ID_AD5541A
@ ID_AD5541A
Definition: ad5446.h:88
ad5446_chip_info::data_clock_in
enum active_clk_t data_clock_in
Definition: ad5446.h:71
ad5446_init_param::gpio_clrout
struct no_os_gpio_init_param gpio_clrout
Definition: ad5446.h:113
ad5446_dev
Definition: ad5446.h:98
unipolar_inv
@ unipolar_inv
Definition: ad5446.h:78
CMD_OFFSET
#define CMD_OFFSET
Definition: ad5446.c:59
PKT_LENGTH
#define PKT_LENGTH
Definition: ad5446.c:60
device
Definition: ad9361_util.h:75
unipolar
@ unipolar
Definition: ad5446.h:77
ID_AD5450
@ ID_AD5450
Definition: ad5446.h:93
ID_AD5444
@ ID_AD5444
Definition: ad5446.h:95
ad5446_chip_info
Definition: ad5446.h:69
ID_AD5600
@ ID_AD5600
Definition: ad5446.h:84
DATA_MASK
#define DATA_MASK(x)
Definition: ad5446.c:52
ad5446_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad5446.h:110
ad5446_set_register
void ad5446_set_register(struct ad5446_dev *dev, uint8_t command, uint16_t data)
Writes to input register via SPI.
Definition: ad5446.c:210
bool_t
bool_t
Definition: ad5446.h:63
ad5446_remove
int32_t ad5446_remove(struct ad5446_dev *dev)
Free the resources allocated by ad5446_init().
Definition: ad5446.c:187
AD5446_CLR_OUT
#define AD5446_CLR_OUT
Definition: ad5446.h:130
ID_AD5543
@ ID_AD5543
Definition: ad5446.h:86
ad5446_init_param
Definition: ad5446.h:108
ad5446_remove
int32_t ad5446_remove(struct ad5446_dev *dev)
Free the resources allocated by ad5446_init().
Definition: ad5446.c:187
ad5446_chip_info::resolution
uint8_t resolution
Definition: ad5446.h:70
ID_AD5453
@ ID_AD5453
Definition: ad5446.h:90
posedge
@ posedge
Definition: ad5446.h:59
ad5446_type_t
ad5446_type_t
Definition: ad5446.h:83
MSB_OFFSET
#define MSB_OFFSET
Definition: ad5446.c:55
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
ad5446_set_voltage
float ad5446_set_voltage(struct ad5446_dev *dev, float voltage, float vref, enum vout_type_t vout_type)
Sets the output voltage.
Definition: ad5446.c:242
ID_AD5452
@ ID_AD5452
Definition: ad5446.h:91
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
ad5446_chip_info::has_ctrl
enum bool_t has_ctrl
Definition: ad5446.h:72
AD5446_CLR_LOW
#define AD5446_CLR_LOW
Definition: ad5446.h:132
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:55
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
ID_AD5512A
@ ID_AD5512A
Definition: ad5446.h:89
ad5446.h
Header file of AD5446 Driver. This driver supporting the following devices: AD5553,...
ad5446_set_voltage
float ad5446_set_voltage(struct ad5446_dev *dev, float voltage, float vref, enum vout_type_t vout_type)
Sets the output voltage.
Definition: ad5446.c:242
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
vout_type_t
vout_type_t
Definition: ad5446.h:76
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
ad5446_dev::gpio_clrout
struct no_os_gpio_desc * gpio_clrout
Definition: ad5446.h:103
bipolar
@ bipolar
Definition: ad5446.h:79
ad5446_dev::act_device
enum ad5446_type_t act_device
Definition: ad5446.h:105
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:122
ID_AD5446
@ ID_AD5446
Definition: ad5446.h:94
ID_AD5553
@ ID_AD5553
Definition: ad5446.h:85
no_os_gpio.h
Header file of GPIO Interface.
MSB_MASK
#define MSB_MASK
Definition: ad5446.c:54
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
negedge
@ negedge
Definition: ad5446.h:58
ad5446_init_param::gpio_ladc
struct no_os_gpio_init_param gpio_ladc
Definition: ad5446.h:112
ID_AD5451
@ ID_AD5451
Definition: ad5446.h:92
ad5446_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad5446.h:100
AD5446_LDAC_LOW
#define AD5446_LDAC_LOW
Definition: ad5446.h:125
ad5446_init
int8_t ad5446_init(struct ad5446_dev **device, struct ad5446_init_param init_param)
Initialize SPI and Initial Values for AD5446 Board.
Definition: ad5446.c:141
LSB_MASK
#define LSB_MASK
Definition: ad5446.c:56
ad5446_init_param::act_device
enum ad5446_type_t act_device
Definition: ad5446.h:115
ad5446_set_register
void ad5446_set_register(struct ad5446_dev *dev, uint8_t command, uint16_t data)
Writes to input register via SPI.
Definition: ad5446.c:210
CMD_MASK
#define CMD_MASK
Definition: ad5446.c:58
ad5446_init
int8_t ad5446_init(struct ad5446_dev **device, struct ad5446_init_param init_param)
Initialize SPI and Initial Values for AD5446 Board.
Definition: ad5446.c:141
ID_AD5542A
@ ID_AD5542A
Definition: ad5446.h:87
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
DATA_OFFSET
#define DATA_OFFSET(x)
Definition: ad5446.c:53