no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5755.h
Go to the documentation of this file.
1/***************************************************************************/
34#ifndef __AD5755_H__
35#define __AD5755_H__
36
37#include <stdint.h>
38#include "no_os_delay.h"
39#include "no_os_gpio.h"
40#include "no_os_spi.h"
41
42
43/* LDAC */
44#define AD5755_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \
45 NO_OS_GPIO_HIGH);
46#define AD5755_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \
47 NO_OS_GPIO_LOW)
48#define AD5755_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \
49 NO_OS_GPIO_HIGH)
50
51/* RESET */
52#define AD5755_RESET_OUT no_os_gpio_direction_output(dev->gpio_rst, \
53 NO_OS_GPIO_HIGH);
54#define AD5755_RESET_LOW no_os_gpio_set_value(dev->gpio_rst, \
55 NO_OS_GPIO_LOW)
56#define AD5755_RESET_HIGH no_os_gpio_set_value(dev->gpio_rst, \
57 NO_OS_GPIO_HIGH)
58
59/* CLEAR */
60#define AD5755_CLEAR_OUT no_os_gpio_direction_output(dev->gpio_clr, \
61 NO_OS_GPIO_HIGH);
62#define AD5755_CLEAR_LOW no_os_gpio_set_value(dev->gpio_clr, \
63 NO_OS_GPIO_LOW)
64#define AD5755_CLEAR_HIGH no_os_gpio_set_value(dev->gpio_clr, \
65 NO_OS_GPIO_HIGH)
66
67/* POC */
68#define AD5755_POC_OUT no_os_gpio_direction_output(dev->gpio_poc, \
69 NO_OS_GPIO_HIGH);
70#define AD5755_POC_LOW no_os_gpio_set_value(dev->gpio_poc, \
71 NO_OS_GPIO_LOW)
72#define AD5755_POC_HIGH no_os_gpio_set_value(dev->gpio_poc, \
73 NO_OS_GPIO_HIGH)
74
75/* Input Shift Register Contents for a Write Operation. */
76#define AD5755_ISR_WRITE (0ul << 23) /* R/nW */
77#define AD5755_ISR_DUT_AD1(x) (((x) & 0x1) << 22) /* Device AddrBit1*/
78#define AD5755_ISR_DUT_AD0(x) (((x) & 0x1) << 21) /* Device AddrBit0*/
79#define AD5755_ISR_DREG(x) (((x) & 0x7) << 18) /* Register AddrBits*/
80#define AD5755_ISR_DAC_AD(x) (((x) & 0x3) << 16) /* Channel AddrBits */
81#define AD5755_ISR_DATA(x) ((x) & 0xFFFF) /* Data Bits*/
82
83/* Nop operation code. */
84#define AD5755_ISR_NOP 0x1CE000
85
86/* AD5755_ISR_DREG(x) options. (Register addresses) */
87#define AD5755_DREG_WR_DAC 0
88#define AD5755_DREG_WR_GAIN 2
89#define AD5755_DREG_WR_GAIN_ALL 3
90#define AD5755_DREG_WR_OFFSET 4
91#define AD5755_DREG_WR_OFFSET_ALL 5
92#define AD5755_DREG_WR_CLR_CODE 6
93#define AD5755_DREG_WR_CTRL_REG 7
94
95/* AD5755_ISR_DAC_AD(x) options. (Channel addresses) */
96#define AD5755_DAC_A 0
97#define AD5755_DAC_B 1
98#define AD5755_DAC_C 2
99#define AD5755_DAC_D 3
100
101/* Gain register definition. */
102#define AD5755_GAIN_ADJUSTMENT(x) ((x) & 0xFFFF)
103
104/* Offset register definition. */
105#define AD5755_OFFSET_ADJUSTMENT(x) ((x) & 0xFFFF)
106
107/* Clear Code Register definition. */
108#define AD5755_CLEAR_CODE(x) ((x) & 0xFFFF)
109
110/* Control Register definition. */
111#define AD5755_CTRL_CREG(x) (((x) & 0x7) << 13)
112#define AD5755_CTRL_DATA(x) ((x) & 0x1FFF)
113
114/* AD5755_CTRL_CREG(x) options. */
115#define AD5755_CREG_SLEW 0 // Slew rate control register(one per channel)
116#define AD5755_CREG_MAIN 1 // Main control register
117#define AD5755_CREG_DAC 2 // DAC control register(one per channel)
118#define AD5755_CREG_DC_DC 3 // DC-to-dc control register
119#define AD5755_CREG_SOFT 4 // Software register
120
121/* Slew Rate Control Register definition. */
122#define AD5755_SLEW_SREN (1 << 12)
123#define AD5755_SLEW_SR_CLOCK(x) (((x) & 0xF) << 3)
124#define AD5755_SLEW_SR_STEP(x) (((x) & 0x7) << 0)
125
126/* AD5755_SLEW_SR_CLOCK(x) options. */
127#define AD5755_SR_CLK_64K 0
128#define AD5755_SR_CLK_32k 1
129#define AD5755_SR_CLK_16k 2
130#define AD5755_SR_CLK_8K 3
131#define AD5755_SR_CLK_4K 4
132#define AD5755_SR_CLK_2K 5
133#define AD5755_SR_CLK_1K 6
134#define AD5755_SR_CLK_500 7
135#define AD5755_SR_CLK_250 8
136#define AD5755_SR_CLK_125 9
137#define AD5755_SR_CLK_64 10
138#define AD5755_SR_CLK_32 11
139#define AD5755_SR_CLK_16 12
140#define AD5755_SR_CLK_8 13
141#define AD5755_SR_CLK_4 14
142#define AD5755_SR_CLK_0_5 15
143
144/* AD5755_SLEW_SR_STEP(x) options. */
145#define AD5755_STEP_1 0
146#define AD5755_STEP_2 1
147#define AD5755_STEP_4 2
148#define AD5755_STEP_16 3
149#define AD5755_STEP_32 4
150#define AD5755_STEP_64 5
151#define AD5755_STEP_128 6
152#define AD5755_STEP_256 7
153
154/* Main Control Register definition. */
155#define AD5755_MAIN_POC (1 << 12)
156#define AD5755_MAIN_STATREAD (1 << 11)
157#define AD5755_MAIN_EWD (1 <<10)
158#define AD5755_MAIN_WD(x) (((x) & 0x3) << 8)
159#define AD5755_MAIN_SHTCCTLIM(x) (((x) & 0x1) << 6)
160#define AD5755_MAIN_OUTEN_ALL (1 << 5)
161#define AD5755_MAIN_DCDC_ALL (1 << 4)
162
163/* AD5755_MAIN_WD(x) options. */
164#define AD5755_WD_5MS 0 // 5 ms timeout period
165#define AD5755_WD_10MS 1 // 10 ms timeout period
166#define AD5755_WD_100MS 2 // 100 ms timeout period
167#define AD5755_WD_200MS 3 // 200 ms timeout period
168
169/* AD5755_MAIN_SHTCCTLIM(x) options. */
170#define AD5755_LIMIT_16_MA 0 // 16 mA (default)
171#define AD5755_LIMIT_8_MA 1 // 8 mA
172
173/* DAC Control Register definition. */
174#define AD5755_DAC_INT_ENABLE (1 << 8)
175#define AD5755_DAC_CLR_EN (1 << 7)
176#define AD5755_DAC_OUTEN (1 << 6)
177#define AD5755_DAC_RSET (1 << 5)
178#define AD5755_DAC_DC_DC (1 << 4)
179#define AD5755_DAC_OVRNG (1 << 3)
180#define AD5755_DAC_R(x) ((x) & 0x7)
181
182/* AD5755_DAC_R(x) options. */
183#define AD5755_R_0_5_V 0 // 0 V to 5 V voltage range (default)
184#define AD5755_R_0_10_V 1 // 0 V to 10 V voltage range
185#define AD5755_R_M5_P5_V 2 // -5 V to +5 V voltage range
186#define AD5755_R_M10_P10_V 3 // -10 V to 10 V voltage range
187#define AD5755_R_4_20_MA 4 // 4 mA to 20 mA current range
188#define AD5755_R_0_20_MA 5 // 0 mA to 20 mA current range
189#define AD5755_R_0_24_MA 6 // 0 mA to 24 mA current range
190
191/* DC-to-DC Control Register definition. */
192#define AD5755_DC_DC_COMP (1 << 6)
193#define AD5755_DC_DC_PHASE(x) (((x) & 0x3) << 4)
194#define AD5755_DC_DC_FREQ(x) (((x) & 0x3) << 2)
195#define AD5755_DC_DC_MAX_V(x) (((x) & 0x3) << 0)
196
197/* AD5755_DC_DC_PHASE(x) options. */
198#define AD5755_PHASE_ALL_DC_DC 0 // all dc-dc converters clock on same edge
199#define AD5755_PHASE_AB_CD 1 // Ch A,B clk same edge, C,D opposite edge
200#define AD5755_PHASE_AC_BD 2 // Ch A,C clk same edge, B,D opposite edge
201#define AD5755_PHASE_A_B_C_D_90 3 // A,B,C,D clock 90 degree out of phase
202
203/* AD5755_DC_DC_FREQ(x) options. */
204#define AD5755_FREQ_250_HZ 0 // 250 +/- 10% kHz
205#define AD5755_FREQ_410_HZ 1 // 410 +/- 10% kHz
206#define AD5755_FREQ_650_HZ 2 // 650 +/- 10% kHz
207
208/* AD5755_DC_DC_MAX_V(x) options. */
209#define AD5755_MAX_23V 0 // 23 V + 1 V/-1.5 V (default)
210#define AD5755_MAX_24_5V 1 // 24.5 V +/- 1 V
211#define AD5755_MAX_27V 2 // 27 V +/- 1 V
212#define AD5755_MAX_29_5V 3 // 29.5 V +/- 1V
213
214/* Software Register definition. */
215#define AD5755_SOFT_USER_BIT (1 << 12)
216#define AD5755_SOFT_RESET_CODE(x) ((x) & 0xFFF)
217
218/* AD5755_SOFT_RESET_CODE(x) options. */
219#define AD5755_RESET_CODE 0x555 // Performs a reset of the AD5755.
220#define AD5755_SPI_CODE 0x195 // If watchdog is enabled, 0x195 must be
221// written to the software register within
222// the programmed timeout period.
223
224/* Input Shift Register Contents for a Read Operation. */
225#define AD5755_ISR_READ (1 << 23)
226/* Same as Input Shift Register Contents for a Write Operation. */
227/*
228#define AD5755_ISR_DUT_AD1(x) (((x) & 0x1) << 22)
229#define AD5755_ISR_DUT_AD0(x) (((x) & 0x1) << 21)
230*/
231#define AD5755_ISR_RD(x) (((x) & 0x1F) << 16)
232
233/* AD5755_ISR_RD(x) options. (Read address decoding) */
234#define AD5755_RD_DATA_REG(x) (((x) & 0x3) + 0)
235#define AD5755_RD_CTRL_REG(x) (((x) & 0x3) + 4)
236#define AD5755_RD_GAIN_REG(x) (((x) & 0x3) + 8)
237#define AD5755_RD_OFFSET_REG(x) (((x) & 0x3) + 12)
238#define AD5755_RD_CODE_REG(x) (((x) & 0x3) + 16)
239#define AD5755_RD_SR_CTRL_REG(x) (((x) & 0x3) + 20)
240#define AD5755_RD_STATUS_REG 24
241#define AD5755_RD_MAIN_CTRL_REG 25
242#define AD5755_RD_Dc_DC_CTRL_REG 26
243
244/* Status Register definition. */
245/* channelA = 0 ... channelD = 3 */
246#define AD5755_STATUS_DC_DC(x) (1 << (12 + (x)))
247#define AD5755_STATUS_USER_BIT (1 << 11)
248#define AD5755_STATUS_PEC_ERROR (1 << 10)
249#define AD5755_STATUS_RAMP_ACTIVE (1 << 9)
250#define AD5755_STATUS_OVER_TEMP (1 << 8)
251/* channelA = 0 ... channelD = 3 */
252#define AD5755_STATUS_VOUT_FAULT(x) (1 << (4 + (x)))
253#define AD5755_STATUS_IOUT_FAULT(x) (1 << (0 + (x)))
254
255#define AD5755_CRC_POLYNOMIAL 0x07 // P(x)=x^8+x^2+x^1+1 = 100000111
256#define AD5755_CRC_CHECK_CODE 0x00
257
272
280 uint8_t poc_bit;
288
293 uint8_t rset_bits[4];
295 uint8_t ovrng_bits[4];
296
311};
312
313/* Supported devices */
319
321 /* SPI */
323 /* GPIO */
328 /* Device Settings */
331};
332
344
346int8_t ad5755_init(struct ad5755_dev **device,
348
350int32_t ad5755_remove(struct ad5755_dev *dev);
351
353int32_t ad5755_get_register_value(struct ad5755_dev *dev,
354 uint8_t register_address);
355
357uint16_t ad5755_set_register_value(struct ad5755_dev *dev,
358 uint8_t register_address,
359 uint8_t channel,
360 uint16_t register_value);
361
363void ad5755_software_reset(struct ad5755_dev *dev);
364
366void ad5755_watch_dog_setup(struct ad5755_dev *dev,
367 uint8_t wtd_enable,
368 uint8_t timeout);
369
372
375 uint8_t ctrl_reg_address,
376 uint8_t channel,
377 uint16_t reg_value);
378
380uint8_t ad5755_check_crc(uint8_t* data,
381 uint8_t bytes_number);
382
385void ad5755_set_channel_power(struct ad5755_dev *dev,
386 uint8_t channel,
387 uint8_t pwr_status);
388
390void ad5755_set_channel_range(struct ad5755_dev *dev,
391 uint8_t channel,
392 uint8_t range);
393
396 uint8_t channel,
397 uint8_t clear_en);
398
400void ad5755_slew_rate_ctrl(struct ad5755_dev *dev,
401 int8_t channel,
402 int8_t sr_en,
403 int8_t updt_freq,
404 int8_t step_size);
405
407float ad5755_set_voltage(struct ad5755_dev *dev,
408 uint8_t channel,
409 float voltage);
410
412float ad5755_set_current(struct ad5755_dev *dev,
413 uint8_t channel,
414 float m_acurrent);
415
416#endif // __AD5755_H__
uint32_t timeout
Definition ad413x.c:46
void ad5755_feed_watch_dog_timer(struct ad5755_dev *dev)
Write a "service pulse" to the AD5755 watchdog timer when enabled.
Definition ad5755.c:338
uint16_t ad5755_set_register_value(struct ad5755_dev *dev, uint8_t register_address, uint8_t channel, uint16_t register_value)
Writes data into a register.
Definition ad5755.c:252
void ad5755_set_control_registers(struct ad5755_dev *dev, uint8_t ctrl_reg_address, uint8_t channel, uint16_t reg_value)
Configures one of the control registers.
Definition ad5755.c:365
void ad5755_slew_rate_ctrl(struct ad5755_dev *dev, int8_t channel, int8_t sr_en, int8_t updt_freq, int8_t step_size)
Configures the Digital Slew Rate Control.
Definition ad5755.c:567
void ad5755_set_channel_range(struct ad5755_dev *dev, uint8_t channel, uint8_t range)
Sets the range of a channel.
Definition ad5755.c:461
int8_t ad5755_init(struct ad5755_dev **device, struct ad5755_init_param init_param)
Initializes the device and powers-up all channels. The device is initialized with the values held by ...
Definition ad5755.c:51
ad5755_type_t
Definition ad5755.h:314
@ ID_AD5755_1
Definition ad5755.h:316
@ ID_AD5757
Definition ad5755.h:317
@ ID_AD5755
Definition ad5755.h:315
void ad5755_watch_dog_setup(struct ad5755_dev *dev, uint8_t wtd_enable, uint8_t timeout)
Enables/Disables watchdog timer and sets the timeout period.
Definition ad5755.c:314
float ad5755_set_current(struct ad5755_dev *dev, uint8_t channel, float m_acurrent)
Sets the output current of a channel.
Definition ad5755.c:686
void ad5755_software_reset(struct ad5755_dev *dev)
Performs a software reset to the device.
Definition ad5755.c:293
uint8_t ad5755_check_crc(uint8_t *data, uint8_t bytes_number)
Computes the CRC for a data buffer.
Definition ad5755.c:384
float ad5755_set_voltage(struct ad5755_dev *dev, uint8_t channel, float voltage)
Sets the output voltage of a channel.
Definition ad5755.c:594
int32_t ad5755_remove(struct ad5755_dev *dev)
Free the resources allocated by ad5755_init().
Definition ad5755.c:151
int32_t ad5755_get_register_value(struct ad5755_dev *dev, uint8_t register_address)
Reads the value of a register.
Definition ad5755.c:186
void ad5755_channel_clear_enable(struct ad5755_dev *dev, uint8_t channel, uint8_t clear_en)
Selects if the channel clears when CLEAR pin is activated.
Definition ad5755.c:522
void ad5755_set_channel_power(struct ad5755_dev *dev, uint8_t channel, uint8_t pwr_status)
Allows power-up/down of the dc-to-dc converter, DAC and internal amplifiers for the selected channel.
Definition ad5755.c:420
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of Delay functions.
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad5755.h:320
struct no_os_gpio_desc * gpio_poc
Definition ad5755.h:327
struct ad5755_setup * p_ad5755_st
Definition ad5755.h:329
enum ad5755_type_t this_device
Definition ad5755.h:330
struct no_os_gpio_desc * gpio_clr
Definition ad5755.h:326
struct no_os_gpio_desc * gpio_ldac
Definition ad5755.h:324
struct no_os_spi_desc * spi_desc
Definition ad5755.h:322
struct no_os_gpio_desc * gpio_rst
Definition ad5755.h:325
Definition ad5755.h:333
struct no_os_gpio_init_param gpio_ldac
Definition ad5755.h:337
struct no_os_gpio_init_param gpio_poc
Definition ad5755.h:340
struct no_os_spi_init_param spi_init
Definition ad5755.h:335
struct no_os_gpio_init_param gpio_clr
Definition ad5755.h:339
enum ad5755_type_t this_device
Definition ad5755.h:342
struct no_os_gpio_init_param gpio_rst
Definition ad5755.h:338
Stores the settings that will be written to the device when the "AD5755_Init" functions is called.
Definition ad5755.h:263
uint8_t pin_ad1state
Definition ad5755.h:267
uint8_t dc_dc_comp_bit
Definition ad5755.h:300
uint8_t enable_packet_error_check
Definition ad5755.h:271
uint8_t poc_bit
Definition ad5755.h:280
uint8_t pin_ad0state
Definition ad5755.h:265
uint8_t dc_dc_max_vbit
Definition ad5755.h:310
uint8_t sht_cc_lim_bit
Definition ad5755.h:287
uint8_t rset_bits[4]
Definition ad5755.h:293
uint8_t stat_readbit
Definition ad5755.h:282
uint8_t dc_dc_freq_bit
Definition ad5755.h:306
uint8_t dc_dc_phase_bit
Definition ad5755.h:304
uint8_t ovrng_bits[4]
Definition ad5755.h:295
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