Add asm_assert macro

This commit is contained in:
Felipe Martinez 2024-07-08 12:49:30 +00:00
parent c9f22468ce
commit 46c25e83bc
2 changed files with 14 additions and 2 deletions

View file

@ -346,9 +346,13 @@ void ASM::Refresh() {
}
}
void ASM::asm_assert(bool condition) {
void ASM::_asm_assert(bool condition, const char* msg) {
if (!condition) {
// TODO: Handle better
if (msg)
NRF_LOG_ERROR("Assertion failed: %s", msg);
for (;;) {
}
}

View file

@ -11,6 +11,14 @@
#include <memory>
#include <chrono>
#if DEBUG
#define STRINGIZE_DETAIL(x) #x
#define STRINGIZE(x) STRINGIZE_DETAIL(x)
#define asm_assert(condition) _asm_assert(condition, __FILE__ ":" STRINGIZE(__LINE__) " " #condition)
#else
#define asm_assert(condition) _asm_assert(condition, NULL)
#endif
namespace Pinetime {
namespace Applications {
namespace Screens {
@ -199,7 +207,7 @@ namespace Pinetime {
bool showingStatusIcons = false;
void run();
void asm_assert(bool condition);
void _asm_assert(bool condition, const char* msg);
std::shared_ptr<Value> pop() {
asm_assert(stack_pointer > 0);