no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5686.h
Go to the documentation of this file.
1/***************************************************************************/
36
37#include <stdint.h>
38#include "no_os_gpio.h"
39#include "no_os_spi.h"
40#include "no_os_i2c.h"
41
42/* Control Bits */
43#define AD5686_CTRL_NOP 0
44#define AD5686_CTRL_WRITE 1
45#define AD5686_CTRL_UPDATE 2
46#define AD5686_CTRL_WRITEUPDATE 3
47#define AD5686_CTRL_PWR 4
48#define AD5686_CTRL_LDAC_MASK 5
49#define AD5686_CTRL_SWRESET 6
50#define AD5686_CTRL_IREF_REG 7
51#define AD5686_CTRL_DCEN 8
52#define AD5686_CTRL_RB_REG 9
53
54#define AD5683_CMD_WR_CTRL_REG 4
55#define AD5683_CTRL_RB_REG 5
56
57/* Power-down operation modes masks */
58#define AD5686_PWRM_NORMAL 0
59#define AD5686_PWRM_1K 1
60#define AD5686_PWRM_100K 2
61#define AD5686_PWRM_THREESTATE 3
62
63#define AD5686_PWRM_MASK 3
64
65/* Enable/disable defines */
66#define AD5686_INTREF_EN 1
67#define AD5686_INTREF_DIS 0
68#define AD5686_DC_EN 1
69#define AD5686_DC_DIS 0
70#define AD5686_RB_EN 1
71#define AD5686_RB_DIS 0
72
73#define MAX_RESOLUTION 16 // Maximum resolution of the supported devices
74
75#define PKT_LENGTH 3 // SPI packet length in byte
76
77#define ADDR_MASK 0xFF // Mask for Address bits
78#define CMD_OFFSET 4 // Offset for Command
79
80#define AD5686_CMD_MASK 0xFF
81#define AD5686_MSB_MASK 0xFF00 // Most significant byte of the data word
82#define AD5686_MSB_OFFSET 8
83#define AD5686_LSB_MASK 0x00FF // Least significant byte of the data word
84#define AD5686_LSB_OFFSET 0
85
86#define AD5683_MIDB_OFFSET 4 // Offset for middle bits
87#define AD5683_MIDB_MASK 0xFF
88#define AD5683_MSB_OFFSET 12
89#define AD5683_MSB_MASK 0xF
90#define AD5683_CMD_MASK 0xF
91#define AD5683_LSB_MASK 0xF
92#define AD5683_LSB_OFFSET 4
93
94#define AD5683_REG_MAP 0
95#define AD5686_REG_MAP 1
96
97/********************** AD5683 Write Control Register Bits ********************/
98
99#define AD5683_CTRL_DCEN(x) (((((x) & 0x1) << 0) << 10) & 0xFC00)
100#define AD5683_CTRL_GM(x) (((((x) & 0x1) << 1) << 10) & 0xFC00)
101#define AD5683_CTRL_INT_REF(x) (((((x) & 0x1) << 2) << 10) & 0xFC00)
102#define AD5683_CTRL_PWRM(x) (((((x) & 0x3) << 3) << 10) & 0xFC00)
103#define AD5683_SW_RESET ((((0x1) << 5) << 10) & 0xFC00)
104
105/* Supported devices */
141
145};
146
165
167 uint8_t resolution;
170 const uint32_t *channel_addr;
171};
172
174 /* I2C */
176 /* SPI */
178 /* GPIO */
182 /* Device Settings */
185 uint32_t ldac_mask;
186};
187
189 /* I2C */
191 /* SPI */
193 /* GPIO */
197 /* Device Settings */
199};
200
201/* Initialize SPI and Initial Values for AD5686 Board. */
202int32_t ad5686_init(struct ad5686_dev **device,
204
205/* Free the resources allocated by ad5686_init(). */
206int32_t ad5686_remove(struct ad5686_dev *dev);
207
208/* Write to input register */
209uint16_t ad5686_set_shift_reg(struct ad5686_dev *dev,
210 uint8_t command,
211 uint8_t address,
212 uint16_t data);
213
214/* Write to Input Register n (dependent on LDAC) */
215void ad5686_write_register(struct ad5686_dev *dev,
216 enum ad5686_dac_channels channel,
217 uint16_t data);
218
219/* Update DAC Register n with contents of Input Register n */
220void ad5686_update_register(struct ad5686_dev *dev,
221 enum ad5686_dac_channels channel);
222
223/* Write to and update DAC channel n */
225 enum ad5686_dac_channels channel,
226 uint16_t data);
227
228/* Read back Input Register n */
229uint16_t ad5686_read_back_register(struct ad5686_dev *dev,
230 enum ad5686_dac_channels channel);
231
232/* Power down / power up DAC */
233void ad5686_power_mode(struct ad5686_dev *dev,
234 enum ad5686_dac_channels channel,
235 uint8_t mode);
236
237/* Set up LDAC mask register */
238void ad5686_ldac_mask(struct ad5686_dev *dev,
239 enum ad5686_dac_channels channel,
240 uint8_t enable);
241
242/* Software reset (power-on reset) */
243void ad5686_software_reset(struct ad5686_dev *dev);
244
245/* Write to Internal reference setup register */
247 uint8_t value);
248
249/* Set up DCEN register (daisy-chain enable) */
250void ad5686_daisy_chain_en(struct ad5686_dev *dev,
251 uint8_t value);
252
253/* Set up readback register (readback enable) */
254void ad5686_read_back_en(struct ad5686_dev *dev,
255 uint8_t value);
256
257/* Set Gain mode */
258int32_t ad5686_gain_mode(struct ad5686_dev *dev, uint8_t value);
int32_t ad5686_remove(struct ad5686_dev *dev)
Free the resources allocated by ad5686_init().
Definition ad5686.c:345
void ad5686_software_reset(struct ad5686_dev *dev)
Software reset (power-on reset)
Definition ad5686.c:663
void ad5686_daisy_chain_en(struct ad5686_dev *dev, uint8_t value)
Set up DCEN register (daisy-chain enable)
Definition ad5686.c:700
comm_type
Definition ad5686.h:142
uint16_t ad5686_set_shift_reg(struct ad5686_dev *dev, uint8_t command, uint8_t address, uint16_t data)
Write to input shift register.
Definition ad5686.c:378
void ad5686_internal_reference(struct ad5686_dev *dev, uint8_t value)
Write to Internal reference setup register.
Definition ad5686.c:681
void ad5686_write_update_register(struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint16_t data)
Write to and update DAC channel n.
Definition ad5686.c:502
void ad5686_update_register(struct ad5686_dev *dev, enum ad5686_dac_channels channel)
Update DAC Register n with contents of Input Register n.
Definition ad5686.c:470
uint16_t ad5686_read_back_register(struct ad5686_dev *dev, enum ad5686_dac_channels channel)
Read back Input Register n.
Definition ad5686.c:540
void ad5686_write_register(struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint16_t data)
Write to Input Register n (dependent on LDAC)
Definition ad5686.c:436
void ad5686_ldac_mask(struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t enable)
Set hardware LDAC mask register.
Definition ad5686.c:646
int32_t ad5686_init(struct ad5686_dev **device, struct ad5686_init_param init_param)
Initializes the communication peripheral and the initial Values for AD5686 Board.
Definition ad5686.c:300
ad5686_type
Definition ad5686.h:106
@ ID_AD5686
Definition ad5686.h:118
@ ID_AD5676
Definition ad5686.h:113
@ ID_AD5695R
Definition ad5686.h:129
@ ID_AD5672R
Definition ad5686.h:108
@ ID_AD5679R
Definition ad5686.h:117
@ ID_AD5676R
Definition ad5686.h:114
@ ID_AD5687R
Definition ad5686.h:123
@ ID_AD5687
Definition ad5686.h:122
@ ID_AD5689
Definition ad5686.h:124
@ ID_AD5691R
Definition ad5686.h:136
@ ID_AD5677R
Definition ad5686.h:115
@ ID_AD5679
Definition ad5686.h:116
@ ID_AD5686R
Definition ad5686.h:121
@ ID_AD5685R
Definition ad5686.h:120
@ ID_AD5673R
Definition ad5686.h:109
@ ID_AD5696R
Definition ad5686.h:131
@ ID_AD5675R
Definition ad5686.h:112
@ ID_AD5692R
Definition ad5686.h:137
@ ID_AD5683R
Definition ad5686.h:134
@ ID_AD5693R
Definition ad5686.h:138
@ ID_AD5682R
Definition ad5686.h:133
@ ID_AD5694
Definition ad5686.h:127
@ ID_AD5674
Definition ad5686.h:110
@ ID_AD5696
Definition ad5686.h:130
@ ID_AD5671R
Definition ad5686.h:107
@ ID_AD5693
Definition ad5686.h:139
@ ID_AD5694R
Definition ad5686.h:128
@ ID_AD5684R
Definition ad5686.h:119
@ ID_AD5674R
Definition ad5686.h:111
@ ID_AD5697R
Definition ad5686.h:126
@ ID_AD5681R
Definition ad5686.h:132
@ ID_AD5689R
Definition ad5686.h:125
@ ID_AD5683
Definition ad5686.h:135
void ad5686_read_back_en(struct ad5686_dev *dev, uint8_t value)
Set up readback register (readback enable)
Definition ad5686.c:718
ad5686_dac_channels
Definition ad5686.h:147
@ AD5686_CH_9
Definition ad5686.h:157
@ AD5686_CH_12
Definition ad5686.h:160
@ AD5686_CH_13
Definition ad5686.h:161
@ AD5686_CH_10
Definition ad5686.h:158
@ AD5686_CH_15
Definition ad5686.h:163
@ AD5686_CH_3
Definition ad5686.h:151
@ AD5686_CH_2
Definition ad5686.h:150
@ AD5686_CH_5
Definition ad5686.h:153
@ AD5686_CH_7
Definition ad5686.h:155
@ AD5686_CH_4
Definition ad5686.h:152
@ AD5686_CH_8
Definition ad5686.h:156
@ AD5686_CH_6
Definition ad5686.h:154
@ AD5686_CH_0
Definition ad5686.h:148
@ AD5686_CH_14
Definition ad5686.h:162
@ AD5686_CH_1
Definition ad5686.h:149
@ AD5686_CH_11
Definition ad5686.h:159
int32_t ad5686_gain_mode(struct ad5686_dev *dev, uint8_t value)
Set Gain mode.
Definition ad5686.c:735
void ad5686_power_mode(struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t mode)
Set Power-down mode for DAC channel n.
Definition ad5686.c:601
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
@ I2C
Definition adxl372.h:311
@ SPI
Definition adxl372.h:310
Header file of GPIO Interface.
Header file of I2C Interface.
Header file of SPI Interface.
Definition ad5686.h:166
uint8_t resolution
Definition ad5686.h:167
uint8_t register_map
Definition ad5686.h:168
const uint32_t * channel_addr
Definition ad5686.h:170
enum comm_type communication
Definition ad5686.h:169
Definition ad5686.h:173
enum ad5686_type act_device
Definition ad5686.h:183
struct no_os_gpio_desc * gpio_reset
Definition ad5686.h:179
uint32_t power_down_mask
Definition ad5686.h:184
struct no_os_spi_desc * spi_desc
Definition ad5686.h:177
struct no_os_gpio_desc * gpio_ldac
Definition ad5686.h:180
struct no_os_i2c_desc * i2c_desc
Definition ad5686.h:175
struct no_os_gpio_desc * gpio_gain
Definition ad5686.h:181
uint32_t ldac_mask
Definition ad5686.h:185
Definition ad5686.h:188
struct no_os_gpio_init_param gpio_reset
Definition ad5686.h:194
struct no_os_gpio_init_param gpio_gain
Definition ad5686.h:196
struct no_os_spi_init_param spi_init
Definition ad5686.h:192
enum ad5686_type act_device
Definition ad5686.h:198
struct no_os_gpio_init_param gpio_ldac
Definition ad5686.h:195
struct no_os_i2c_init_param i2c_init
Definition ad5686.h:190
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 I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128