Move SGPIO configuration and control to baseband firmware.

Addresses long-standing and annoying bug where SGPIO DMA channel would not disable -- and not configure cleanly next time it was needed. My theory is that the DMA channel couldn't disable until it got a request from the peripheral, and sometimes the peripheral was disabled before that last request.

Anyway, the baseband firmware should control the SGPIO, methinks, despite the impact on baseband code size.
This commit is contained in:
Jared Boone 2016-01-10 10:23:39 -08:00
parent 8fde4972b4
commit 0647f26707
6 changed files with 8 additions and 20 deletions

View File

@ -135,7 +135,6 @@ CPPSRC = main.cpp \
wm8731.cpp \
radio.cpp \
baseband_cpld.cpp \
baseband_sgpio.cpp \
tuning.cpp \
rf_path.cpp \
rffc507x.cpp \

View File

@ -24,7 +24,6 @@
#include "rf_path.hpp"
#include "max5864.hpp"
#include "baseband_cpld.hpp"
#include "baseband_sgpio.hpp"
#include "portapack_shared_memory.hpp"
#include "tuning.hpp"
@ -90,7 +89,6 @@ rffc507x::RFFC507x first_if;
max2837::MAX2837 second_if { ssp1_target_max2837 };
static max5864::MAX5864 baseband_codec { ssp1_target_max5864 };
static baseband::CPLD baseband_cpld;
static baseband::SGPIO baseband_sgpio;
static rf::Direction direction { rf::Direction::Receive };
@ -100,7 +98,6 @@ void init() {
second_if.init();
baseband_codec.init();
baseband_cpld.init();
baseband_sgpio.init();
}
void set_direction(const rf::Direction new_direction) {
@ -112,7 +109,6 @@ void set_direction(const rf::Direction new_direction) {
rf_path.set_direction(direction);
baseband_codec.set_mode((direction == rf::Direction::Transmit) ? max5864::Mode::Transmit : max5864::Mode::Receive);
baseband_sgpio.configure((direction == rf::Direction::Transmit) ? baseband::Direction::Transmit : baseband::Direction::Receive);
}
bool set_tuning_frequency(const rf::Frequency frequency) {
@ -156,16 +152,7 @@ void set_baseband_decimation_by(const size_t n) {
baseband_cpld.set_decimation_by(n);
}
void streaming_enable() {
baseband_sgpio.streaming_enable();
}
void streaming_disable() {
baseband_sgpio.streaming_disable();
}
void disable() {
baseband_sgpio.streaming_disable();
baseband_codec.set_mode(max5864::Mode::Shutdown);
second_if.set_mode(max2837::Mode::Standby);
first_if.disable();

View File

@ -43,8 +43,6 @@ void set_sampling_frequency(const uint32_t frequency);
void set_baseband_filter_bandwidth(const uint32_t bandwidth_minimum);
void set_baseband_decimation_by(const size_t n);
void streaming_enable();
void streaming_disable();
void disable();
extern rffc507x::RFFC507x first_if;

View File

@ -118,7 +118,6 @@ void ReceiverModel::enable() {
update_vga();
update_baseband_bandwidth();
update_baseband_configuration();
radio::streaming_enable();
update_headphone_volume();
}
@ -168,7 +167,6 @@ void ReceiverModel::set_baseband_configuration(const BasebandConfiguration confi
}
void ReceiverModel::update_baseband_configuration() {
radio::streaming_disable();
clock_manager.set_sampling_frequency(sampling_rate() * baseband_oversampling());
update_tuning_frequency();
@ -176,8 +174,6 @@ void ReceiverModel::update_baseband_configuration() {
BasebandConfigurationMessage message { baseband_configuration };
shared_memory.baseband_queue.push(message);
radio::streaming_enable();
}
void ReceiverModel::update_headphone_volume() {

View File

@ -127,6 +127,7 @@ CPPSRC = main.cpp \
event.cpp \
gpdma.cpp \
baseband_dma.cpp \
baseband_sgpio.cpp \
portapack_shared_memory.cpp \
baseband_thread.cpp \
baseband_processor.cpp \

View File

@ -25,6 +25,7 @@
#include "baseband.hpp"
#include "baseband_stats_collector.hpp"
#include "baseband_sgpio.hpp"
#include "baseband_dma.hpp"
#include "rssi.hpp"
@ -42,6 +43,8 @@
#include <array>
static baseband::SGPIO baseband_sgpio;
WORKING_AREA(baseband_thread_wa, 4096);
Thread* BasebandThread::start(const tprio_t priority) {
@ -79,6 +82,7 @@ void BasebandThread::on_message(const Message* const message) {
}
void BasebandThread::run() {
baseband_sgpio.init();
baseband::dma::init();
const auto baseband_buffer = new std::array<baseband::sample_t, 8192>();
@ -136,6 +140,7 @@ void BasebandThread::disable() {
if( baseband_processor ) {
i2s::i2s0::tx_mute();
baseband::dma::disable();
baseband_sgpio.streaming_disable();
rf::rssi::stop();
}
}
@ -145,6 +150,8 @@ void BasebandThread::enable() {
if( direction() == baseband::Direction::Receive ) {
rf::rssi::start();
}
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.streaming_enable();
}
}