File tree Expand file tree Collapse file tree
examples/nucleo_f429zi/adc_ads868x Expand file tree Collapse file tree 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/platform/spi/spi_master_1.hpp>
14+ #include < modm/driver/adc/ads868x.hpp>
15+
16+ using namespace Board ;
17+
18+ using SpiMaster = SpiMaster1;
19+ using Mosi = GpioB5;
20+ using Miso = GpioB4;
21+ using Sck = GpioB3;
22+ using Cs = GpioA4;
23+ using Rst = GpioF12;
24+
25+ using Ads868x = modm::Ads868x<SpiMaster, Cs, Rst>;
26+
27+ Ads868x adc{};
28+
29+ int
30+ main ()
31+ {
32+ Board::initialize ();
33+ Leds::setOutput ();
34+
35+ MODM_LOG_INFO << " ADS868X Demo on Nucleo-F429ZI\n " << modm::endl;
36+
37+ SpiMaster::initialize<Board::SystemClock, 10_MHz>();
38+ SpiMaster::connect<Sck::Sck, Mosi::Mosi, Miso::Miso>();
39+
40+ Rst::setOutput ();
41+ Cs::setOutput (true );
42+
43+ MODM_LOG_INFO << " Initializing ADC..." << modm::endl;
44+ adc.initialize ();
45+
46+ uint32_t counter (0 );
47+
48+ while (true )
49+ {
50+ Leds::write (counter % ((1 << (Leds::width+1 )) - 1 ));
51+
52+ uint16_t result = RF_CALL_BLOCKING (adc.singleConversion ());
53+ MODM_LOG_INFO.printf (" ADC Manual: %05u\n " , result);
54+
55+ modm::delay (Button::read () ? 1ms : 500ms);
56+ }
57+
58+ return 0 ;
59+ }
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