You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`enum` - analog read resolution (choose from 8, 10, 12, 14, 16 bit).
36
+
-`enum` - **resolution** the ADC resolution (can be 8, 10, 12, 14 or 16 bit).
39
37
-`AN_RESOLUTION_8`
40
38
-`AN_RESOLUTION_10`
41
39
-`AN_RESOLUTION_12`
42
40
-`AN_RESOLUTION_14`
43
41
-`AN_RESOLUTION_16`
44
42
-`int` - **sample_rate** - the sample rate / frequency in Hertz, e.g. `16000`.
45
-
-`int` - **n_samples** - number of samples we want to acquire, e.g. `32`. When reading the ADC, we store these samples into a specific buffer (see [SampleBuffer](#samplebuffer)), and read them via `buffer[x]`, where `x` is the sample you want to retrieve.
43
+
-`int` - **n_samples** - number of samples per buffer, e.g. `32`. When reading the ADC, we store these samples into a specific buffer (see [SampleBuffer](#samplebuffer)), and read them via `buffer[x]`, where `x` is the sample you want to retrieve.
46
44
-`int` - **n_buffers** - the number of buffers in the queue.
45
+
-`bool` - **start** - if true, the ADC will start sampling immediately (the default is true).
46
+
-`enum` - **sample_time** - the ADC sampling time in cycles (the default is 8.5 cycles).
47
+
-`AN_ADC_SAMPLETIME_1_5`
48
+
-`AN_ADC_SAMPLETIME_2_5`
49
+
-`AN_ADC_SAMPLETIME_8_5`
50
+
-`AN_ADC_SAMPLETIME_16_5`
51
+
-`AN_ADC_SAMPLETIME_32_5`
52
+
-`AN_ADC_SAMPLETIME_64_5`
53
+
-`AN_ADC_SAMPLETIME_387_5`
54
+
-`AN_ADC_SAMPLETIME_810_5`
47
55
48
56
#### Returns
49
57
@@ -73,7 +81,7 @@ Reads the first available byte in the buffer.
73
81
74
82
### `stop()`
75
83
76
-
Stops the ADC and buffer transfer, and releases any memory allocated for the buffer array.
84
+
Stops the ADC and releases all of its resources.
77
85
78
86
#### Syntax
79
87
@@ -85,6 +93,67 @@ adc.stop()
85
93
86
94
-`1`
87
95
96
+
## AdvancedADCDual
97
+
98
+
### `AdvancedADCDual`
99
+
100
+
The AdvancedADCDual class enables the configuration of two ADCs in Dual ADC mode. In this mode, the two ADCs are synchronized, with one ADC acting as the master ADC and controlling the other. Note: This mode is only supported on ADC1 and ADC2, and they must be passed in that order.
101
+
102
+
#### Syntax
103
+
104
+
```
105
+
AdvancedADCDual adc_dual(adc1, adc2);
106
+
```
107
+
108
+
#### Parameters
109
+
110
+
-`AdvancedADC` - **adc1** - the first ADC. Note this must be ADC1.
111
+
-`AdvancedADC` - **adc2** - the second ADC. Note this must be ADC2.
112
+
113
+
#### Returns
114
+
115
+
Nothing.
116
+
117
+
### `begin()`
118
+
119
+
Initialize and start the two ADCs with the specified parameters.
-`enum` - **resolution** the ADC resolution (can be 8, 10, 12, 14 or 16 bit).
130
+
-`AN_RESOLUTION_8`
131
+
-`AN_RESOLUTION_10`
132
+
-`AN_RESOLUTION_12`
133
+
-`AN_RESOLUTION_14`
134
+
-`AN_RESOLUTION_16`
135
+
-`int` - **sample_rate** - the sample rate / frequency in Hertz, e.g. `16000`.
136
+
-`int` - **n_samples** - number of samples per buffer, e.g. `32`. When reading the ADC, we store these samples into a specific buffer (see [SampleBuffer](#samplebuffer)), and read them via `buffer[x]`, where `x` is the sample you want to retrieve.
137
+
-`int` - **n_buffers** - the number of buffers in the queue.
138
+
-`bool` - **start** - if true, the ADC will start sampling immediately (the default is true).
139
+
-`enum` - **sample_time** - the ADC sampling time in cycles (the default is 8.5 cycles).
140
+
-`AN_ADC_SAMPLETIME_1_5`
141
+
-`AN_ADC_SAMPLETIME_2_5`
142
+
-`AN_ADC_SAMPLETIME_8_5`
143
+
-`AN_ADC_SAMPLETIME_16_5`
144
+
-`AN_ADC_SAMPLETIME_32_5`
145
+
-`AN_ADC_SAMPLETIME_64_5`
146
+
-`AN_ADC_SAMPLETIME_387_5`
147
+
-`AN_ADC_SAMPLETIME_810_5`
148
+
149
+
#### Returns
150
+
151
+
1 on success, 0 on failure.
152
+
153
+
### `stop()`
154
+
155
+
Stops the two ADCs and releases all of their resources.
156
+
88
157
## AdvancedDAC
89
158
90
159
### `AdvancedDAC`
@@ -109,10 +178,7 @@ Nothing.
109
178
110
179
### `begin()`
111
180
112
-
113
-
Initializes the DAC with the specific parameters. The `begin()` method is firstly used to initialize the library.
114
-
115
-
If reconfigured during program execution, use `stop()` first.
181
+
Initializes the DAC with the specified parameters. If reconfiguration is needed during program execution, `stop()` should be called first.
-`int` - **frequency** - the frequency in Hertz, e.g. `8000`.
130
-
-`int` - **n_samples** - number of samples we want to write, e.g. `32`. When writing to the DAC, we first write the samples into a buffer (see [SampleBuffer](#samplebuffer)), and write it to the DAC using `dac_out.write(buf)`.
196
+
-`int` - **n_samples** - number of samples per buffer, e.g. `32`. When writing to the DAC, we first write the samples into a buffer (see [SampleBuffer](#samplebuffer)), and write it to the DAC using `dac_out.write(buf)`.
131
197
-`int` - **n_buffers** - the number of buffers in the queue.
132
198
133
199
@@ -188,7 +254,7 @@ dac1.write(buf);
188
254
189
255
### `stop()`
190
256
191
-
Stops the DAC timer and buffer transfer, and releases any memory allocated for the buffer array.
257
+
Stops the DAC and releases all of its resources.
192
258
193
259
#### Syntax
194
260
@@ -216,7 +282,170 @@ dac.frequency(frequency);
216
282
217
283
-`int` - frequency in Hertz (Hz).
218
284
285
+
## AdvancedI2S
286
+
287
+
### `AdvancedI2S`
288
+
289
+
Creates an I2S object using the provided pins.
290
+
291
+
#### Syntax
292
+
293
+
```
294
+
AdvancedI2S i2s(WS, CK, SDI, SDO, MCK);
295
+
```
296
+
297
+
#### Parameters
298
+
299
+
-`WS` I2S word select (LR clock).
300
+
-`CK` I2S bit-clock (BRCLK clock).
301
+
-`SDI` I2S data input (can be `NC` in half-duplex output mode).
302
+
-`SDO` I2S data output (can be `NC` in half-duplex input mode).
303
+
-`MCK` Master clock (can be `NC` if no MCLK is required).
-`int` - **sample_rate** - The sample rate / frequency in Hertz, e.g. `16000`.
326
+
-`int` - **n_samples** - The number of samples per buffer (i.e, buffer width).
327
+
-`int` - **n_buffers** - The number of buffers in the sample queue (i.e, queue depth).
328
+
329
+
#### Returns
330
+
331
+
1 on success, 0 on failure.
332
+
333
+
### `available()`
334
+
335
+
Checks if the I2S is readable, writable or both (in full-duplex mode).
336
+
337
+
#### Syntax
338
+
339
+
```
340
+
if(i2s.available()){}
341
+
```
342
+
343
+
#### Parameters
344
+
345
+
None.
346
+
347
+
#### Returns
348
+
349
+
True if I2S is readable, writable or both (in full-duplex mode), false if not.
350
+
351
+
### `read()`
352
+
353
+
Returns a sample buffer from the queue for reading. This function can be called in half-duplex input or full-duplex modes. When the code is done with the buffer, it should be returned to I2S by calling `release()` (see [SampleBuffer](#release))
354
+
355
+
#### Syntax
356
+
357
+
```
358
+
SampleBuffer buf = i2s.read();
359
+
360
+
for (size_t i=0; i<buf.size(); i++) {
361
+
Serial.println(buf[i]);
362
+
}
363
+
364
+
i2s.release(buf);
365
+
```
366
+
367
+
### `dequeue()`
368
+
369
+
Returns a sample buffer from the queue for writing. This function can be called in half-duplex output or full-duplex modes. When the code is done with the buffer, it should be written out to I2S by calling `write()` (see [I2S](#write))
370
+
371
+
#### Syntax
372
+
373
+
```
374
+
SampleBuffer buf = dac.dequeue();
375
+
376
+
for (size_t i=0; i<buf.size(); i++) {
377
+
buf[i] = SAMPLES_BUFFER[i];
378
+
}
379
+
380
+
dac1.write(buf);
381
+
```
382
+
383
+
### `write()`
384
+
385
+
Writes the buffer to I2S.
386
+
387
+
#### Syntax
388
+
389
+
```
390
+
i2s.write(buf);
391
+
```
392
+
393
+
#### Parameters
394
+
395
+
- A buffer containing the samples (see [SampleBuffer](#samplebuffer)).
219
396
397
+
### `stop()`
398
+
399
+
Stops the I2S and releases all of its resources.
400
+
401
+
#### Syntax
402
+
403
+
```
404
+
i2s.stop()
405
+
```
406
+
407
+
#### Returns
408
+
409
+
-`1`
410
+
411
+
## WavReader
412
+
413
+
### `WavReader`
414
+
415
+
Creates a WAV file reader.
416
+
417
+
### `begin()`
418
+
419
+
Initializes the WAV reader, opens the file and reads the WAV file header.
420
+
421
+
#### Syntax
422
+
423
+
```
424
+
wav.begin(path, n_samples, n_buffers, loop)
425
+
```
426
+
427
+
#### Parameters
428
+
429
+
-`string` - **path** - the path to the WAV file.
430
+
-`int` - **n_samples** - the number of samples per buffer.
431
+
-`int` - **n_buffers** - the number of buffers in the queue.
432
+
-`bool` - **loop* - if true, the WAV reader will loop back to the start of the file, when the end file is reached.
433
+
434
+
### `stop()`
435
+
436
+
Stops the WAV file and releases all of its resources (include the WAV file handle).
437
+
438
+
### `available()`
439
+
440
+
Returns true if the WAV file has more data to be read.
441
+
442
+
### `read()`
443
+
444
+
Returns a sample buffer from the queue for reading.
445
+
446
+
### `rewind()`
447
+
448
+
If `loop` is false, this functions restarts the file read position.
220
449
221
450
## SampleBuffer
222
451
@@ -244,7 +473,7 @@ dac1.write(buf);
244
473
245
474
### `data()`
246
475
247
-
Returns a pointer to the buffer's memory.
476
+
Returns a pointer to the buffer's memory.
248
477
249
478
```
250
479
buf.data()
@@ -325,7 +554,7 @@ buf.release()
325
554
326
555
### `setflags()`
327
556
328
-
Sets flag(s) for the buffer.
557
+
Sets flag(s) for the buffer.
329
558
330
559
```
331
560
buf.setflags(int arg)
@@ -373,7 +602,7 @@ buf.readable()
373
602
374
603
### `allocate()`
375
604
376
-
Used to obtain a buffer from the free queue.
605
+
Used to obtain a buffer from the free queue.
377
606
378
607
```
379
608
buf.allocate()
@@ -401,4 +630,4 @@ Return a DMA buffer from the ready queue.
0 commit comments