-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[examples] Add ITM and RTT on NUCLEO-64 board
- Loading branch information
Showing
4 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2019, 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> | ||
#include <modm/processing.hpp> | ||
|
||
using namespace Board; | ||
|
||
modm::IODeviceWrapper<Itm, modm::IOBuffer::DiscardIfFull> itm_device; | ||
modm::IOStream stream(itm_device); | ||
|
||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
Itm::initialize(); | ||
|
||
stream << "Hello from the SWO." << modm::endl; | ||
stream << "debug" << modm::endl; | ||
stream << "info" << modm::endl; | ||
stream << "warning" << modm::endl; | ||
stream << "error" << modm::endl; | ||
|
||
|
||
while (true) | ||
{ | ||
static modm::PeriodicTimer tmr{500ms}; | ||
if (tmr.execute()) | ||
{ | ||
tmr.restart(Button::read() ? 100ms : 500ms); | ||
LedGreen::toggle(); | ||
|
||
static uint32_t counter{0}; | ||
stream << "loop: " << counter++ << modm::endl; | ||
} | ||
Itm::update(); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<library> | ||
<extends>modm:nucleo-l476rg</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_l476rg/itm</option> | ||
<option name="modm:platform:itm:buffer.tx">250</option> | ||
</options> | ||
<modules> | ||
<module>modm:build:scons</module> | ||
<module>modm:build:make</module> | ||
<module>modm:platform:itm</module> | ||
<module>modm:processing:timer</module> | ||
</modules> | ||
</library> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2021, 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> | ||
#include <modm/processing.hpp> | ||
#include <modm/debug.hpp> | ||
|
||
using namespace Board; | ||
|
||
Rtt rtt(0); | ||
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > rtt_device(rtt); | ||
modm::IOStream rtt_stream(rtt_device); | ||
|
||
#undef MODM_LOG_LEVEL | ||
#define MODM_LOG_LEVEL modm::log::INFO | ||
|
||
/* | ||
$ scons rtt | ||
╭───OpenOCD───> Real Time Transfer | ||
╰─────RTT────── stm32f303vct6 | ||
Info : STLINK V2J16S0 (API v2) VID:PID 0483:3748 | ||
Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints | ||
Info : rtt: Searching for control block 'SEGGER RTT' | ||
Info : rtt: Control block found at 0x20000c04 | ||
Info : Listening on port 9090 for rtt connections | ||
Info | ||
Warning | ||
Error | ||
loop: 0 | ||
loop: 1 | ||
loop: 2 | ||
loop: 3 | ||
loop: 4 | ||
loop: 5 | ||
Type number 0-9, then press enter to send. | ||
The LED should blink slower or faster. | ||
Ctrl+D to exit | ||
*/ | ||
|
||
// ---------------------------------------------------------------------------- | ||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
|
||
rtt_stream << "RTT Demo on Nucleo-64" << modm::endl; | ||
|
||
uint32_t counter(0); | ||
modm::PeriodicTimer tmr(100ms); | ||
|
||
char data; | ||
while (true) | ||
{ | ||
rtt_stream.get(data); | ||
switch(data) | ||
{ | ||
case '0': | ||
tmr.restart(1s); | ||
break; | ||
case '1'...'9': | ||
tmr.restart(std::chrono::milliseconds((data - '0') * 100)); | ||
break; | ||
} | ||
if (tmr.execute()) | ||
{ | ||
LedGreen::toggle(); | ||
|
||
rtt_stream << "loop: " << counter++ << modm::endl; | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<library> | ||
<extends>modm:nucleo-l476rg</extends> | ||
<options> | ||
<option name="modm:build:build.path">../../../build/nucleo_l476rg/rtt</option> | ||
<option name="modm:platform:rtt:buffer.rx">16</option> | ||
</options> | ||
<modules> | ||
<module>modm:platform:rtt</module> | ||
<module>modm:processing:timer</module> | ||
<module>modm:build:scons</module> | ||
<module>modm:debug</module> | ||
</modules> | ||
</library> |