File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed
examples/stm32f469_discovery/printf Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change 1111
1212#include < modm/board.hpp>
1313
14- extern " C"
15- void putchar_ (char c)
16- {
17- // Redirect the printf output to UART.
18- Board::stlink::Uart::write (c);
19- // or IOStream if the board already has a logger
20- // MODM_LOG_INFO << c;
21- }
22-
23- // ----------------------------------------------------------------------------
2414int
2515main ()
2616{
Original file line number Diff line number Diff line change 1414%% if with_assert
1515#include <modm/architecture/interface/assert.hpp>
1616%% endif
17-
17+ %#
1818%% if with_logger
1919Board::LoggerDevice loggerDevice;
2020
@@ -23,8 +23,15 @@ modm::log::Logger modm::log::debug(loggerDevice);
2323modm::log::Logger modm::log::info(loggerDevice);
2424modm::log::Logger modm::log::warning(loggerDevice);
2525modm::log::Logger modm::log::error(loggerDevice);
26- %% endif
2726
27+ // Default all calls to printf to the UART
28+ modm_extern_c void
29+ putchar_(char c)
30+ {
31+ loggerDevice.write(c);
32+ }
33+ %% endif
34+ %#
2835%% if with_assert
2936modm_extern_c void
3037modm_abandon(const modm::AssertionInfo &info)
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ The BSPs all use a common interface within a top-level `namespace Board`:
2525 ` modm::platform::Gpio{port}{pin} ` .
2626
2727If the board supports a dedicated serial logging output the BSP redirects the
28- ` modm:debug ` module debug stream ` MODM_LOG_INFO ` etc.
28+ ` modm:debug ` module debug stream ` MODM_LOG_INFO ` as well as the output of the
29+ standalone ` printf ` function.
2930
3031Please note that YOU must explicitly call the ` Board ` functions to initialize
3132your hardware, just including the board module is not enough.
You can’t perform that action at this time.
0 commit comments