diff --git a/examples/stm32c0x/blink-timer/main.cpp b/examples/stm32c0x/blink-timer/main.cpp index a386b59a5c..4a0b2ba896 100644 --- a/examples/stm32c0x/blink-timer/main.cpp +++ b/examples/stm32c0x/blink-timer/main.cpp @@ -8,6 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include #include #include "../custom-board.hpp" @@ -15,15 +16,29 @@ using namespace Board; using namespace std::chrono_literals; +// --- UART Debugging --- +#undef MODM_LOG_LEVEL +#define MODM_LOG_LEVEL modm::log::DEBUG +// Create an IODeviceWrapper around the Uart Peripheral we want to use +modm::IODeviceWrapper loggerDevice; +// Set all four logger streams to use the UART +modm::log::Logger modm::log::debug(loggerDevice); +modm::log::Logger modm::log::info(loggerDevice); +modm::log::Logger modm::log::warning(loggerDevice); +modm::log::Logger modm::log::error(loggerDevice); + + MODM_ISR(TIM14) { Timer14::acknowledgeInterruptFlags(Timer14::InterruptFlag::Update); + MODM_LOG_DEBUG << "Toggle green LED" << modm::endl; LedGn::toggle(); } MODM_ISR(TIM16) { Timer16::acknowledgeInterruptFlags(Timer16::InterruptFlag::Update); + MODM_LOG_DEBUG << "Toggle red LED" << modm::endl; LedRd::toggle(); } @@ -32,6 +47,12 @@ main() { Board::initialize(); + // Initialize prototyping-UART for MODM_LOG_* + proto_uart::Uart::connect(); + proto_uart::Uart::initialize(); + + MODM_LOG_INFO << "Board & Logger initialized" << modm::endl; + Timer14::enable(); Timer14::setMode(Timer14::Mode::UpCounter); Timer14::setPeriod(1000ms); diff --git a/examples/stm32c0x/blink-timer/project.xml b/examples/stm32c0x/blink-timer/project.xml index 4bdf8a24ff..f6a80e5062 100644 --- a/examples/stm32c0x/blink-timer/project.xml +++ b/examples/stm32c0x/blink-timer/project.xml @@ -9,12 +9,15 @@ + modm:architecture:clock + modm:build:scons + modm:debug modm:platform:core modm:platform:rcc modm:platform:gpio modm:platform:timer:14 modm:platform:timer:16 - modm:architecture:clock - modm:build:scons + modm:platform:uart:1 + modm:platform:uart:2 diff --git a/examples/stm32c0x/custom-board.hpp b/examples/stm32c0x/custom-board.hpp index 5ce3e28c2d..d5b5caf464 100644 --- a/examples/stm32c0x/custom-board.hpp +++ b/examples/stm32c0x/custom-board.hpp @@ -13,9 +13,6 @@ #include #include -// #include -/// @ingroup modm_board_custom_stm32c0x modm_board_custom_stm32c0x -// #define MODM_BOARD_HAS_LOGGER using namespace modm::platform; @@ -40,6 +37,8 @@ struct SystemClock static constexpr uint32_t Timer14 = Apb; static constexpr uint32_t Timer16 = Apb; static constexpr uint32_t Timer17 = Apb; + static constexpr uint32_t Usart1 = Ahb; + static constexpr uint32_t Usart2 = Ahb; static bool inline enable() { @@ -60,19 +59,25 @@ using LedRd = GpioC14; using Leds = SoftwareGpioPort; /// @} -/*namespace stlink +namespace om_uart { -/// @ingroup modm_board_custom_stm32c0x modm_board_custom_stm32c0x +/// @ingroup modm_board_custom_stm32c0x /// @{ -using Rx = GpioInputA3; -using Tx = GpioOutputA2; -using Uart = BufferedUart>; +using Tx = GpioOutputA9; +using Rx = GpioInputA10; +using Uart = BufferedUart>; /// @} -}*/ +} // namespace om_uart -/// @ingroup modm_board_custom_stm32c0x modm_board_custom_stm32c0x +namespace proto_uart +{ +/// @ingroup modm_board_custom_stm32c0x /// @{ -// using LoggerDevice = modm::IODeviceWrapper< stlink::Uart, modm::IOBuffer::BlockIfFull >; +using Tx = GpioOutputA4; +using Rx = GpioInputA5; +using Uart = BufferedUart>; +/// @} +} // namespace proto_uart inline void initialize() @@ -80,13 +85,13 @@ initialize() SystemClock::enable(); SysTickTimer::initialize(); - // stlink::Uart::connect(); - // stlink::Uart::initialize(); + // Remap om_uart GPIOs + GpioA9::remap(); // Remap A9 -> A11 + GpioA10::remap(); // Remap A10 -> A12 LedGn::setOutput(); LedRd::setOutput(); } -/// @} } // namespace Board diff --git a/src/modm/platform/uart/stm32/module.lb b/src/modm/platform/uart/stm32/module.lb index 3501d4ebb3..b8b4a4e949 100644 --- a/src/modm/platform/uart/stm32/module.lb +++ b/src/modm/platform/uart/stm32/module.lb @@ -113,9 +113,9 @@ def prepare(module, options): global props drivers = (device.get_all_drivers("uart") + device.get_all_drivers("usart") + device.get_all_drivers("lpuart")) - props["extended_driver"] = ("extended" in drivers[0]["type"]) + props["extended_driver"] = ("extended" in drivers[0]["type"]) or device.identifier.family == "c0" # FIXME: C0 doesn't has this feature in modm-devices. Add there? props["over8"] = ("feature" in drivers[0]) and ("over8" in drivers[0]["feature"]) - props["tcbgt"] = ("feature" in drivers[0]) and ("tcbgt" in drivers[0]["feature"]) + props["tcbgt"] = (("feature" in drivers[0]) and ("tcbgt" in drivers[0]["feature"])) or device.identifier.family == "c0" # FIXME: C0 doesn't has this feature in modm-devices. Add there? props["instances"] = [] for driver in drivers: