Skip to content

Commit

Permalink
WIP Implement modm_abandon for AVR
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Nov 9, 2024
1 parent 078aeea commit 3baacc2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/modm/board/mega_2560_pro/board_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,33 @@ 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);

#include <modm/architecture/interface/accessor.hpp>

modm_extern_c void
modm_abandon(const modm::AssertionInfo &info)
{
MODM_LOG_ERROR << IFSS("Assertion '") << modm::accessor::asFlash(info.name) << IFSS("'");
if (info.context != uintptr_t(-1)) {
MODM_LOG_ERROR << IFSS(" @ ") << (void *) info.context <<
IFSS(" (") << (uint32_t) info.context << IFSS(")");
}
#if MODM_ASSERTION_INFO_HAS_DESCRIPTION
MODM_LOG_ERROR << IFSS(" failed!\n ") << modm::accessor::asFlash(info.description) << IFSS("\nAbandoning...\n");
#else
MODM_LOG_ERROR << IFSS(" failed!\nAbandoning...\n");
#endif

Board::Leds::setOutput();
for(int times=10; times>=0; times--)
{
Board::Leds::write(1);
modm::delay_ms(20);
Board::Leds::write(0);
modm::delay_ms(180);
}
// Do not flush here otherwise you may deadlock due to waiting on the UART
// interrupt which may never be executed when abandoning in a higher
// priority Interrupt!!!
// MODM_LOG_ERROR << modm::flush;
}

0 comments on commit 3baacc2

Please sign in to comment.