Give new Processor to EventDispatcher.

This commit is contained in:
Jared Boone 2016-06-25 11:14:28 -07:00
parent 525e72ac86
commit 1a5f3a4422
3 changed files with 25 additions and 11 deletions

View file

@ -51,6 +51,12 @@ CH_IRQ_HANDLER(MAPP_IRQHandler) {
Thread* EventDispatcher::thread_event_loop = nullptr; Thread* EventDispatcher::thread_event_loop = nullptr;
EventDispatcher::EventDispatcher(
std::unique_ptr<BasebandProcessor> baseband_processor
) : baseband_processor { std::move(baseband_processor) }
{
}
void EventDispatcher::run() { void EventDispatcher::run() {
thread_event_loop = chThdSelf(); thread_event_loop = chThdSelf();
@ -107,10 +113,10 @@ void EventDispatcher::on_message_shutdown(const ShutdownMessage&) {
} }
void EventDispatcher::on_message_default(const Message* const message) { void EventDispatcher::on_message_default(const Message* const message) {
baseband_thread.on_message(message); baseband_processor->on_message(message);
} }
void EventDispatcher::handle_spectrum() { void EventDispatcher::handle_spectrum() {
const UpdateSpectrumMessage message; const UpdateSpectrumMessage message;
baseband_thread.on_message(&message); baseband_processor->on_message(&message);
} }

View file

@ -36,6 +36,8 @@ constexpr auto EVT_MASK_SPECTRUM = EVENT_MASK(1);
class EventDispatcher { class EventDispatcher {
public: public:
EventDispatcher(std::unique_ptr<BasebandProcessor> baseband_processor);
void run(); void run();
void request_stop(); void request_stop();
@ -50,6 +52,7 @@ public:
private: private:
static Thread* thread_event_loop; static Thread* thread_event_loop;
std::unique_ptr<BasebandProcessor> baseband_processor;
bool is_running = true; bool is_running = true;

View file

@ -32,9 +32,14 @@
#include "touch_dma.hpp" #include "touch_dma.hpp"
#include "baseband_thread.hpp" #include "proc_am_audio.hpp"
#include "rssi_thread.hpp" #include "proc_nfm_audio.hpp"
#include "baseband_processor.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" #include "message_queue.hpp"
@ -85,6 +90,11 @@ static void init() {
touch::dma::enable(); touch::dma::enable();
} }
static void run() {
EventDispatcher event_dispatcher { std::make_unique<CaptureProcessor>() };
event_dispatcher.run();
}
static void halt() { static void halt() {
port_disable(); port_disable();
while(true) { while(true) {
@ -109,12 +119,7 @@ static void shutdown() {
int main(void) { int main(void) {
init(); init();
run();
/* TODO: Ensure DMAs are configured to point at first LLI in chain. */
EventDispatcher event_dispatcher;
event_dispatcher.run();
shutdown(); shutdown();
return 0; return 0;