From b5341a8385407a2d5fdbe0f0ece223eb33ee00e3 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Sat, 9 Nov 2024 23:16:13 +0100 Subject: [PATCH] [board] Implement modm_abandon for AVR boards --- src/modm/board/arduino_nano/module.lb | 8 ++++++- src/modm/board/arduino_uno/board_serial.cpp | 22 ------------------- src/modm/board/arduino_uno/module.lb | 5 +++++ src/modm/board/board.cpp.in | 11 +++++----- src/modm/board/mega_2560_pro/board_serial.cpp | 22 ------------------- src/modm/board/mega_2560_pro/module.lb | 5 +++++ 6 files changed, 23 insertions(+), 50 deletions(-) delete mode 100644 src/modm/board/arduino_uno/board_serial.cpp delete mode 100644 src/modm/board/mega_2560_pro/board_serial.cpp diff --git a/src/modm/board/arduino_nano/module.lb b/src/modm/board/arduino_nano/module.lb index 188457cf71..77318e372a 100644 --- a/src/modm/board/arduino_nano/module.lb +++ b/src/modm/board/arduino_nano/module.lb @@ -30,7 +30,13 @@ def prepare(module, options): return True def build(env): - env.outbasepath = "modm/src/modm/" + env.outbasepath = "modm/src/modm/board" + env.substitutions = { + "with_logger": True, + "with_assert": env.has_module(":architecture:assert") + } + env.template("../board.cpp.in", "board.cpp") + env.outbasepath = "modm/src/modm" env.copy(localpath("../arduino_uno"), "board") env.collect(":build:default.avrdude.programmer", "arduino"); env.collect(":build:default.avrdude.baudrate", "115200"); diff --git a/src/modm/board/arduino_uno/board_serial.cpp b/src/modm/board/arduino_uno/board_serial.cpp deleted file mode 100644 index ef7c3b9e45..0000000000 --- a/src/modm/board/arduino_uno/board_serial.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016-2018, 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 "board.hpp" - -// Create an IODeviceWrapper around the Uart Peripheral we want to use -Board::LoggerDevice loggerDevice; - -// Set all four logger streams to use the UART -modm::IOStream serialStream(loggerDevice); -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); diff --git a/src/modm/board/arduino_uno/module.lb b/src/modm/board/arduino_uno/module.lb index b54f21189d..54c8febbda 100644 --- a/src/modm/board/arduino_uno/module.lb +++ b/src/modm/board/arduino_uno/module.lb @@ -31,6 +31,11 @@ def prepare(module, options): def build(env): env.outbasepath = "modm/src/modm/board" + env.substitutions = { + "with_logger": True, + "with_assert": env.has_module(":architecture:assert") + } + env.template("../board.cpp.in", "board.cpp") env.copy('.') env.collect(":build:default.avrdude.programmer", "arduino"); env.collect(":build:default.avrdude.baudrate", "115200"); diff --git a/src/modm/board/board.cpp.in b/src/modm/board/board.cpp.in index 890eb10ca8..7f47316808 100644 --- a/src/modm/board/board.cpp.in +++ b/src/modm/board/board.cpp.in @@ -11,6 +11,7 @@ #include "board.hpp" #include +#include %% if with_assert #include %% endif @@ -37,15 +38,15 @@ modm_extern_c void modm_abandon(const modm::AssertionInfo &info) { %% if with_logger - MODM_LOG_ERROR << "Assertion '" << info.name << "'"; + MODM_LOG_ERROR << IFSS("Assertion '") << modm::accessor::asFlash(info.name) << IFSS("'"); if (info.context != uintptr_t(-1)) { - MODM_LOG_ERROR << " @ " << (void *) info.context << - " (" << (uint32_t) info.context << ")"; + MODM_LOG_ERROR << IFSS(" @ ") << (void *) info.context << + IFSS(" (") << (uint32_t) info.context << IFSS(")"); } #if MODM_ASSERTION_INFO_HAS_DESCRIPTION - MODM_LOG_ERROR << " failed!\n " << info.description << "\nAbandoning...\n"; + MODM_LOG_ERROR << IFSS(" failed!\n ") << modm::accessor::asFlash(info.description) << IFSS("\nAbandoning...\n"); #else - MODM_LOG_ERROR << " failed!\nAbandoning...\n"; + MODM_LOG_ERROR << IFSS(" failed!\nAbandoning...\n"); #endif %% else (void)info; diff --git a/src/modm/board/mega_2560_pro/board_serial.cpp b/src/modm/board/mega_2560_pro/board_serial.cpp deleted file mode 100644 index ef7c3b9e45..0000000000 --- a/src/modm/board/mega_2560_pro/board_serial.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2016-2018, 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 "board.hpp" - -// Create an IODeviceWrapper around the Uart Peripheral we want to use -Board::LoggerDevice loggerDevice; - -// Set all four logger streams to use the UART -modm::IOStream serialStream(loggerDevice); -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); diff --git a/src/modm/board/mega_2560_pro/module.lb b/src/modm/board/mega_2560_pro/module.lb index b01371e4fa..c1cf13d569 100644 --- a/src/modm/board/mega_2560_pro/module.lb +++ b/src/modm/board/mega_2560_pro/module.lb @@ -38,6 +38,11 @@ def prepare(module, options): def build(env): env.outbasepath = "modm/src/modm/board" + env.substitutions = { + "with_logger": True, + "with_assert": env.has_module(":architecture:assert") + } + env.template("../board.cpp.in", "board.cpp") env.copy('.') env.collect(":build:default.avrdude.programmer", "stk500v2"); env.collect(":build:default.avrdude.baudrate", "115200");