no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5449.h
Go to the documentation of this file.
1/***************************************************************************/
35
36#include <stdint.h>
37#include "no_os_gpio.h"
38#include "no_os_spi.h"
39
40enum bool_t {
41 false,
42 true
43};
44
45/* Supported devices */
55
57 uint8_t num_channels;
58 uint8_t resolution;
60};
61
62struct ad5449_dev {
63 /* SPI */
65 /* GPIO */
68 /* Device Settings */
70 uint16_t control_reg;
71};
72
74 /* SPI */
76 /* GPIO */
79 /* Device Settings */
81};
82
83/* Control Bits */
84#define AD5449_CTRL_NOP 0
85#define AD5449_CTRL_LOADUPDATE(x) (1 + 3 * (x))
86#define AD5449_CTRL_READBACK(x) (2 + 3 * (x))
87#define AD5449_CTRL_LOAD(x) (3 + 3 * (x))
88#define AD5449_CTRL_UPDATEALL 7
89#define AD5449_CTRL_LOADALL 8
90#define AD5449_CTRL_DAISY_CHAIN 9
91#define AD5449_CTRL_CLK_EDGE 10
92#define AD5449_CTRL_CLR_ZERO 11
93#define AD5449_CTRL_CLR_MID 12
94#define AD5449_CTRL_REG 13
95
96/* AD5449 channels */
97#define AD5449_CH_A 0
98#define AD5449_CH_B 1
99
100/* Clear target scales */
101#define AD5449_ZERO_SCALE 0
102#define AD5449_MID_SCALE 1
103
104/* Active clock edge */
105#define AD5449_CLOCK_NEGEDGE 0
106#define AD5449_CLOCK_POSEDGE 1
107
108/* Daisy-Chain Control */
109#define AD5449_DAISY_CHAIN_DIS 0
110#define AD5449_DAISY_CHAIN_EN 1
111
112/* AD5449_CTRL_REG definition */
113#define AD5449_SDO_MASK (3 << 10)
114#define AD5449_DSY_MASK (1 << 9)
115#define AD5449_HCLR_MASK (1 << 8)
116#define AD5449_SCLK_MASK (1 << 7)
117#define AD5449_SDO_BIT 10
118#define AD5449_DSY_BIT 9
119#define AD5449_HCLR_BIT 8
120#define AD5449_SCLK_BIT 7
121
122/* AD5449 GPIO */
123#define AD5449_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \
124 NO_OS_GPIO_HIGH)
125#define AD5449_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \
126 NO_OS_GPIO_LOW)
127#define AD5449_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \
128 NO_OS_GPIO_HIGH)
129
130#define AD5449_CLR_OUT no_os_gpio_direction_output(dev->gpio_clr, \
131 NO_OS_GPIO_HIGH)
132#define AD5449_CLR_LOW no_os_gpio_set_value(dev->gpio_clr, \
133 NO_OS_GPIO_LOW)
134#define AD5449_CLR_HIGH no_os_gpio_set_value(dev->gpio_clr, \
135 NO_OS_GPIO_HIGH)
136
137/* SDO Control Bits */
138#define AD5449_SDO_FULL 0
139#define AD5449_SDO_WEAK 1
140#define AD5449_SDO_OPEN_DRAIN 2
141#define AD5449_SDO_DISABLE 3
142
143/* Initialize SPI and Initial Values for AD5449 Board. */
144int8_t ad5449_init(struct ad5449_dev **device,
146
147/* Free the resources allocated by AD5449_Init(). */
148int32_t ad5449_remove(struct ad5449_dev *dev);
149
150/* Write to shift register via SPI. */
151uint16_t ad5449_set_input_shift_reg(struct ad5449_dev *dev,
152 uint16_t command,
153 uint16_t data);
154
155/* Load and updates the selected DAC with a given value. */
157 uint8_t channel,
158 uint16_t dac_value);
159
160/* Load selected DAC input register with a given value. */
161void ad5449_load_channel(struct ad5449_dev *dev,
162 uint8_t channel,
163 uint16_t dac_value);
164
165/* Read from the selected DAC register. */
166uint16_t ad5449_readback_channel(struct ad5449_dev *dev,
167 uint8_t channel);
168
169/* Update the DAC outputs (all channels). */
170void ad5449_update_all(struct ad5449_dev *dev);
171
172/* Load the DAC input registers. */
173void ad5449_load_all(struct ad5449_dev *dev,
174 int16_t dac_value);
175
176/* Set up the scale where to the output will be cleared on active CLR signal */
177void ad5449_clear_scale_setup(struct ad5449_dev *dev,
178 int8_t type);
179
180/* Enable/disable the Daisy-Chain mode */
181void ad5449_daisy_chain_setup(struct ad5449_dev *dev,
182 int8_t value);
183
184/* Control the SDO output driver strength */
185void ad5449_sdocontrol(struct ad5449_dev *dev,
186 int8_t control_bits);
187
188/* Set up the active clock edge of the SPI interface */
189void ad5449_sclksetup(struct ad5449_dev *dev,
190 int8_t value);
bool_t
Definition ad5446.h:48
bool_t
Definition ad5449.h:40
int8_t ad5449_init(struct ad5449_dev **device, struct ad5449_init_param init_param)
Initialize SPI and Initial Values for AD5449 Board.
Definition ad5449.c:99
ad5449_type_t
Definition ad5449.h:46
@ ID_AD5432
Definition ad5449.h:50
@ ID_AD5443
Definition ad5449.h:52
@ ID_AD5439
Definition ad5449.h:51
@ ID_AD5415
Definition ad5449.h:47
@ ID_AD5449
Definition ad5449.h:53
@ ID_AD5429
Definition ad5449.h:49
@ ID_AD5426
Definition ad5449.h:48
void ad5449_daisy_chain_setup(struct ad5449_dev *dev, int8_t value)
Enable/disable the Daisy-Chain mode.
Definition ad5449.c:369
void ad5449_update_all(struct ad5449_dev *dev)
Update the DAC outputs. This function has a physical result just with devices with two channels.
Definition ad5449.c:293
void ad5449_load_channel(struct ad5449_dev *dev, uint8_t channel, uint16_t dac_value)
Load selected DAC input register with a given value.
Definition ad5449.c:238
uint16_t ad5449_set_input_shift_reg(struct ad5449_dev *dev, uint16_t command, uint16_t data)
Write to input register and read from output register via SPI.
Definition ad5449.c:173
void ad5449_load_all(struct ad5449_dev *dev, int16_t dac_value)
Load the DAC input registers. This function has a physical result just with devices with two channels...
Definition ad5449.c:310
int32_t ad5449_remove(struct ad5449_dev *dev)
Free the resources allocated by ad5449_init().
Definition ad5449.c:150
void ad5449_load_update_channel(struct ad5449_dev *dev, uint8_t channel, uint16_t dac_value)
Loads and updates the selected DAC with a given value.
Definition ad5449.c:213
uint16_t ad5449_readback_channel(struct ad5449_dev *dev, uint8_t channel)
Read from the selected DAC register.
Definition ad5449.c:263
void ad5449_sdocontrol(struct ad5449_dev *dev, int8_t control_bits)
Control the SDO output driver strength. This function is supported by the devices : AD5415,...
Definition ad5449.c:407
void ad5449_clear_scale_setup(struct ad5449_dev *dev, int8_t type)
Set up the scale where to the output will be cleared on active CLR signal.
Definition ad5449.c:330
void ad5449_sclksetup(struct ad5449_dev *dev, int8_t value)
Set up the active clock edge of the SPI interface.
Definition ad5449.c:434
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad5449.h:56
uint8_t resolution
Definition ad5449.h:58
enum bool_t has_ctrl
Definition ad5449.h:59
uint8_t num_channels
Definition ad5449.h:57
Definition ad5449.h:62
enum ad5449_type_t act_device
Definition ad5449.h:69
struct no_os_gpio_desc * gpio_ldac
Definition ad5449.h:66
struct no_os_spi_desc * spi_desc
Definition ad5449.h:64
uint16_t control_reg
Definition ad5449.h:70
struct no_os_gpio_desc * gpio_clr
Definition ad5449.h:67
Definition ad5449.h:73
struct no_os_gpio_init_param gpio_ldac
Definition ad5449.h:77
struct no_os_spi_init_param spi_init
Definition ad5449.h:75
enum ad5449_type_t act_device
Definition ad5449.h:80
struct no_os_gpio_init_param gpio_clr
Definition ad5449.h:78
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