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