Skip to content

Commit 478f10d

Browse files
committed
drivers:dac:Add support for MAX22007
Added driver, example project and documentation for MAX22007 Added a new API in no_os_crc.c/.h to populate CRC table with LSB first logic Signed-off-by: Janani Sunil <janani.sunil@analog.com>
1 parent 8fd6bb7 commit 478f10d

File tree

19 files changed

+1730
-0
lines changed

19 files changed

+1730
-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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../../../../projects/max22007/README.rst

drivers/dac/max22007/README.rst

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
32+
MAX22007 Device Configuration
33+
-----------------------------
34+
35+
Driver Initialization
36+
---------------------
37+
38+
In order to be able to use the device, SPI communication needs to be established
39+
between the part and a microcontroller. This is done through the
40+
:func:`max22007_init` function. The function requires a structure of type
41+
:c:struct:`max22007_dev` that contains the SPI configuration information and
42+
the chip select GPIO information. The function returns 0 in case of success
43+
or a negative error code otherwise.
44+
45+
Channel Mode Configuration
46+
--------------------------
47+
48+
The MAX22007 has four channels that can be configured to operate in
49+
different modes. The configuration is done through the
50+
:func:`max22007_set_channel_mode` function. The 2 possible channel modes are:
51+
* Voltage Output Mode
52+
* Current Output Mode
53+
54+
55+
Channel Power Mode Configuration
56+
--------------------------------
57+
58+
The MAX22007 has four channels that can be configured to operate in
59+
different power modes. The configuration is done through the
60+
:func:`max22007_set_channel_power` function. The 2 possible channel power
61+
modes are:
62+
* Power off Mode
63+
* Power on Mode
64+
65+
DAC Channel Latch Mode Configuration
66+
------------------------------------
67+
68+
The MAX22007 has four channels that can be configured to operate in
69+
different latch modes. The configuration is done through the
70+
:func:`max22007_set_latch_mode` function. The 2 possible channel
71+
latch modes are:
72+
* Transparent Mode
73+
* Latched Mode (This mode enables the DAC channels to be updated via an LDAC update (register write/GPIO))
74+
75+
76+
Setting the Output Value
77+
------------------------
78+
79+
The output value of each channel can be set through the
80+
:func:`max22007_write_channel_data` function. The function requires the channel
81+
number and the output value to be set. The output value is a 12-bit value
82+
that can be set between 0 and 4095.
83+
84+
Configuring the SPI timeout
85+
---------------------------
86+
87+
The SPI timeout can be configured through the
88+
:func:`max22007_set_timeout` function. The status of the Timeout select, timeout configuration and timeout enable
89+
is set through this function.
90+
91+
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,
92+
as the channels have been configured to operate in voltage output mode.
93+
94+
MAX22007 Driver Initialization Example
95+
--------------------------------------
96+
97+
.. code-block:: c
98+
99+
struct no_os_spi_init_param max22007_spi_init = {
100+
.device_id = SPI_DEVICE_ID,
101+
.max_speed_hz = 5000000,
102+
.mode = NO_OS_SPI_MODE_0,
103+
.chip_select = GPIO_CS_PIN,
104+
.bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
105+
.platform_ops = &spi_platform_ops,
106+
.extra = &max22007_spi_extra_ip
107+
};
108+
109+
struct max22007_init_param max22007_ip = {
110+
.comm_param = &max22007_spi_init,
111+
.crc_en = false,
112+
.ref_mode = INTERNAL_REF,
113+
.timeout_config = {
114+
.timeout_en = false,
115+
.timeout_sel = MAX22007_TIMEOUT_100MS,
116+
.timeout_cnfg = TIMEOUT_RESET,
117+
},
118+
.channel_config = {
119+
[0] = {
120+
.channel_mode = MAX22007_VOLTAGE_MODE,
121+
.latch_mode = TRANSPARENT_LATCH,
122+
.channel_power = MAX22007_CH_POWER_ON,
123+
},
124+
[1] = {
125+
.channel_mode = MAX22007_VOLTAGE_MODE,
126+
.latch_mode = LDAC_CONTROL,
127+
.channel_power = MAX22007_CH_POWER_OFF,
128+
},
129+
[2] = {
130+
.channel_mode = MAX22007_VOLTAGE_MODE,
131+
.latch_mode = LDAC_CONTROL,
132+
.channel_power = MAX22007_CH_POWER_OFF,
133+
},
134+
[3] = {
135+
.channel_mode = MAX22007_VOLTAGE_MODE,
136+
.latch_mode = LDAC_CONTROL,
137+
.channel_power = MAX22007_CH_POWER_ON,
138+
},
139+
}
140+
};

0 commit comments

Comments
 (0)