mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-12 15:23:39 +00:00
Capture M4 chDbgPanic msg, show in application.
This commit is contained in:
parent
97ba19af24
commit
eac4cf678a
@ -40,6 +40,8 @@ using namespace lpc43xx;
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#include "ui_font_fixed_8x16.hpp"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
CH_IRQ_HANDLER(M4Core_IRQHandler) {
|
CH_IRQ_HANDLER(M4Core_IRQHandler) {
|
||||||
@ -133,6 +135,40 @@ eventmask_t EventDispatcher::wait() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::dispatch(const eventmask_t events) {
|
void EventDispatcher::dispatch(const eventmask_t events) {
|
||||||
|
if( shared_memory.m4_panic_msg[0] != 0 ) {
|
||||||
|
halt = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( halt ) {
|
||||||
|
if( shared_memory.m4_panic_msg[0] != 0 ) {
|
||||||
|
painter.fill_rectangle(
|
||||||
|
{ 0, 0, portapack::display.width(), portapack::display.height() },
|
||||||
|
ui::Color::red()
|
||||||
|
);
|
||||||
|
|
||||||
|
constexpr int border = 8;
|
||||||
|
painter.fill_rectangle(
|
||||||
|
{ border, border, portapack::display.width() - (border * 2), portapack::display.height() - (border * 2) },
|
||||||
|
ui::Color::black()
|
||||||
|
);
|
||||||
|
|
||||||
|
painter.draw_string({ 48, 24 }, top_widget->style(), "M4 Guru Meditation");
|
||||||
|
|
||||||
|
shared_memory.m4_panic_msg[sizeof(shared_memory.m4_panic_msg) - 1] = 0;
|
||||||
|
const std::string message = shared_memory.m4_panic_msg;
|
||||||
|
const int x_offset = (portapack::display.width() - (message.size() * 8)) / 2;
|
||||||
|
constexpr int y_offset = (portapack::display.height() - 16) / 2;
|
||||||
|
painter.draw_string(
|
||||||
|
{ x_offset, y_offset },
|
||||||
|
top_widget->style(),
|
||||||
|
message
|
||||||
|
);
|
||||||
|
|
||||||
|
shared_memory.m4_panic_msg[0] = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( events & EVT_MASK_APPLICATION ) {
|
if( events & EVT_MASK_APPLICATION ) {
|
||||||
handle_application_queue();
|
handle_application_queue();
|
||||||
}
|
}
|
||||||
@ -291,6 +327,7 @@ void EventDispatcher::init_message_queues() {
|
|||||||
new (&shared_memory.app_local_queue) MessageQueue(
|
new (&shared_memory.app_local_queue) MessageQueue(
|
||||||
shared_memory.app_local_queue_data, SharedMemory::app_local_queue_k
|
shared_memory.app_local_queue_data, SharedMemory::app_local_queue_k
|
||||||
);
|
);
|
||||||
|
shared_memory.m4_panic_msg[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageHandlerRegistration::MessageHandlerRegistration(
|
MessageHandlerRegistration::MessageHandlerRegistration(
|
||||||
|
@ -102,6 +102,7 @@ private:
|
|||||||
bool is_running = true;
|
bool is_running = true;
|
||||||
bool sd_card_present = false;
|
bool sd_card_present = false;
|
||||||
bool display_sleep = false;
|
bool display_sleep = false;
|
||||||
|
bool halt = false;
|
||||||
|
|
||||||
eventmask_t wait();
|
eventmask_t wait();
|
||||||
void dispatch(const eventmask_t events);
|
void dispatch(const eventmask_t events);
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
|
#include "portapack_shared_memory.hpp"
|
||||||
|
|
||||||
#if defined(LPC43XX_M0)
|
#if defined(LPC43XX_M0)
|
||||||
static void debug_indicate_error_init() {
|
static void debug_indicate_error_init() {
|
||||||
// TODO: Get knowledge of LED GPIO port/bit from shared place.
|
// TODO: Get knowledge of LED GPIO port/bit from shared place.
|
||||||
@ -75,6 +77,16 @@ void __early_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void port_halt(void) {
|
void port_halt(void) {
|
||||||
|
// Copy debug panic message to M0 region.
|
||||||
|
const auto* p = dbg_panic_msg;
|
||||||
|
for(size_t i=0; i<sizeof(shared_memory.m4_panic_msg); i++) {
|
||||||
|
if( *p == 0 ) {
|
||||||
|
shared_memory.m4_panic_msg[i] = 0;
|
||||||
|
} else {
|
||||||
|
shared_memory.m4_panic_msg[i] = *(p++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
port_disable();
|
port_disable();
|
||||||
runtime_error();
|
runtime_error();
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@ struct SharedMemory {
|
|||||||
// TODO: M0 should directly configure and control DMA channel that is
|
// TODO: M0 should directly configure and control DMA channel that is
|
||||||
// acquiring ADC samples.
|
// acquiring ADC samples.
|
||||||
TouchADCFrame touch_adc_frame;
|
TouchADCFrame touch_adc_frame;
|
||||||
|
|
||||||
|
char m4_panic_msg[32];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SharedMemory& shared_memory;
|
extern SharedMemory& shared_memory;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user