From 6328efb70b075fec76b46a0268388d83e80483b7 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 10 Dec 2015 17:10:28 -0800 Subject: [PATCH] Move more baseband main() code into EventDispatcher. EventDispatcher might be ripe for a refactor or rename. --- firmware/baseband/main.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index 44275bd1..1edf4713 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -125,6 +125,23 @@ public: } void run() { + message_map.register_handler(Message::ID::BasebandConfiguration, + [](const Message* const p) { + auto message = reinterpret_cast(p); + baseband_thread.set_configuration(message->configuration); + } + ); + + message_map.register_handler(Message::ID::Shutdown, + [this](const Message* const) { + this->request_stop(); + } + ); + + baseband_thread.thread_main = chThdSelf(); + baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10); + baseband_thread.start(NORMALPRIO + 20); + while(is_running) { const auto events = wait(); dispatch(events); @@ -175,26 +192,8 @@ int main(void) { m0apptxevent_interrupt_enable(); EventDispatcher event_dispatcher; - auto& message_handlers = event_dispatcher.message_handlers(); - - message_handlers.register_handler(Message::ID::BasebandConfiguration, - [](const Message* const p) { - auto message = reinterpret_cast(p); - baseband_thread.set_configuration(message->configuration); - } - ); - - message_handlers.register_handler(Message::ID::Shutdown, - [&event_dispatcher](const Message* const) { - event_dispatcher.request_stop(); - } - ); /* TODO: Ensure DMAs are configured to point at first LLI in chain. */ - - baseband_thread.thread_main = chThdSelf(); - baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10); - baseband_thread.start(NORMALPRIO + 20); touch::dma::allocate(); touch::dma::enable();