Skip to content

Commit

Permalink
[examples] Add STM32F030 ADC example
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 14, 2021
1 parent 8053ef9 commit 3ecad35
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/stm32f030f4p6_demo_board/adc/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2020, Niklas Hauser
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <modm/board.hpp>

using namespace Board;

int
main()
{
Board::initialize();

Adc::initialize<Board::SystemClock, Adc::ClockMode::Synchronous, 12_MHz>();
const uint16_t Vref = Adc::readInternalVoltageReference();

while (true)
{
int16_t Temp = Adc::readTemperature(Vref);
LedOrange::set(Temp > 30);
modm::delay(1s);
}

return 0;
}
2 changes: 2 additions & 0 deletions examples/stm32f030f4p6_demo_board/adc/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Replace this with your custom programmer
source [find interface/stlink-v2.cfg]
11 changes: 11 additions & 0 deletions examples/stm32f030f4p6_demo_board/adc/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:stm32f030_demo</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f030f4p6_demo/adc</option>
<option name="modm:build:openocd.cfg">openocd.cfg</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:platform:adc</module>
</modules>
</library>

0 comments on commit 3ecad35

Please sign in to comment.