Skip to content

Commit

Permalink
[examples] Add ITM example for NUCLEO-F103RB
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed May 23, 2019
1 parent b3728d9 commit 47adfd6
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ make gdb

## Interesting Examples

We have a lot of examples, <!--examplecount-->176<!--/examplecount--> to be
We have a lot of examples, <!--examplecount-->177<!--/examplecount--> to be
exact, but here are some of our favorite examples for our supported development
boards:

Expand Down
52 changes: 52 additions & 0 deletions examples/nucleo_f103rb/itm/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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();
LedD13::setOutput();

// Done by OpenOCD: scons itm fcpu=64000000
// Itm::initialize<Board::SystemClock, 500_kHz>();
// Itm::connect<GpioB3::Traceswo>();

stream << "Hello from the SWO." << modm::endl;
stream << "debug" << modm::endl;
stream << "info" << modm::endl;
stream << "warning" << modm::endl;
stream << "error" << modm::endl;


while (1)
{
static modm::PeriodicTimer tmr{500};
if (tmr.execute())
{
tmr.restart(Button::read() ? 100 : 500);
LedD13::toggle();

static uint32_t counter{0};
stream << "loop: " << counter++ << modm::endl;
}
Itm::update();
}

return 0;
}
11 changes: 11 additions & 0 deletions examples/nucleo_f103rb/itm/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<library>
<extends>modm:nucleo-f103rb</extends>
<options>
<option name="modm:build:build.path">../../../build/nucleo_f103rb/itm</option>
<option name="modm:platform:itm:buffer.tx">250</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:platform:itm</module>
</modules>
</library>

0 comments on commit 47adfd6

Please sign in to comment.