diff --git a/firmware/application/event_m0.cpp b/firmware/application/event_m0.cpp index 33c81ad3..a8705abc 100644 --- a/firmware/application/event_m0.cpp +++ b/firmware/application/event_m0.cpp @@ -145,6 +145,10 @@ void EventDispatcher::dispatch(const eventmask_t events) { handle_application_queue(); } + if( events & EVT_MASK_LOCAL ) { + handle_local_queue(); + } + if( events & EVT_MASK_RTC_TICK ) { handle_rtc_tick(); } @@ -174,6 +178,12 @@ void EventDispatcher::handle_application_queue() { }); } +void EventDispatcher::handle_local_queue() { + shared_memory.app_local_queue.handle([](Message* const message) { + message_map.send(message); + }); +} + void EventDispatcher::handle_rtc_tick() { sd_card::poll_inserted(); @@ -288,6 +298,9 @@ void EventDispatcher::init_message_queues() { new (&shared_memory.application_queue) MessageQueue( shared_memory.application_queue_data, SharedMemory::application_queue_k ); + new (&shared_memory.app_local_queue) MessageQueue( + shared_memory.app_local_queue_data, SharedMemory::app_local_queue_k + ); } MessageHandlerRegistration::MessageHandlerRegistration( diff --git a/firmware/application/event_m0.hpp b/firmware/application/event_m0.hpp index cdf73e84..fcf36102 100644 --- a/firmware/application/event_m0.hpp +++ b/firmware/application/event_m0.hpp @@ -86,6 +86,7 @@ private: static constexpr auto EVT_MASK_RTC_TICK = EVENT_MASK(0); static constexpr auto EVT_MASK_LCD_FRAME_SYNC = EVENT_MASK(1); static constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6); + static constexpr auto EVT_MASK_LOCAL = EVENT_MASK(7); static Thread* thread_event_loop; @@ -102,6 +103,7 @@ private: void dispatch(const eventmask_t events); void handle_application_queue(); + void handle_local_queue(); void handle_rtc_tick(); static ui::Widget* touch_widget(ui::Widget* const w, ui::TouchEvent event); diff --git a/firmware/common/portapack_shared_memory.hpp b/firmware/common/portapack_shared_memory.hpp index 3310f033..a2ffe841 100644 --- a/firmware/common/portapack_shared_memory.hpp +++ b/firmware/common/portapack_shared_memory.hpp @@ -35,11 +35,14 @@ struct TouchADCFrame { struct SharedMemory { static constexpr size_t baseband_queue_k = 11; static constexpr size_t application_queue_k = 11; + static constexpr size_t app_local_queue_k = 11; uint8_t baseband_queue_data[1 << baseband_queue_k]; uint8_t application_queue_data[1 << application_queue_k]; + uint8_t app_local_queue_data[1 << app_local_queue_k]; MessageQueue baseband_queue; MessageQueue application_queue; + MessageQueue app_local_queue; // TODO: M0 should directly configure and control DMA channel that is // acquiring ADC samples.