no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5629r.h
Go to the documentation of this file.
1/**************************************************************************/
34
35#ifndef _AD5629R_H_
36#define _AD5629R_H_
37
38#include <stdint.h>
39#include "no_os_gpio.h"
40#include "no_os_spi.h"
41#include "no_os_i2c.h"
42
43/* AD5629R Device I2C Address */
44#define AD5629R_I2C_ADDR_0 0x54 // A1=0 and A0=0 (A0_Pin=High)
45#define AD5629R_I2C_ADDR_1 0x56 // A1=1 and A0=0 (A0_Pin=NC)
46#define AD5629R_I2C_ADDR_2 0x57 // A1=1 and A0=1 (A0_Pin=Low)
47
48#define MAX_RESOLUTION 16
49
50/* Commands */
51#define AD5629R_WRITE_N 0x0
52#define AD5629R_UPDATE_N 0x1
53#define AD5629R_WRITE_N_UPDATE_ALL 0x2
54#define AD5629R_WRITE_N_UPDATE_N 0x3
55#define AD5629R_POWER 0x4
56#define AD5629R_LOAD_CLEAR_REG 0x5
57#define AD5629R_LOAD_LDAC_REG 0x6
58#define AD5629R_RESET 0x7
59#define AD5629R_REFERENCE 0x8
60
61/* AD5629R GPIO */
62/* LDAC - GPIO0 */
63#define AD5629R_LDAC_OUT no_os_gpio_direction_output(dev->gpio_ldac, \
64 NO_OS_GPIO_HIGH);
65#define AD5629R_LDAC_LOW no_os_gpio_set_value(dev->gpio_ldac, \
66 NO_OS_GPIO_LOW)
67#define AD5629R_LDAC_HIGH no_os_gpio_set_value(dev->gpio_ldac, \
68 NO_OS_GPIO_HIGH)
69/* CLR - GPIO1 */
70#define AD5629R_CLR_OUT no_os_gpio_direction_output(dev->gpio_clr, \
71 NO_OS_GPIO_HIGH);
72#define AD5629R_CLR_LOW no_os_gpio_set_value(dev->gpio_clr, \
73 NO_OS_GPIO_LOW)
74#define AD5629R_CLR_HIGH no_os_gpio_set_value(dev->gpio_clr, \
75 NO_OS_GPIO_HIGH)
76
77/* DAC Addresses */
78#define AD5629R_DAC_A_ADDR 0x0
79#define AD5629R_DAC_B_ADDR 0x1
80#define AD5629R_DAC_C_ADDR 0x2
81#define AD5629R_DAC_D_ADDR 0x3
82#define AD5629R_DAC_E_ADDR 0x4
83#define AD5629R_DAC_F_ADDR 0x5
84#define AD5629R_DAC_G_ADDR 0x6
85#define AD5629R_DAC_H_ADDR 0x7
86#define AD5629R_DAC_ALL_ADDR 0xF
87
88/* DAC Selection */
89#define DAC_A_SEL 1
90#define DAC_B_SEL 2
91#define DAC_C_SEL 4
92#define DAC_D_SEL 8
93#define DAC_E_SEL 16
94#define DAC_F_SEL 32
95#define DAC_G_SEL 64
96#define DAC_H_SEL 128
97
98/* Power modes */
99#define PWR_NORMAL 0
100#define PWR_1K_TO_GND 1
101#define PWR_100K_TO_GND 2
102#define PWR_3_STATE 3
103
104/* Clear code values */
105#define CLR_TO_ZEROSCALE 0
106#define CLR_TO_MIDSCALE 1
107#define CLR_TO_FULLSCALE 2
108#define CLR_NOOP 3
109
110/* Internal reference status */
111#define REF_ON 1
112#define REF_OFF 0
113
114/* Supported devices */
122
127
132
134 /* I2C */
136 /* SPI */
138 /* GPIO */
141 /* Device Settings */
143};
144
146 /* I2C */
148 /* SPI */
150 /* GPIO */
153 /* Device Settings */
155};
156
157/* Initializes the communication with the device. */
158int8_t ad5629r_init(struct ad5629r_dev **device,
160/* Free the resources allocated by AD5629R_Init(). */
161int32_t ad5629r_remove(struct ad5629r_dev *dev);
162/* Writes a value to Input Register N of selected DAC channel. */
163void ad5629r_write_reg_n(struct ad5629r_dev *dev,
164 uint8_t dac_n,
165 uint16_t dac_value);
166/* Updates selected DAC register. */
167void ad5629r_update_dac_n(struct ad5629r_dev *dev,
168 uint8_t dac_n);
169/* Writes a value to Input Register N of selected DAC channel, then updates all. */
171 uint8_t dac_n,
172 uint16_t dac_value);
173/* Writes a value to Input Register N and updates the respective DAC channel. */
175 uint8_t dac_n,
176 uint16_t dac_value);
177/* Sets the power mode for one or more selected DAC channels. */
178void ad5629r_set_power_mode(struct ad5629r_dev *dev,
179 uint8_t dac_sel,
180 uint8_t mode);
181/* Loads the Clear Code Register with a certain value. */
183 uint8_t clear_value);
184/* Loads the LDAC register with a certain value. */
185void ad5629r_load_ldac_reg(struct ad5629r_dev *dev,
186 uint8_t dac_sel);
187/* Makes a power-on reset. */
188void ad5629r_reset(struct ad5629r_dev *dev);
189/* Turns on/off the internal reference. */
190void ad5629r_set_ref(struct ad5629r_dev *dev,
191 uint8_t status);
192
193
194#endif /* AD5629_H_ */
void ad5629r_set_power_mode(struct ad5629r_dev *dev, uint8_t dac_sel, uint8_t mode)
Sets the power mode for one or more selected DAC channels.
Definition ad5629r.c:296
void ad5629r_write_reg_n(struct ad5629r_dev *dev, uint8_t dac_n, uint16_t dac_value)
Writes a value to Input Register N of selected DAC channel.
Definition ad5629r.c:220
void ad5629r_write_reg_nupdate_all(struct ad5629r_dev *dev, uint8_t dac_n, uint16_t dac_value)
Writes a value to Input Register N of selected DAC channel, then updates all.
Definition ad5629r.c:253
int32_t ad5629r_remove(struct ad5629r_dev *dev)
Free the resources allocated by AD5629R_Init().
Definition ad5629r.c:112
int8_t ad5629r_init(struct ad5629r_dev **device, struct ad5629r_init_param init_param)
Initializes the communication with the device.
Definition ad5629r.c:74
void ad5629r_update_dac_n(struct ad5629r_dev *dev, uint8_t dac_n)
Updates selected DAC register.
Definition ad5629r.c:236
ad5629r_type
Definition ad5629r.h:115
@ ID_AD5629R
Definition ad5629r.h:116
@ ID_AD5668
Definition ad5629r.h:118
@ ID_AD5628
Definition ad5629r.h:120
@ ID_AD5648
Definition ad5629r.h:119
@ ID_AD5669R
Definition ad5629r.h:117
void ad5629r_reset(struct ad5629r_dev *dev)
Makes a power-on reset.
Definition ad5629r.c:364
comm_type_t
Definition ad5629r.h:123
@ com_spi
Definition ad5629r.h:124
@ com_i2c
Definition ad5629r.h:125
void ad5629r_set_ref(struct ad5629r_dev *dev, uint8_t status)
Turns on/off the internal reference.
Definition ad5629r.c:380
void ad5629r_load_clear_code_reg(struct ad5629r_dev *dev, uint8_t clear_value)
Loads the Clear Code Register with a certain value.
Definition ad5629r.c:321
void ad5629r_write_reg_nupdate_n(struct ad5629r_dev *dev, uint8_t dac_n, uint16_t dac_value)
Writes a value to Input Register N and updates the respective DAC channel.
Definition ad5629r.c:271
void ad5629r_load_ldac_reg(struct ad5629r_dev *dev, uint8_t dac_sel)
Loads the LDAC register with a certain value.
Definition ad5629r.c:346
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of GPIO Interface.
Header file of I2C Interface.
Header file of SPI Interface.
Definition ad5629r.h:128
enum comm_type_t communication
Definition ad5629r.h:130
uint32_t resolution
Definition ad5629r.h:129
Definition ad5629r.h:133
struct no_os_i2c_desc * i2c_desc
Definition ad5629r.h:135
struct no_os_gpio_desc * gpio_clr
Definition ad5629r.h:140
struct no_os_gpio_desc * gpio_ldac
Definition ad5629r.h:139
struct no_os_spi_desc * spi_desc
Definition ad5629r.h:137
enum ad5629r_type act_device
Definition ad5629r.h:142
Definition ad5629r.h:145
struct no_os_i2c_init_param i2c_init
Definition ad5629r.h:147
struct no_os_spi_init_param spi_init
Definition ad5629r.h:149
enum ad5629r_type act_device
Definition ad5629r.h:154
struct no_os_gpio_init_param gpio_clr
Definition ad5629r.h:152
struct no_os_gpio_init_param gpio_ldac
Definition ad5629r.h:151
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