Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
54 lines (44 loc) · 1.36 KB

File metadata and controls

54 lines (44 loc) · 1.36 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright (c) 2021, Christopher Durand
*
* 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;
// Blink LED with timer 2 interrupt. A custom handler is configured at runtime
// in the vector table located in SRAM.
// If the LED is blinking with a period of 1 second, the vector table has been
// successfully relocated to ram.
// Set the option "modm:platform:cortex-m:vector_table_location" in project.xml
// to place the vector table in ram.
static void tim2Handler()
{
Timer2::acknowledgeInterruptFlags(Timer2::InterruptFlag::Update);
LedD13::toggle();
}
int
main()
{
Board::initialize();
LedD13::setOutput();
// Set custom handler, only works if vector table is in RAM
NVIC_SetVector(TIM2_IRQn, reinterpret_cast<uintptr_t>(&tim2Handler));
Timer2::enable();
Timer2::setMode(Timer2::Mode::UpCounter);
Timer2::setPeriod<Board::SystemClock>(500ms);
Timer2::applyAndReset();
Timer2::start();
Timer2::enableInterrupt(Timer2::Interrupt::Update);
Timer2::enableInterruptVector(true, 5);
uint32_t counter{0};
while (true)
{
modm::delay(100ms);
MODM_LOG_INFO << "loop: " << counter++ << modm::endl;
}
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.