Skip to content

Commit 0bf0e0a

Browse files
Update docs/readme.md
Update docs/readme.md Update docs/readme.md Update docs/readme.md Update docs/readme.md update docs/readme.md: add multichannel description doc: update README.md doc: update doc/readme.md Co-Authored-By: Karl Söderby <[email protected]>
1 parent f1808b2 commit 0bf0e0a

File tree

2 files changed

+168
-38
lines changed

2 files changed

+168
-38
lines changed

README.md

+4-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,7 @@
1-
<img src="https://content.arduino.cc/website/Arduino_logo_teal.svg" height="100" align="right" />
1+
22

3-
`Arduino_AdvancedAnalog`
4-
===========================
5-
[![Compile Examples status](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/compile-examples.yml)
6-
[![Spell Check status](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/spell-check.yml)
7-
[![Sync Labels status](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions/workflows/sync-labels.yml)
8-
[![Arduino Lint](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/workflows/Arduino%20Lint/badge.svg)](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/actions?workflow=Arduino+Lint)
3+
# 〰️ Arduino AdvancedAnalog Library
94

10-
Advanced Analog Library for Arduino Giga.
5+
The Arduino AdvancedAnalog library is designed to offer high performance DAC/ADC applications on boards based on the STM32H7 microcontroller.
116

12-
## :mag_right: Resources
13-
14-
* [How to install a library](https://www.arduino.cc/en/guide/libraries)
15-
* [Help Center](https://support.arduino.cc/)
16-
* [Forum](https://forum.arduino.cc)
17-
18-
## :bug: Bugs & Issues
19-
20-
If you want to report an issue with this library, you can submit it to the [issue tracker](https://github.com/arduino-libraries/Arduino_AdvancedAnalog/issues) of this repository. Remember to include as much detail as you can about your hardware set-up, code and steps for reproducing the issue. Make sure you're using an original Arduino board.
21-
22-
## :technologist: Development
23-
24-
There are many ways to contribute:
25-
26-
* Improve documentation and examples
27-
* Fix a bug
28-
* Test open Pull Requests
29-
* Implement a new feature
30-
* Discuss potential ways to improve this library
31-
32-
You can submit your patches directly to this repository as Pull Requests. Please provide a detailed description of the problem you're trying to solve and make sure you test on real hardware.
33-
34-
## :yellow_heart: Donations
35-
36-
This open-source code is maintained by Arduino with the help of the community. We invest a considerable amount of time in testing code, optimizing it and introducing new features. Please consider [donating](https://www.arduino.cc/en/donate/) or [sponsoring](https://github.com/sponsors/arduino) to support our work, as well as [buying original Arduino boards](https://store.arduino.cc/) which is the best way to make sure our effort can continue in the long term.
37-
38-
## Known issues
39-
* ADC is running at the slowest possible clock (PCLK), should probably set up a PLL and change the clock source.
7+
📖 For more information about this library please read the documentation [here](./docs/).

docs/readme.md

+164-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,174 @@
11
# Arduino_AdvancedAnalog library
22

3-
The **Arduino_AdvancedAnalog** library is designed for high performance DAC/ADC applications on boards based on the STM32H747XI microcontroller:
3+
[![License](https://img.shields.io/badge/License-LGPLv2.1-blue.svg)](../LICENSE)
4+
5+
The **Arduino_AdvancedAnalog** library is designed to offer high performance DAC/ADC applications on boards based on the STM32H747XI microcontroller:
46
- [Arduino GIGA R1 WiFi](https://store.arduino.cc/products/giga-r1-wifi)
57
- [Arduino Portenta H7](https://store.arduino.cc/products/portenta-h7)
68

7-
To use this library:
9+
## Features
10+
11+
- ADC/DAC parameters fine tuning: resolution, channel number, queue number and size
12+
- ADC acquisition with DMA in double buffering mode
13+
- ADC Multichannel acquisition
14+
- DAC Multichannel writing
15+
- Storing ADC samples history in multiple queues
16+
## Guides
17+
18+
To learn more about using the DAC & ADC on the GIGA R1 WiFi, check out the [GIGA Advanced DAC/ADC Guide](https://docs.arduino.cc/tutorials/giga-r1-wifi/giga-audio).
19+
20+
This includes examples such as audio playback from USB storage, generate sine waves and more.
21+
## Usage
22+
23+
### ADC
24+
25+
To use this library for ADC applications, you must have a supported Arduino board and include the AdvancedAnalog library in your Arduino sketch. Here is a minimal example:
26+
27+
```cpp
28+
#include <Arduino_AdvancedAnalog.h>
29+
30+
AdvancedADC adc1(A0);
31+
32+
void setup() {
33+
Serial.begin(9600);
34+
35+
// Initialize ADC with: resolution, sample rate, number of samples per channel, queue depth
36+
if (!adc1.begin(AN_RESOLUTION_16, 16000, 32, 64)) {
37+
Serial.println("Failed to start ADC!");
38+
while (1);
39+
}
40+
}
41+
42+
void loop() {
43+
// Check if an ADC measurement is ready
44+
if (adc1.available()) {
45+
// Get read buffer
46+
SampleBuffer buf = adc1.read();
47+
48+
// Print sample from read buffer
49+
Serial.println(buf[0]);
50+
51+
// Release read buffer
52+
buf.release();
53+
}
54+
}
55+
```
56+
57+
#### ADC Multichannel (GIGA R1 WiFi)
58+
This library supports concurrent usage of up to **three** ADCs (_ADC1_, _ADC2_ and _ADC3_).
59+
Each ADC instance can handle up to **five** channels.
60+
61+
**Note:** It's important to be aware that certain pins cannot be used across multiple ADCs or cannot share the same ADC.
62+
63+
*Please ensure that you refer to tables below when configuring your project to avoid conflicts in pin assignments.*
64+
65+
Below is a table illustrating the pin mapping for each ADC in **Arduino Giga R1 WiFi**:
66+
67+
| Pin | ADC1 | ADC2 | ADC3 |
68+
|-------|-------|-------|-------|
69+
| A0 | X | X | |
70+
| A1 | X | X | |
71+
| A2 | X | X | |
72+
| A3 | X | X | |
73+
| A4 | X | X | |
74+
| A5 | X | X | X |
75+
| A6 | X | X | X |
76+
| A7 | X | | |
77+
| A8 | | | X |
78+
| A9 | | | X |
79+
| A10 | X | X | |
80+
| A11 | X | X | |
81+
82+
Here is a example for the Arduino GIGA R1 WiFi:
83+
84+
```cpp
85+
#include <Arduino_AdvancedAnalog.h>
86+
87+
AdvancedADC adc_a(A0, A1);
88+
/* Mapped to ADC1 */
89+
90+
AdvancedADC adc_b(A2);
91+
/* Mapped to ADC2, because ADC1 is occupied by A0 and A1 */
892
93+
void setup() {
94+
...
995
```
96+
97+
#### ADC Multichannel (Portenta H7)
98+
99+
Below is a table illustrating the pin mapping for each ADC in **Portenta H7**:
100+
101+
| Pin | ADC1 | ADC2 | ADC3 |
102+
|-------|-------|-------|-------|
103+
| A0 | X | X | |
104+
| A1 | X | X | |
105+
| A2 | | | X |
106+
| A3 | | | X |
107+
| A4 | X | X | X |
108+
| A5 | X | X | |
109+
| A6 | X | X | |
110+
| A7 | X | X | |
111+
112+
Here is an example for the Portenta H7:
113+
114+
```cpp
10115
#include <Arduino_AdvancedAnalog.h>
116+
117+
AdvancedADC adc_c(A2, A3, A4);
118+
/* Mapped to ADC3 */
119+
120+
AdvancedADC adc_d(A5);
121+
/* Mapped to ADC1 */
122+
123+
void setup() {
124+
...
11125
```
12126
127+
### DAC
128+
129+
To use this library for DAC application, you must have a supported Arduino board and include the AdvancedAnalog library in your Arduino sketch. Here is a minimal example for the Arduino GIGA R1 WiFi:
130+
131+
```cpp
132+
#include <Arduino_AdvancedAnalog.h>
133+
134+
AdvancedDAC dac1(A12);
135+
136+
void setup() {
137+
Serial.begin(9600);
138+
139+
// Initialize DAC with: resolution, sample rate, number of samples per channel, queue depth
140+
if (!dac1.begin(AN_RESOLUTION_12, 8000, 32, 64)) {
141+
Serial.println("Failed to start DAC!");
142+
while (1);
143+
}
144+
}
145+
146+
void loop() {
147+
if (dac1.available()) {
148+
149+
// Get a free buffer for writing
150+
SampleBuffer buf = dac1.dequeue();
151+
152+
// Write data to buffer (Even position: 0, Odd position: 0xFFF)
153+
for (int i=0; i<buf.size(); i++) {
154+
buf.data()[i] = (i % 2 == 0) ? 0: 0xFFF;
155+
}
156+
157+
// Write the buffer to DAC
158+
dac1.write(buf);
159+
}
160+
}
161+
```
162+
163+
## Examples
164+
- **[Advanced](../examples/Advanced):** This folder contains examples showing how to configure ADC/DAC to read/write data.
165+
- **[Beginner](../examples/Beginner):** This folder contains examples showing how to generate waveforms with DAC.
166+
167+
## API
168+
169+
The API documentation can be found [here](./api.md).
170+
171+
## License
172+
173+
This library is released under the [LGPLv2.1 license](../LICENSE).
174+

0 commit comments

Comments
 (0)