File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
examples/samv71_xplained_ultra/dac
src/modm/board/samv71_xplained_ultra Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2023, Christopher Durand
3+ *
4+ * This file is part of the modm project.
5+ *
6+ * This Source Code Form is subject to the terms of the Mozilla Public
7+ * License, v. 2.0. If a copy of the MPL was not distributed with this
8+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9+ */
10+ // ----------------------------------------------------------------------------
11+
12+ #include < modm/board.hpp>
13+
14+ using namespace Board ;
15+
16+ /* *
17+ * Simple DAC example
18+ *
19+ * Output sawtooth waveform in free-running mode.
20+ *
21+ * See DMA examples for use of DAC with DMA.
22+ */
23+
24+ using Out0 = GpioB13;
25+
26+ void waitForTxReady ()
27+ {
28+ while (!(Dac::readInterruptFlags () & Dac::Interrupt::TxReadyCh0));
29+ }
30+
31+ int main ()
32+ {
33+ Board::initialize ();
34+
35+ Dac::connect<Out0::Ch0>();
36+ Dac::initialize<SystemClock, 12_MHz>();
37+
38+ Dac::enableChannel (Dac::Channel::Channel0);
39+
40+ while (true )
41+ {
42+ for (int i = 0 ; i <= 4095 ; ++i)
43+ {
44+ waitForTxReady ();
45+ Dac::setOutput0 (i);
46+ }
47+ }
48+
49+ return 0 ;
50+ }
Original file line number Diff line number Diff line change 1+ <library >
2+ <extends >modm:samv71-xplained-ultra</extends >
3+ <options >
4+ <option name =" modm:build:build.path" >../../../build/samv71_xplained_ultra/dac</option >
5+ </options >
6+ <modules >
7+ <module >modm:build:scons</module >
8+ <module >modm:platform:dac</module >
9+ </modules >
10+ </library >
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ struct SystemClock
3232 static constexpr uint32_t Usart1 = Mck;
3333 static constexpr uint32_t Spi0 = Mck;
3434 static constexpr uint32_t Twihs0 = Mck;
35+ static constexpr uint32_t Dacc = Mck;
3536// static constexpr uint32_t Usb = 48_MHz;
3637
3738 static bool inline
You can’t perform that action at this time.
0 commit comments