Skip to content

Commit 2a253df

Browse files
jvelasc2buha
authored andcommitted
drivers: dac: ad3552r: Add README for AD3552R
Added the rst readme document for the AD3552R driver. Also modified the sphinx driver doc to add the corresponding source for this new readme. Signed-off-by: Joyce Velasco <joyce.velasco@analog.com>
1 parent 947cea8 commit 2a253df

File tree

3 files changed

+219
-0
lines changed

3 files changed

+219
-0
lines changed

doc/sphinx/source/drivers/ad3552r.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../../../drivers/dac/ad3552r/README.rst

doc/sphinx/source/drivers_doc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ DIGITAL TO ANALOG CONVERTERS
7474

7575
drivers/max22017
7676

77+
drivers/ad3552r
78+
7779
FREQUENCY GENERATORS
7880
====================
7981
.. toctree::

drivers/dac/ad3552r/README.rst

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
AD3552R no-OS Driver
2+
=====================
3+
4+
Supported Devices
5+
-----------------
6+
7+
- :adi:`AD3552R`
8+
9+
Overview
10+
--------
11+
12+
The AD3552R is a dual-channel digital-to-analog converter (DAC) designed
13+
for precision signal processing applications, supporting bipolar (-10V
14+
to 10V) and unipolar (0V to 5V) output configurations. It operates
15+
via SPI communication in single, dual, and quad modes. The DAC features
16+
adjustable gain and offset, a scratch pad test, and allows for both
17+
hardware and software resets. Dedicated registers provide control over
18+
channel attributes, streaming, and input/output settings.
19+
20+
Applications
21+
-------------
22+
23+
- Instrumentation
24+
- Hardware in the loop
25+
- Process control equipment
26+
- Medical devices
27+
- Automated test equipment
28+
- Data acquisition systems
29+
- Programmable voltage sources
30+
- Optical communications
31+
32+
Operation Modes
33+
---------------
34+
35+
+------------------+--------------------------------+----------------------------------+--------------------------------+
36+
| Mode Name | Description | Configuration | Typical Use |
37+
+------------------+--------------------------------+----------------------------------+--------------------------------+
38+
| Single | SPI mode with | *AD3552R_SPI_MULTI_IO_MODE* | Basic applications |
39+
| | unidirectional SDI/SDIO0 | set to 0 | requiring standard SPI |
40+
| | and SDO/SDIO1 lines for | | communication. |
41+
| | basic serial communication. | | |
42+
+------------------+--------------------------------+----------------------------------+--------------------------------+
43+
| Dual | Bidirectional communication | Set *multi_io_mode* to 1 | Applications requiring |
44+
| | on SDI/SDIO lines for | in *ad3552_transfer_config* | higher data throughput. |
45+
| | enhanced throughput. | | |
46+
+------------------+--------------------------------+----------------------------------+--------------------------------+
47+
| Quad | Utilizes four lines for | Set *multi_io_mode* to 2 | High-speed data- |
48+
| | data transfer for | in *ad3552_transfer_config* | intensive applications. |
49+
| | significantly increased | | |
50+
| | throughput. | | |
51+
+------------------+--------------------------------+----------------------------------+--------------------------------+
52+
| DDR Mode | Double Data Rate transfer | *AD3552R_MASK_SPI_CONFIG_DDR* | Situations requiring |
53+
| | using both edges of the | used to enable this mode | rapid data updates. |
54+
| | clock for faster data | | |
55+
| | transfers. | | |
56+
+------------------+--------------------------------+----------------------------------+--------------------------------+
57+
| Synchronous | Dual SPI synchronous mode | *AD3552R_SPI_SYNCHRONOUS_ENABLE* | Systems needing |
58+
| | for synchronized data | for enabling this feature | synchronized operations |
59+
| | transfer across channels. | | for data integrity. |
60+
+------------------+--------------------------------+----------------------------------+--------------------------------+
61+
62+
Device Configuration
63+
--------------------
64+
65+
Initialization
66+
~~~~~~~~~~~~~~
67+
68+
The ``ad3552r_init`` function initializes the AD3552R DAC, configuring
69+
SPI or AXI interfaces based on parameters and setting up GPIOs for reset
70+
and LDAC signals. It includes programming CRC settings for data
71+
integrity and writing initial configuration registers.
72+
73+
Data Transfer and Access
74+
~~~~~~~~~~~~~~~~~~~~~~~~
75+
76+
Key functions for data transfer include ``ad3552r_write_reg``, which
77+
writes data to specific registers, and ``ad3552r_transfer``, which
78+
handles data transfer operations. For read operations,
79+
``ad3552r_read_reg`` retrieves data from specified registers.
80+
81+
Configuration and Mode Setting
82+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83+
84+
Functions like ``ad3552r_set_dev_value`` adjust specific device
85+
settings, such as enabling or disabling CRC. The ``ad3552r_axi_init``
86+
function is used for additional initialization when configured in AXI
87+
mode. ``_ad3552r_update_reg_field`` updates specific fields in
88+
configuration registers.
89+
90+
Error Handling
91+
~~~~~~~~~~~~~~
92+
93+
Error handling is managed by functions like ``ad3552r_get_status``,
94+
which retrieves and optionally clears error states. This functionality
95+
assists in managing and reporting errors related to interface
96+
configurations, CRC mismatches, and access attempts to invalid
97+
registers.
98+
99+
Reset and Utilities
100+
~~~~~~~~~~~~~~~~~~~
101+
102+
The ``ad3552r_reset`` function handles resetting the device to its
103+
initial state. It is important for re-initialization and
104+
troubleshooting. Additional utility functions exist to support various
105+
device-specific operations.
106+
107+
Initialization and Configuration
108+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109+
110+
The ``ad3552r_init`` function initializes the AD3552R DAC, setting up
111+
SPI or AXI interfaces and configuring necessary GPIOs. Additional
112+
configurations may include enabling CRC and setting the device’s
113+
operational parameters. Functions like ``ad3552r_reset`` are used to
114+
restore the device to its initial state, important for both
115+
initialization and troubleshooting. ``ad3552r_axi_init`` is particularly
116+
used when configured in AXI mode. The reset capabilities are crucial to
117+
establish a known state for successful operations.
118+
119+
Register Access and Data Transfer
120+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121+
122+
Functions such as ``ad3552r_write_reg`` and ``ad3552r_read_reg`` are
123+
designed for register access to update settings or retrieve data from
124+
the DAC. ``ad3552r_single_transfer`` and ``ad3552r_transfer`` handle
125+
data transactions, ensuring efficient communication via SPI or AXI
126+
setups. Operations like ``ad3552r_write_simulatneously`` allow multiple
127+
channel updates, enhancing the DAC’s data throughput in high-speed
128+
applications. DMA support is facilitated through the
129+
``ad3552r_axi_write_data`` for bulk data operations.
130+
131+
Device Control and Customization
132+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133+
134+
Functions under this category, like ``ad3552r_set_dev_value`` and
135+
``ad3552r_get_dev_value``, handle device parameter adjustments.
136+
``ad3552r_config_custom_gain`` and ``ad3552r_configure_device`` allow
137+
configuration of custom output ranges and gain. ``ad3552r_ldac_trigger``
138+
is utilized for asynchronous operations. These functions enable
139+
adaptation of the DAC to specific operational needs, ensuring accurate
140+
performance.
141+
142+
Error Handling
143+
~~~~~~~~~~~~~~
144+
145+
Error detection and handling functions like ``ad3552r_get_status``
146+
provide mechanisms to monitor and address device malfunctions. This is
147+
crucial for identifying issues such as CRC mismatches or illegal
148+
accesses, ensuring system reliability. Error states can be retrieved for
149+
diagnostic purposes, facilitating robust device integration.
150+
151+
Utility and Support
152+
~~~~~~~~~~~~~~~~~~~
153+
154+
Utility functions, including ``ad3552r_remove``, manage device cleanup
155+
and resource deallocation. Functions like ``ad3552r_check_scratch_pad``
156+
and ``ad3552r_get_scale`` offer additional support for device
157+
diagnostics and calibration checks. This holistic approach covers
158+
various operational needs, enhancing device management and support
159+
throughout its lifecycle.
160+
161+
Device Initialization Example
162+
-----------------------------
163+
164+
.. code-block:: C
165+
166+
#include "ad3552r.h"
167+
static struct ad3552r_init_param default_ad3552r_param = {
168+
.chip_id = 0x4008,
169+
.spi_param = {
170+
.device_id = 1,
171+
.chip_select = 0,
172+
.mode = NO_OS_SPI_MODE_0,
173+
.max_speed_hz = 66000000,
174+
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
175+
.platform_ops = &xil_spi_ops,
176+
.extra = SPI_EXTRA
177+
},
178+
.ldac_gpio_param_optional = &gpio_ldac_param,
179+
.reset_gpio_param_optional = &gpio_reset_param,
180+
.sdo_drive_strength = 1,
181+
.channels = {
182+
[0] = {
183+
.en = 1,
184+
.range = AD3552R_CH_OUTPUT_RANGE_NEG_10__10V,
185+
},
186+
[1] = {
187+
.en = 1,
188+
.range = AD3552R_CH_OUTPUT_RANGE_NEG_10__10V,
189+
}
190+
},
191+
.crc_en = 0,
192+
.single_transfer = 1,
193+
};
194+
int example_main()
195+
{
196+
int32_t err;
197+
struct ad3552r_desc *dac;
198+
err = init_gpios_to_defaults();
199+
if (NO_OS_IS_ERR_VALUE(err)) {
200+
pr_err("init_gpios_to_defaults failed: %d\n", err);
201+
return err;
202+
}
203+
err = ad3552r_init(&dac, &default_ad3552r_param);
204+
if (NO_OS_IS_ERR_VALUE(err)) {
205+
pr_err("ad3552r_init failed with code: %d\n", err);
206+
return err;
207+
}
208+
set_power_up_success_led();
209+
err = run_example(dac);
210+
if (NO_OS_IS_ERR_VALUE(err)) {
211+
pr_debug("Example failed with code: %d\n", err);
212+
return err;
213+
}
214+
ad3552r_remove(dac);
215+
return 0;
216+
}

0 commit comments

Comments
 (0)