Skip to content

Commit

Permalink
[example] Add C++ exceptions and RTTI example
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Mar 11, 2020
1 parent f00e789 commit 4b5de7b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
41 changes: 41 additions & 0 deletions examples/stm32f469_discovery/exceptions_rtti/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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>
#include <typeinfo>

using namespace Board;

// ----------------------------------------------------------------------------
int
main()
{
Board::initialize();
LedD13::setOutput(modm::Gpio::Low);
uint32_t counter(0);

MODM_LOG_INFO << "TypeId for LedD13: " << typeid(LedD13).name() << modm::endl;

while (true)
{
LedBlue::toggle();
modm::delayMilliseconds(500);

try {
throw counter++;
}
catch (uint32_t code) {
MODM_LOG_ERROR << "Caught exception #" << code << modm::endl;
}
}

return 0;
}
12 changes: 12 additions & 0 deletions examples/stm32f469_discovery/exceptions_rtti/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/exceptions_rtti</option>
<option name="modm:stdc++:exceptions">true</option>
<option name="modm:stdc++:rtti">true</option>
</options>
<modules>
<module>modm:platform:gpio</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit 4b5de7b

Please sign in to comment.