-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAdvancedDAC.h
49 lines (40 loc) · 1.68 KB
/
AdvancedDAC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
This file is part of the Arduino_AdvancedAnalog library.
Copyright (c) 2023 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <vector>
#include "DMABuffer.h"
#include "AdvancedAnalog.h"
struct dac_descr_t;
class AdvancedDAC {
private:
size_t n_channels;
dac_descr_t *descr;
PinName dac_pins[AN_MAX_DAC_CHANNELS];
public:
template <typename ... T>
AdvancedDAC(pin_size_t p0, T ... args): n_channels(0), descr(nullptr) {
static_assert(sizeof ...(args) < AN_MAX_DAC_CHANNELS,
"A maximum of 1 channel is currently supported.");
for (auto p : {p0, args...}) {
dac_pins[n_channels++] = analogPinToPinName(p);
}
}
~AdvancedDAC();
bool available();
SampleBuffer dequeue();
void write(SampleBuffer dmabuf);
int begin(uint32_t resolution, uint32_t frequency, size_t n_samples=0, size_t n_buffers=0);
int stop();
};