From 1a5f3a4422b0f735d2b82b190c2f666d8d733d84 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 25 Jun 2016 11:14:28 -0700 Subject: [PATCH] Give new Processor to EventDispatcher. --- firmware/baseband/event_m4.cpp | 10 ++++++++-- firmware/baseband/event_m4.hpp | 3 +++ firmware/baseband/main.cpp | 23 ++++++++++++++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/firmware/baseband/event_m4.cpp b/firmware/baseband/event_m4.cpp index 0ef97bba1..49c98caf1 100644 --- a/firmware/baseband/event_m4.cpp +++ b/firmware/baseband/event_m4.cpp @@ -51,6 +51,12 @@ CH_IRQ_HANDLER(MAPP_IRQHandler) { Thread* EventDispatcher::thread_event_loop = nullptr; +EventDispatcher::EventDispatcher( + std::unique_ptr baseband_processor +) : baseband_processor { std::move(baseband_processor) } +{ +} + void EventDispatcher::run() { thread_event_loop = chThdSelf(); @@ -107,10 +113,10 @@ void EventDispatcher::on_message_shutdown(const ShutdownMessage&) { } void EventDispatcher::on_message_default(const Message* const message) { - baseband_thread.on_message(message); + baseband_processor->on_message(message); } void EventDispatcher::handle_spectrum() { const UpdateSpectrumMessage message; - baseband_thread.on_message(&message); + baseband_processor->on_message(&message); } diff --git a/firmware/baseband/event_m4.hpp b/firmware/baseband/event_m4.hpp index 09b00fa2f..42b5d3b90 100644 --- a/firmware/baseband/event_m4.hpp +++ b/firmware/baseband/event_m4.hpp @@ -36,6 +36,8 @@ constexpr auto EVT_MASK_SPECTRUM = EVENT_MASK(1); class EventDispatcher { public: + EventDispatcher(std::unique_ptr baseband_processor); + void run(); void request_stop(); @@ -50,6 +52,7 @@ public: private: static Thread* thread_event_loop; + std::unique_ptr baseband_processor; bool is_running = true; diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index 5f8a7da0f..5f8179906 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -32,9 +32,14 @@ #include "touch_dma.hpp" -#include "baseband_thread.hpp" -#include "rssi_thread.hpp" -#include "baseband_processor.hpp" +#include "proc_am_audio.hpp" +#include "proc_nfm_audio.hpp" +#include "proc_wfm_audio.hpp" +#include "proc_ais.hpp" +#include "proc_wideband_spectrum.hpp" +#include "proc_tpms.hpp" +#include "proc_ert.hpp" +#include "proc_capture.hpp" #include "message_queue.hpp" @@ -85,6 +90,11 @@ static void init() { touch::dma::enable(); } +static void run() { + EventDispatcher event_dispatcher { std::make_unique() }; + event_dispatcher.run(); +} + static void halt() { port_disable(); while(true) { @@ -109,12 +119,7 @@ static void shutdown() { int main(void) { init(); - - /* TODO: Ensure DMAs are configured to point at first LLI in chain. */ - - EventDispatcher event_dispatcher; - event_dispatcher.run(); - + run(); shutdown(); return 0;