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;
EventDispatcher::EventDispatcher(
std::unique_ptr<BasebandProcessor> 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);
}

View File

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

View File

@ -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<CaptureProcessor>() };
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;