From 818790e734a483647dcea0019e61e5c9182eb80c Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 10 Dec 2015 16:32:00 -0800 Subject: [PATCH] Move init/configure details into RSSI/BasebandThread classes. --- firmware/baseband/baseband_thread.cpp | 14 ++++++++++++++ firmware/baseband/main.cpp | 21 +-------------------- firmware/baseband/rssi_thread.cpp | 5 +++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 0ca0fed48..f654bda73 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -23,6 +23,7 @@ #include "dsp_types.hpp" +#include "baseband.hpp" #include "baseband_stats_collector.hpp" #include "baseband_dma.hpp" @@ -39,6 +40,8 @@ #include "portapack_shared_memory.hpp" +#include + Thread* BasebandThread::start(const tprio_t priority) { return chThdCreateStatic(wa, sizeof(wa), priority, ThreadBase::fn, @@ -64,6 +67,15 @@ void BasebandThread::set_configuration(const BasebandConfiguration& new_configur } void BasebandThread::run() { + baseband::dma::init(); + + const auto baseband_buffer = new std::array(); + baseband::dma::configure( + baseband_buffer->data(), + direction() + ); + //baseband::dma::allocate(4, 2048); + BasebandStatsCollector stats { chSysGetIdleThread(), thread_main, @@ -89,6 +101,8 @@ void BasebandThread::run() { } ); } + + delete baseband_buffer; } BasebandProcessor* BasebandThread::create_processor(const int32_t mode) { diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index d5e6fb876..44275bd18 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -29,15 +29,10 @@ #include "gpdma.hpp" -#include "baseband_dma.hpp" - #include "event_m4.hpp" #include "irq_ipc_m4.hpp" -#include "rssi.hpp" -#include "rssi_dma.hpp" - #include "touch_dma.hpp" #include "baseband_thread.hpp" @@ -101,9 +96,6 @@ static void init() { gpdma::controller.enable(); nvicEnableVector(DMA_IRQn, CORTEX_PRIORITY_MASK(LPC_DMA_IRQ_PRIORITY)); - baseband::dma::init(); - - rf::rssi::init(); touch::dma::init(); } @@ -199,25 +191,14 @@ int main(void) { ); /* 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); - if( baseband_thread.direction() == baseband::Direction::Receive ) { - rf::rssi::dma::allocate(4, 400); - } - touch::dma::allocate(); touch::dma::enable(); - const auto baseband_buffer = - new std::array(); - baseband::dma::configure( - baseband_buffer->data(), - baseband_thread.direction() - ); - //baseband::dma::allocate(4, 2048); - event_dispatcher.run(); shutdown(); diff --git a/firmware/baseband/rssi_thread.cpp b/firmware/baseband/rssi_thread.cpp index b084c4948..d7b5f99ca 100644 --- a/firmware/baseband/rssi_thread.cpp +++ b/firmware/baseband/rssi_thread.cpp @@ -36,6 +36,9 @@ Thread* RSSIThread::start(const tprio_t priority) { } void RSSIThread::run() { + rf::rssi::init(); + rf::rssi::dma::allocate(4, 400); + RSSIStatisticsCollector stats; while(true) { @@ -53,4 +56,6 @@ void RSSIThread::run() { } ); } + + rf::rssi::dma::free(); }