Skip to content

Commit 61ececb

Browse files
committed
drivers: dac: ad5710r: Add doc for AD5710r
Add rst documentation file for AD5710r driver. Signed-off-by: SGudla <[email protected]>
1 parent 056ac09 commit 61ececb

File tree

1 file changed

+239
-0
lines changed

1 file changed

+239
-0
lines changed

drivers/dac/ad5710r/README.rst

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
AD5710R no-OS Driver
2+
====================
3+
4+
.. no-os-doxygen::
5+
6+
Supported Devices
7+
-----------------
8+
9+
- :adi:`AD5710R`
10+
11+
Overview
12+
--------
13+
14+
The AD5710R is an 8-channel, 16-bit precision digital-to-analog converter (DAC)
15+
with On-chip reference. It features
16+
both voltage and current output modes, making it versatile for driving various
17+
industrial loads. The device supports SPI communication with CRC error
18+
checking, hardware and software LDAC triggering, and multiple operating modes
19+
per channel. The device includes internal/external voltage reference options,
20+
flexible output ranges.
21+
22+
Applications
23+
-------------
24+
25+
- Optical networking
26+
- Instrumentation
27+
- Data acquisition
28+
- Automatic test equipment
29+
- Process control
30+
- Industrial automation
31+
32+
Output Modes
33+
------------
34+
35+
+---------------------------+-----------------+-----------+-----------------+
36+
| Output Mode | Description | Value | Typical Use |
37+
| | | | Case |
38+
+---------------------------+-----------------+-----------+-----------------+
39+
| IMODE | Current output | 0x0 | Driving voltage |
40+
| | mode | | controlled |
41+
| | | | devices |
42+
+---------------------------+-----------------+-----------+-----------------+
43+
| VMODE | Voltage output | 0x1 | Driving current |
44+
| | mode | | controlled |
45+
| | | | devices |
46+
+---------------------------+-----------------+-----------+-----------------+
47+
48+
Write Modes
49+
-----------
50+
51+
+----------------------------------+-----------------------+-----------------+
52+
| Write Mode | Description | Typical Use |
53+
| | | Case |
54+
+----------------------------------+-----------------------+-----------------+
55+
| AD5710R_WRITE_DAC_REGS | Write directly to DAC | Immediate |
56+
| | registers, immediate | output update |
57+
| | output update | |
58+
+----------------------------------+-----------------------+-----------------+
59+
| AD5710R_WRITE_INPUT_REGS | Write to input | Synchronized |
60+
| | registers, manual | updates with |
61+
| | LDAC trigger required | LDAC |
62+
+----------------------------------+-----------------------+-----------------+
63+
| AD5710R_WRITE_INPUT_REGS_AND_ | Write to input | Synchronized |
64+
| TRIGGER_LDAC | registers and auto | updates with |
65+
| | trigger LDAC | LDAC |
66+
+----------------------------------+-----------------------+-----------------+
67+
68+
Device Configuration
69+
---------------------
70+
71+
Device Setup and Configuration
72+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73+
74+
The ``ad5710r_init`` function initializes and configures the AD5710R,
75+
involving memory allocation, SPI initialization, GPIO setup for RESET and LDAC
76+
pins, and comprehensive device configuration. The initialization process includes
77+
product ID verification, scratch pad testing, and configuration of operating
78+
modes, output ranges, reference selection, and CRC settings.
79+
80+
Resource Management
81+
~~~~~~~~~~~~~~~~~~~
82+
83+
The ``ad5710r_remove`` function deallocates resources associated with the
84+
AD5710R, removing GPIO descriptors, SPI descriptor, and freeing allocated
85+
memory to ensure proper resource release and prevent memory leaks.
86+
87+
SPI Communication
88+
~~~~~~~~~~~~~~~~~
89+
90+
The ``ad5710r_reg_read`` and ``ad5710r_reg_write`` functions handle SPI
91+
interactions for the AD5710R. These functions support both short and long
92+
instruction modes, CRC error checking, and multi-drop configurations.
93+
94+
Channel Configuration
95+
~~~~~~~~~~~~~~~~~~~~
96+
97+
Individual channels can be configured for voltage or current output modes using
98+
``ad5710r_channel_output_select``. Operating modes are set per channel using
99+
``ad5710r_set_operating_mode``, allowing fine-tuned control of each DAC output.
100+
101+
DAC Value Setting
102+
~~~~~~~~~~~~~~~~
103+
104+
DAC values can be set using ``ad5710r_set_dac_value`` for individual channels
105+
or ``ad5710r_set_multidac_value`` for simultaneous updates across multiple
106+
channels. The driver supports different write modes for immediate updates or
107+
synchronized updates using LDAC triggers.
108+
109+
Hardware Features
110+
~~~~~~~~~~~~~~~~
111+
112+
The driver supports hardware LDAC triggering via GPIO pin using
113+
``ad5710r_hw_ldac_trigger`` and software LDAC triggering using
114+
``ad5710r_sw_ldac_trigger``. Reference voltage can be configured as internal
115+
or external using ``ad5710r_set_reference``.
116+
117+
Driver Initialization Example
118+
-----------------------------
119+
120+
.. code-block:: C
121+
122+
#include <stdint.h>
123+
#include "no_os_delay.h"
124+
#include "no_os_spi.h"
125+
#include "no_os_gpio.h"
126+
#include "ad5710r.h"
127+
128+
// Initialization parameters for the AD5710R device
129+
struct ad5710r_init_param init_param = {
130+
.chip_id = AD5710R_ID,
131+
.spi_cfg = {
132+
.stream_mode_length = 0,
133+
.addr_asc = 0,
134+
.single_instr = 1,
135+
.short_instr = 0,
136+
.stream_length_keep_value = 0
137+
},
138+
.spi_param = &spi_init_param, // SPI configuration
139+
.reset_gpio_param_optional = &reset_gpio_param, // Optional reset GPIO
140+
.ldac_gpio_param_optional = &ldac_gpio_param, // Optional LDAC GPIO
141+
.vref_enable = AD5710R_INTERNAL_VREF_PIN_2P5V, // Internal 2.5V reference
142+
.chn_op_mode = {
143+
AD5710R_CH_OPERATING_MODE_0, // Channel 0
144+
AD5710R_CH_OPERATING_MODE_0, // Channel 1
145+
AD5710R_CH_OPERATING_MODE_0, // Channel 2
146+
AD5710R_CH_OPERATING_MODE_0, // Channel 3
147+
AD5710R_CH_OPERATING_MODE_0, // Channel 4
148+
AD5710R_CH_OPERATING_MODE_0, // Channel 5
149+
AD5710R_CH_OPERATING_MODE_0, // Channel 6
150+
AD5710R_CH_OPERATING_MODE_0 // Channel 7
151+
},
152+
.range = AD5710R_CH_OUTPUT_RANGE_0_VREF, // 0V to VREF range
153+
.hw_ldac_mask = 0x00, // No hardware LDAC enabled
154+
.sw_ldac_mask = 0xFF, // All channels software LDAC enabled
155+
.crc_en = 0, // Disable CRC error checking
156+
.mux_out_sel = VOUT0, // Monitor channel 0 voltage output
157+
.dev_addr = 0 // Device address for multi-drop
158+
};
159+
160+
// Device structure for the AD5710R
161+
struct ad5710r_desc *ad5710r_device;
162+
163+
// Set up the AD5710R device
164+
int32_t setup_ad5710r() {
165+
int32_t ret;
166+
uint16_t dac_value;
167+
168+
// Initialize the device
169+
ret = ad5710r_init(&ad5710r_device, &init_param);
170+
if (ret) {
171+
printf("AD5710R initialization failed with error %d\n", ret);
172+
return ret;
173+
}
174+
175+
// Configure channel 0 for voltage output mode
176+
ret = ad5710r_channel_output_select(ad5710r_device, 0, VMODE);
177+
if (ret) {
178+
printf("Channel 0 configuration failed with error %d\n", ret);
179+
return ret;
180+
}
181+
182+
// Set DAC value for channel 0 (mid-scale: 32768 for 16-bit)
183+
dac_value = 32768;
184+
ret = ad5710r_set_dac_value(ad5710r_device, dac_value, 0,
185+
AD5710R_WRITE_DAC_REGS);
186+
if (ret) {
187+
printf("Setting DAC value failed with error %d\n", ret);
188+
return ret;
189+
}
190+
191+
printf("AD5710R setup completed successfully\n");
192+
return 0;
193+
}
194+
195+
// Example of multi-channel synchronized update
196+
int32_t multi_channel_update() {
197+
int32_t ret;
198+
uint16_t dac_value = 40000; // Near full scale
199+
uint8_t channel_mask = 0x0F; // Channels 0-3
200+
201+
// Set multiple channels simultaneously with LDAC trigger
202+
ret = ad5710r_set_multidac_value(ad5710r_device, dac_value,
203+
channel_mask,
204+
AD5710R_WRITE_INPUT_REGS_AND_TRIGGER_LDAC);
205+
if (ret) {
206+
printf("Multi-channel update failed with error %d\n", ret);
207+
return ret;
208+
}
209+
210+
printf("Multi-channel update completed successfully\n");
211+
return 0;
212+
}
213+
214+
// Main function for AD5710R demonstration
215+
int main() {
216+
int32_t status;
217+
218+
// Setup the device
219+
status = setup_ad5710r();
220+
if (status) {
221+
return status;
222+
}
223+
224+
// Perform multi-channel update
225+
status = multi_channel_update();
226+
if (status) {
227+
return status;
228+
}
229+
230+
// Clean up resources
231+
status = ad5710r_remove(ad5710r_device);
232+
if (status) {
233+
printf("Device cleanup failed with error %d\n", status);
234+
return status;
235+
}
236+
237+
printf("AD5710R demonstration completed successfully\n");
238+
return 0;
239+
}

0 commit comments

Comments
 (0)