File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
examples/nucleo_f429zi/adc_ads868x Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2021, Raphael Lehmann
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
+ #include < modm/driver/adc/ads868x.hpp>
14
+
15
+ using namespace Board ;
16
+
17
+ using SpiMaster = SpiMaster1;
18
+ using Mosi = GpioB5;
19
+ using Miso = GpioB4;
20
+ using Sck = GpioB3;
21
+ using Cs = GpioA4;
22
+ using Rst = GpioF12;
23
+
24
+ using Ads868x = modm::Ads868x<SpiMaster, Cs, Rst>;
25
+
26
+ Ads868x adc{};
27
+
28
+ int
29
+ main ()
30
+ {
31
+ Board::initialize ();
32
+ Leds::setOutput ();
33
+
34
+ MODM_LOG_INFO << " ADS868X Demo on Nucleo-F429ZI\n " << modm::endl;
35
+
36
+ SpiMaster::initialize<Board::SystemClock, 10_MHz>();
37
+ SpiMaster::connect<Sck::Sck, Mosi::Mosi, Miso::Miso>();
38
+
39
+ Rst::setOutput ();
40
+ Cs::setOutput (true );
41
+
42
+ MODM_LOG_INFO << " Initializing ADC..." << modm::endl;
43
+ adc.initialize ();
44
+
45
+ uint32_t counter (0 );
46
+
47
+ while (true )
48
+ {
49
+ Leds::write (counter % ((1 << (Leds::width+1 )) - 1 ));
50
+
51
+ uint16_t result = adc.singleConversion ();
52
+ MODM_LOG_INFO.printf (" ADC Manual: %05u\n " , result);
53
+
54
+ modm::delay (Button::read () ? 1ms : 500ms);
55
+ }
56
+
57
+ return 0 ;
58
+ }
Original file line number Diff line number Diff line change
1
+ <library >
2
+ <extends >modm:nucleo-f429zi</extends >
3
+ <options >
4
+ <option name =" modm:build:build.path" >../../../build/nucleo_f429zi/adc_ads868x</option >
5
+ </options >
6
+ <modules >
7
+ <module >modm:build:scons</module >
8
+ <module >modm:platform:spi:1</module >
9
+ <module >modm:driver:ads868x</module >
10
+ </modules >
11
+ </library >
You can’t perform that action at this time.
0 commit comments