Skip to content

Commit 360e7b4

Browse files
committed
drivers: dac: max22007: Add README for MAX22007
Add driver documentation for MAX22007 Signed-off-by: Janani Sunil <janani.sunil@analog.com>
1 parent 65cd2ba commit 360e7b4

File tree

2 files changed

+139
-0
lines changed

2 files changed

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

drivers/dac/max22007/README.rst

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
MAX22007 no-OS driver
2+
=====================
3+
4+
.. no-os-doxygen::
5+
6+
Supported Devices
7+
-----------------
8+
9+
`MAX22007 <https://www.analog.com/en/products/max22007.html>`_
10+
11+
Overview
12+
--------
13+
14+
The MAX22007 is a software-configurable four-channel
15+
analog output device that drives a voltage or current output
16+
on each channel. Each output channel of the MAX22007 features a 12-bit
17+
DAC with fast settling time using a shared internal voltage
18+
reference. The MAX22007 communicates with a microcontroller using an
19+
SPI interface at clock rates up to 30MHz with an optional eight-bit CRC for improved data integrity.
20+
21+
22+
Applications
23+
------------
24+
25+
* Building Automation Analog Outputs
26+
* Configurable Analog Output Cards
27+
* Factory Automation Analog Outputs
28+
* Process Automation
29+
* Programmable Logic Controllers
30+
31+
MAX22007 Device Configuration
32+
-----------------------------
33+
34+
Driver Initialization
35+
---------------------
36+
37+
In order to be able to use the device, SPI communication needs to be established
38+
between the part and a microcontroller. This is done through the
39+
:func:`max22007_init` function. The function requires a structure of type
40+
:c:struct:`max22007_dev` that contains the SPI configuration information and
41+
the chip select GPIO information. The function returns 0 in case of success
42+
or a negative error code otherwise.
43+
44+
Channel Mode Configuration
45+
--------------------------
46+
47+
The MAX22007 has four channels that can be configured to operate in
48+
different modes. The configuration is done through the
49+
:func:`max22007_set_channel_mode` function. The 2 possible channel modes are:
50+
* Voltage Output Mode
51+
* Current Output Mode
52+
53+
Channel Power Mode Configuration
54+
--------------------------------
55+
56+
The MAX22007 has four channels that can be configured to operate in
57+
different power modes. The configuration is done through the
58+
:func:`max22007_set_channel_power` function. The 2 possible channel power
59+
modes are:
60+
* Power off Mode
61+
* Power on Mode
62+
63+
DAC Channel Latch Mode Configuration
64+
------------------------------------
65+
66+
The MAX22007 has four channels that can be configured to operate in
67+
different latch modes. The configuration is done through the
68+
:func:`max22007_set_latch_mode` function. The 2 possible channel
69+
latch modes are:
70+
* Transparent Mode
71+
* Latched Mode (This mode enables the DAC channels to be updated via an LDAC update (register write/GPIO))
72+
73+
Setting the Output Value
74+
------------------------
75+
76+
The output value of each channel can be set through the
77+
:func:`max22007_write_channel_data` function. The function requires the channel
78+
number and the output value to be set. The output value is a 12-bit value
79+
that can be set between 0 and 4095.
80+
81+
Configuring the SPI timeout
82+
---------------------------
83+
84+
The SPI timeout can be configured through the
85+
:func:`max22007_set_timeout` function. The status of the Timeout select, timeout configuration and timeout enable
86+
is set through this function.
87+
88+
After the basic example code has been programmed to the MCU, the outputs of channel 0 and 3 shall be set to 2 and 4v respectively,
89+
as the channels have been configured to operate in voltage output mode.
90+
91+
MAX22007 Driver Initialization Example
92+
--------------------------------------
93+
94+
.. code-block:: c
95+
96+
struct no_os_spi_init_param max22007_spi_init = {
97+
.device_id = SPI_DEVICE_ID,
98+
.max_speed_hz = 5000000,
99+
.mode = NO_OS_SPI_MODE_0,
100+
.chip_select = GPIO_CS_PIN,
101+
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
102+
.platform_ops = &spi_platform_ops,
103+
.extra = &max22007_spi_extra_ip
104+
};
105+
106+
struct max22007_init_param max22007_ip = {
107+
.comm_param = &max22007_spi_init,
108+
.crc_en = false,
109+
.ref_mode = INTERNAL_REF,
110+
.timeout_config = {
111+
.timeout_en = false,
112+
.timeout_sel = MAX22007_TIMEOUT_100MS,
113+
.timeout_cnfg = TIMEOUT_RESET,
114+
},
115+
.channel_config = {
116+
[0] = {
117+
.channel_mode = MAX22007_VOLTAGE_MODE,
118+
.latch_mode = TRANSPARENT_LATCH,
119+
.channel_power = MAX22007_CH_POWER_ON,
120+
},
121+
[1] = {
122+
.channel_mode = MAX22007_VOLTAGE_MODE,
123+
.latch_mode = LDAC_CONTROL,
124+
.channel_power = MAX22007_CH_POWER_OFF,
125+
},
126+
[2] = {
127+
.channel_mode = MAX22007_VOLTAGE_MODE,
128+
.latch_mode = LDAC_CONTROL,
129+
.channel_power = MAX22007_CH_POWER_OFF,
130+
},
131+
[3] = {
132+
.channel_mode = MAX22007_VOLTAGE_MODE,
133+
.latch_mode = LDAC_CONTROL,
134+
.channel_power = MAX22007_CH_POWER_ON,
135+
},
136+
}
137+
};
138+

0 commit comments

Comments
 (0)