Skip to content

Commit

Permalink
[examples] Add RTT with OpenOCD example
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Apr 12, 2021
1 parent 4d5fffb commit c0d737c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
49 changes: 49 additions & 0 deletions examples/stm32f469_discovery/rtt/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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>

using namespace Board;

Rtt rtt(1);
modm::IODeviceObjectWrapper< Rtt, modm::IOBuffer::DiscardIfFull > device(rtt);
modm::IOStream stream(device);

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

uint32_t counter(0);
modm::PeriodicTimer tmr(100ms);

char data;
while (true)
{
stream.get(data);
switch(data)
{
case '1'...'9':
tmr.restart(std::chrono::milliseconds((data - '0') * 100));
break;
}
if (tmr.execute())
{
LedBlue::toggle();

stream << "loop: " << counter++ << modm::endl;
}
}

return 0;
}
12 changes: 12 additions & 0 deletions examples/stm32f469_discovery/rtt/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library>
<extends>modm:disco-f469ni</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f469_discovery/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>
</modules>
</library>

0 comments on commit c0d737c

Please sign in to comment.