Move init/configure details into RSSI/BasebandThread classes.

This commit is contained in:
Jared Boone 2015-12-10 16:32:00 -08:00
parent ed25f65e8b
commit 818790e734
3 changed files with 20 additions and 20 deletions

View File

@ -23,6 +23,7 @@
#include "dsp_types.hpp" #include "dsp_types.hpp"
#include "baseband.hpp"
#include "baseband_stats_collector.hpp" #include "baseband_stats_collector.hpp"
#include "baseband_dma.hpp" #include "baseband_dma.hpp"
@ -39,6 +40,8 @@
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include <array>
Thread* BasebandThread::start(const tprio_t priority) { Thread* BasebandThread::start(const tprio_t priority) {
return chThdCreateStatic(wa, sizeof(wa), return chThdCreateStatic(wa, sizeof(wa),
priority, ThreadBase::fn, priority, ThreadBase::fn,
@ -64,6 +67,15 @@ void BasebandThread::set_configuration(const BasebandConfiguration& new_configur
} }
void BasebandThread::run() { void BasebandThread::run() {
baseband::dma::init();
const auto baseband_buffer = new std::array<baseband::sample_t, 8192>();
baseband::dma::configure(
baseband_buffer->data(),
direction()
);
//baseband::dma::allocate(4, 2048);
BasebandStatsCollector stats { BasebandStatsCollector stats {
chSysGetIdleThread(), chSysGetIdleThread(),
thread_main, thread_main,
@ -89,6 +101,8 @@ void BasebandThread::run() {
} }
); );
} }
delete baseband_buffer;
} }
BasebandProcessor* BasebandThread::create_processor(const int32_t mode) { BasebandProcessor* BasebandThread::create_processor(const int32_t mode) {

View File

@ -29,15 +29,10 @@
#include "gpdma.hpp" #include "gpdma.hpp"
#include "baseband_dma.hpp"
#include "event_m4.hpp" #include "event_m4.hpp"
#include "irq_ipc_m4.hpp" #include "irq_ipc_m4.hpp"
#include "rssi.hpp"
#include "rssi_dma.hpp"
#include "touch_dma.hpp" #include "touch_dma.hpp"
#include "baseband_thread.hpp" #include "baseband_thread.hpp"
@ -101,9 +96,6 @@ static void init() {
gpdma::controller.enable(); gpdma::controller.enable();
nvicEnableVector(DMA_IRQn, CORTEX_PRIORITY_MASK(LPC_DMA_IRQ_PRIORITY)); nvicEnableVector(DMA_IRQn, CORTEX_PRIORITY_MASK(LPC_DMA_IRQ_PRIORITY));
baseband::dma::init();
rf::rssi::init();
touch::dma::init(); touch::dma::init();
} }
@ -199,25 +191,14 @@ int main(void) {
); );
/* TODO: Ensure DMAs are configured to point at first LLI in chain. */ /* TODO: Ensure DMAs are configured to point at first LLI in chain. */
baseband_thread.thread_main = chThdSelf(); baseband_thread.thread_main = chThdSelf();
baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10); baseband_thread.thread_rssi = rssi_thread.start(NORMALPRIO + 10);
baseband_thread.start(NORMALPRIO + 20); baseband_thread.start(NORMALPRIO + 20);
if( baseband_thread.direction() == baseband::Direction::Receive ) {
rf::rssi::dma::allocate(4, 400);
}
touch::dma::allocate(); touch::dma::allocate();
touch::dma::enable(); touch::dma::enable();
const auto baseband_buffer =
new std::array<baseband::sample_t, 8192>();
baseband::dma::configure(
baseband_buffer->data(),
baseband_thread.direction()
);
//baseband::dma::allocate(4, 2048);
event_dispatcher.run(); event_dispatcher.run();
shutdown(); shutdown();

View File

@ -36,6 +36,9 @@ Thread* RSSIThread::start(const tprio_t priority) {
} }
void RSSIThread::run() { void RSSIThread::run() {
rf::rssi::init();
rf::rssi::dma::allocate(4, 400);
RSSIStatisticsCollector stats; RSSIStatisticsCollector stats;
while(true) { while(true) {
@ -53,4 +56,6 @@ void RSSIThread::run() {
} }
); );
} }
rf::rssi::dma::free();
} }