Skip to content

Commit 954fd35

Browse files
committed
adc_test: add README
Add README documentation. Signed-off-by: Antoniu Miclaus <[email protected]>
1 parent 37a5c2c commit 954fd35

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../../../../drivers/adc/adc_test/README.rst

drivers/adc/adc_test/README.rst

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
AD405X no-OS Driver
2+
===================
3+
4+
.. no-os-doxygen::
5+
6+
Supported Devices
7+
-----------------
8+
9+
`AD4050 <https://www.analog.com/AD4050>`_
10+
`AD4052 <https://www.analog.com/AD4052>`_
11+
`AD4056 <https://www.analog.com/AD4056>`_
12+
`AD4058 <https://www.analog.com/AD4058>`_
13+
`AD4060 <https://www.analog.com/AD4060>`_
14+
`AD4062 <https://www.analog.com/AD4062>`_
15+
16+
Overview
17+
--------
18+
19+
The AD4052/AD4062 are low power, compact 16-bit successive approximation
20+
register (SAR) analog-to-digital converters (ADC) designed
21+
for battery powered precision measurement and monitoring applications.
22+
The AD4052/AD4062 feature set supports event-driven programming
23+
for dynamic tradeoff between system power and precision. Using
24+
a patented, power efficient window comparator, the AD4052 autonomously monitors
25+
signals while the host sleeps. The programmable averaging filter enables
26+
on-demand high resolution measurements for optimizing precision for the power
27+
consumed.
28+
29+
The AD4052 includes AFE control signals to minimize the complexity of
30+
host timers.
31+
The control signals automate the power cycling
32+
of the AFE relative to ADC sampling to reduce system power while
33+
minimizing settling error artifacts. The Easy Drive analog inputs
34+
enables compact and low power signal conditioning circuitry by
35+
reducing the dependence on high-speed ADC driver amplifiers. The
36+
small 3.4 pF sampling capacitors result in low dynamic and average
37+
input current, broadening compatibility with low power amplifiers or
38+
direct sensor interfacing. The AD4052 wide common mode input
39+
range supports both differential and single-ended input signals.
40+
41+
The AD4052 family features a 4-wire SPI with a dedicated CNV input.
42+
The AD4062 family features a I3C, allowing multiple devices on the same
43+
bus.
44+
Cyclic redundancy check (CRC) is available on all interface read
45+
and write operations and internal memory to ensure reliable device
46+
configuration and operation.
47+
48+
AD405X Device Configuration
49+
---------------------------
50+
51+
Driver Initialization
52+
---------------------
53+
54+
SPI
55+
~~~
56+
57+
In order to be able to use the device, you will have to provide the support for
58+
the communication protocol (SPI) as well as 3 external GPIOs for the CNV pin and two
59+
general-purpose input/output pins (GP0 and GP1).
60+
61+
SPI&I3C
62+
~~~~~~~
63+
64+
The first API to be called is **ad405x_init**. Make sure that it returns 0,
65+
which means that the driver was initialized correctly.
66+
67+
GPIO Configuration
68+
------------------
69+
70+
The device has two general purpose output pins, GP0 and GP1.
71+
These pins can be configured as threshold events, data ready, among other
72+
status signals.
73+
In the driver files the **ad405x_set_gp_mode** can be found and used to choose
74+
the specific signal for the GPIOs.
75+
76+
If GP0 is set as DRDY, the device will assert the pin on the CONV assertion,
77+
and the ADC driver will wait the pin to desert before issuing the ADC data
78+
acquisition.
79+
During initialization, GP1 is used to track the DEV_RDY state,
80+
and no further behaviour is defined at the driver level.
81+
82+
Channel Configuration
83+
---------------------
84+
85+
Channel data can be fetched with **ad405x_get_adc**.
86+
87+
The channel data format can be set using **ad405x_set_data_format**
88+
89+
Channel operation mode can also be configured using **ad405x_set_operating_mode**.
90+
91+
Soft Reset
92+
----------
93+
94+
The device can be soft reset by using **ad405x_soft_reset**.
95+
96+
AD405X Driver Initialization Example
97+
------------------------------------
98+
99+
SPI
100+
~~~
101+
102+
.. code-block:: c
103+
104+
struct ad405x_dev *ad405x;
105+
const struct no_os_spi_init_param ad405x_spi_ip = {
106+
.device_id = SPI_DEVICE_ID,
107+
.max_speed_hz = 100000,
108+
.mode = NO_OS_SPI_MODE_0,
109+
.chip_select = GPIO_CS_PIN,
110+
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
111+
.platform_ops = SPI_OPS,
112+
.extra = &ad405x_spi_extra_ip
113+
};
114+
const struct no_os_gpio_init_param gpio_cnv_param = {
115+
.port = GPIO_CNV_PORT,
116+
.number = GPIO_CNV_PIN,
117+
.platform_ops = GPIO_OPS,
118+
.extra = &gpio_init
119+
};
120+
const struct no_os_gpio_init_param gpio_gpio0_param = {
121+
.port = GPIO_GPIO0_PORT,
122+
.number = GPIO_GPIO0_PIN,
123+
.platform_ops = GPIO_OPS,
124+
.extra = &gpio_init
125+
};
126+
const struct no_os_gpio_init_param gpio_gpio1_param = {
127+
.port = GPIO_GPIO1_PORT,
128+
.number = GPIO_GPIO1_PIN,
129+
.platform_ops = GPIO_OPS,
130+
.extra = &gpio_init
131+
};
132+
struct ad405x_init_param ad405x_ip = {
133+
.comm_type = AD405X_COMM,
134+
.comm_init.spi_init = ad405x_spi_ip,
135+
.dev_type = AD405X_DEV_TYPE,
136+
.gpio_cnv = &gpio_cnv_param,
137+
.gpio_gpio0 = &gpio_gpio0_param,
138+
.gpio_gpio1 = &gpio_gpio1_param
139+
};
140+
ret = ad405x_init(&ad405x, &ad405x_ip);
141+
if (ret)
142+
goto error;
143+
144+
I3C
145+
~~~
146+
147+
.. code-block:: c
148+
149+
struct ad405x_dev *ad405x;
150+
const struct no_os_i3c_init_param *i3c1_devs_param[] = {
151+
&ad405x_i3c_ip
152+
};
153+
struct no_os_i3c_bus_init_param i3c1_ip = {
154+
.device_id = I3C_DEVICE_ID,
155+
.platform_ops = I3C_OPS,
156+
.devs = i3c1_devs_param,
157+
.num_devs = LENGTH_I3C_DEVS,
158+
.extra = &ad405x_i3c_extra_ip
159+
};
160+
const struct no_os_i3c_init_param ad405x_i3c_ip = {
161+
.bus = &i3c1_ip,
162+
.pid = AD405X_PID(AD405X_INSTANCE_ID),
163+
.is_i3c = AD405X_IS_I3C,
164+
.addr = AD405X_DYN_ADDR,
165+
.is_static = AD405X_NO_STATIC_ADDR,
166+
};
167+
const struct no_os_gpio_init_param gpio_gpio0_param = {
168+
.port = GPIO_GPIO0_PORT,
169+
.number = GPIO_GPIO0_PIN,
170+
.platform_ops = GPIO_OPS,
171+
.extra = &gpio_init
172+
};
173+
const struct no_os_gpio_init_param gpio_gpio1_param = {
174+
.port = GPIO_GPIO1_PORT,
175+
.number = GPIO_GPIO1_PIN,
176+
.platform_ops = GPIO_OPS,
177+
.extra = &gpio_init
178+
};
179+
struct no_os_i3c_init_param ad405x_i3c_ip = {
180+
.bus = &i3c1_ip,
181+
.pid = AD405X_PID(AD405X_INSTANCE_ID),
182+
.is_i3c = AD405X_IS_I3C,
183+
.addr = AD405X_DYN_ADDR,
184+
.is_static = AD405X_NO_STATIC_ADDR,
185+
};
186+
struct ad405x_init_param ad405x_ip = {
187+
.comm_type = AD405X_COMM,
188+
.comm_init.i3c_init = ad405x_i3c_ip,
189+
.dev_type = AD405X_DEV_TYPE,
190+
.gpio_gpio0 = &gpio_gpio0_param,
191+
.gpio_gpio1 = &gpio_gpio1_param
192+
};
193+
ret = ad405x_init(&ad405x, &ad405x_ip);
194+
if (ret)
195+
goto error;
196+

0 commit comments

Comments
 (0)