Skip to content

Commit 3ecad35

Browse files
committed
[examples] Add STM32F030 ADC example
1 parent 8053ef9 commit 3ecad35

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2020, Niklas Hauser
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+
#include <modm/board.hpp>
11+
12+
using namespace Board;
13+
14+
int
15+
main()
16+
{
17+
Board::initialize();
18+
19+
Adc::initialize<Board::SystemClock, Adc::ClockMode::Synchronous, 12_MHz>();
20+
const uint16_t Vref = Adc::readInternalVoltageReference();
21+
22+
while (true)
23+
{
24+
int16_t Temp = Adc::readTemperature(Vref);
25+
LedOrange::set(Temp > 30);
26+
modm::delay(1s);
27+
}
28+
29+
return 0;
30+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Replace this with your custom programmer
2+
source [find interface/stlink-v2.cfg]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<library>
2+
<extends>modm:stm32f030_demo</extends>
3+
<options>
4+
<option name="modm:build:build.path">../../../build/stm32f030f4p6_demo/adc</option>
5+
<option name="modm:build:openocd.cfg">openocd.cfg</option>
6+
</options>
7+
<modules>
8+
<module>modm:build:scons</module>
9+
<module>modm:platform:adc</module>
10+
</modules>
11+
</library>

0 commit comments

Comments
 (0)