Don't update radio directly when saving/restoring tx/rx model settings. (#1160)

* Set rf direction in RadioState

* centralize cpld load for TX->RX

* Remove calls to load_sram from all apps

* re-add CPLD hack, don't set radio values directly.

---------

Co-authored-by: kallanreed <kallanreed@noreply.github.com>
This commit is contained in:
Kyle Reed 2023-06-17 07:54:52 -07:00 committed by GitHub
parent 3a5c2da66c
commit 650d299c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 114 additions and 137 deletions

View File

@ -94,8 +94,6 @@ constexpr std::string_view volume = "volume="sv;
// TODO: Maybe just use a dictionary which would allow for custom settings. // TODO: Maybe just use a dictionary which would allow for custom settings.
// TODO: Create a control value binding which will allow controls to // TODO: Create a control value binding which will allow controls to
// be declaratively bound to a setting and persistence will be magic. // be declaratively bound to a setting and persistence will be magic.
// TODO: radio settings should be pushed and popped to prevent cross-app
// radio bugs caused by sharing a global model.
ResultCode load_settings(const std::string& app_name, AppSettings& settings) { ResultCode load_settings(const std::string& app_name, AppSettings& settings) {
if (!portapack::persistent_memory::load_app_settings()) if (!portapack::persistent_memory::load_app_settings())
@ -178,17 +176,17 @@ void copy_to_radio_model(const AppSettings& settings) {
if (flags_enabled(settings.mode, Mode::TX)) { if (flags_enabled(settings.mode, Mode::TX)) {
if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency)) if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency))
transmitter_model.set_target_frequency(settings.tx_frequency); persistent_memory::set_target_frequency(settings.tx_frequency);
transmitter_model.configure_from_app_settings(settings); transmitter_model.configure_from_app_settings(settings);
} }
if (flags_enabled(settings.mode, Mode::RX)) { if (flags_enabled(settings.mode, Mode::RX)) {
if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency)) if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency))
transmitter_model.set_target_frequency(settings.rx_frequency); persistent_memory::set_target_frequency(settings.rx_frequency);
receiver_model.configure_from_app_settings(settings); receiver_model.configure_from_app_settings(settings);
receiver_model.set_configuration_without_init( receiver_model.set_configuration_without_update(
static_cast<ReceiverModel::Mode>(settings.modulation), static_cast<ReceiverModel::Mode>(settings.modulation),
settings.step, settings.step,
settings.am_config_index, settings.am_config_index,

View File

@ -21,10 +21,9 @@
*/ */
#include "capture_app.hpp" #include "capture_app.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack.hpp" #include "portapack.hpp"
using namespace portapack; using namespace portapack;
namespace ui { namespace ui {
@ -49,13 +48,12 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
field_frequency.set_value(receiver_model.target_frequency()); field_frequency.set_value(receiver_model.target_frequency());
field_frequency.set_step(receiver_model.frequency_step()); field_frequency.set_step(receiver_model.frequency_step());
field_frequency.on_change = [this](rf::Frequency f) { field_frequency.on_change = [this](rf::Frequency f) {
this->on_target_frequency_changed(f); receiver_model.set_target_frequency(f);
}; };
field_frequency.on_edit = [this, &nav]() { field_frequency.on_edit = [this, &nav]() {
// TODO: Provide separate modal method/scheme? // TODO: Provide separate modal method/scheme?
auto new_view = nav.push<FrequencyKeypadView>(receiver_model.target_frequency()); auto new_view = nav.push<FrequencyKeypadView>(receiver_model.target_frequency());
new_view->on_changed = [this](rf::Frequency f) { new_view->on_changed = [this](rf::Frequency f) {
this->on_target_frequency_changed(f);
this->field_frequency.set_value(f); this->field_frequency.set_value(f);
}; };
}; };
@ -71,12 +69,9 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
/* base_rate is used for FFT calculation and display LCD, and also in recording writing SD Card rate. */ /* base_rate is used for FFT calculation and display LCD, and also in recording writing SD Card rate. */
/* ex. sampling_rate values, 4Mhz, when recording 500 kHz (BW) and fs 8 Mhz, when selected 1 Mhz BW ... */ /* ex. sampling_rate values, 4Mhz, when recording 500 kHz (BW) and fs 8 Mhz, when selected 1 Mhz BW ... */
/* ex. recording 500kHz BW to .C16 file, base_rate clock 500kHz x2(I,Q) x 2 bytes (int signed) =2MB/sec rate SD Card */ /* ex. recording 500kHz BW to .C16 file, base_rate clock 500kHz x2(I,Q) x 2 bytes (int signed) =2MB/sec rate SD Card */
waterfall.on_hide(); waterfall.on_hide();
record_view.set_sampling_rate(sampling_rate);
receiver_model.set_sampling_rate(sampling_rate);
/* Set up proper anti aliasing BPF bandwith in MAX2837 before ADC sampling according to the new added BW Options . */
/* Set up proper anti aliasing BPF bandwith in MAX2837 before ADC sampling according to the new added BW Options . */
switch (sampling_rate) { // we use the var fs (sampling_rate) , to set up BPF aprox < fs_max/2 by Nyquist theorem. switch (sampling_rate) { // we use the var fs (sampling_rate) , to set up BPF aprox < fs_max/2 by Nyquist theorem.
case 0 ... 2000000: // BW Captured range (0 <= 250kHz max ) fs = 8 x 250 kHz case 0 ... 2000000: // BW Captured range (0 <= 250kHz max ) fs = 8 x 250 kHz
@ -111,12 +106,15 @@ CaptureAppView::CaptureAppView(NavigationView& nav) {
// We tested also 9Mhz FPB stightly too much noise floor, better 8Mhz // We tested also 9Mhz FPB stightly too much noise floor, better 8Mhz
anti_alias_baseband_bandwidth_filter = 8000000; anti_alias_baseband_bandwidth_filter = 8000000;
} }
record_view.set_sampling_rate(sampling_rate);
receiver_model.set_sampling_rate(sampling_rate);
receiver_model.set_baseband_bandwidth(anti_alias_baseband_bandwidth_filter); receiver_model.set_baseband_bandwidth(anti_alias_baseband_bandwidth_filter);
waterfall.on_show(); waterfall.on_show();
}; };
option_bandwidth.set_selected_index(7); // 500k, Preselected starting default option 500kHz option_bandwidth.set_selected_index(7); // Preselected default option 500kHz.
receiver_model.set_modulation(ReceiverModel::Mode::Capture); receiver_model.set_modulation(ReceiverModel::Mode::Capture);
receiver_model.enable(); receiver_model.enable();
@ -132,8 +130,6 @@ CaptureAppView::~CaptureAppView() {
} }
void CaptureAppView::on_hide() { void CaptureAppView::on_hide() {
// TODO: Terrible kludge because widget system doesn't notify Waterfall that
// it's being shown or hidden.
waterfall.on_hide(); waterfall.on_hide();
View::on_hide(); View::on_hide();
} }
@ -141,7 +137,7 @@ void CaptureAppView::on_hide() {
void CaptureAppView::set_parent_rect(const Rect new_parent_rect) { void CaptureAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect); View::set_parent_rect(new_parent_rect);
const ui::Rect waterfall_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height}; ui::Rect waterfall_rect{0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height};
waterfall.set_parent_rect(waterfall_rect); waterfall.set_parent_rect(waterfall_rect);
} }
@ -149,8 +145,4 @@ void CaptureAppView::focus() {
record_view.focus(); record_view.focus();
} }
void CaptureAppView::on_target_frequency_changed(rf::Frequency f) {
receiver_model.set_target_frequency(f);
}
} /* namespace ui */ } /* namespace ui */

View File

@ -28,6 +28,7 @@
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "ui_record_view.hpp" #include "ui_record_view.hpp"
#include "ui_spectrum.hpp" #include "ui_spectrum.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp" #include "radio_state.hpp"
#define BW_OPTIONS \ #define BW_OPTIONS \
@ -40,7 +41,7 @@
{" 250k", 250000}, \ {" 250k", 250000}, \
{" 500k", 500000}, /* Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.*/ \ {" 500k", 500000}, /* Previous Limit bandwith Option with perfect micro SD write .C16 format operaton.*/ \
{" 600k", 600000}, /* That extended option is still possible to record with FW version Mayhem v1.41 (< 2,5MB/sec) */ \ {" 600k", 600000}, /* That extended option is still possible to record with FW version Mayhem v1.41 (< 2,5MB/sec) */ \
{" 750k", 750000}, /* From that BW onwards, the LCD is ok, but the recorded file is auto decimated,(not real file size) */ \ {" 750k", 750000}, /* From this BW onwards, the LCD is ok, but the recorded file is decimated, (not real file size) */ \
{"1100k", 1100000}, \ {"1100k", 1100000}, \
{"1750k", 1750000}, \ {"1750k", 1750000}, \
{"2000k", 2000000}, \ {"2000k", 2000000}, \
@ -55,10 +56,8 @@ class CaptureAppView : public View {
~CaptureAppView(); ~CaptureAppView();
void on_hide() override; void on_hide() override;
void set_parent_rect(const Rect new_parent_rect) override;
void focus() override; void focus() override;
void set_parent_rect(const Rect new_parent_rect) override;
std::string title() const override { return "Capture"; }; std::string title() const override { return "Capture"; };
@ -66,9 +65,12 @@ class CaptureAppView : public View {
static constexpr ui::Dim header_height = 3 * 16; static constexpr ui::Dim header_height = 3 * 16;
RxRadioState radio_state_{}; RxRadioState radio_state_{};
app_settings::SettingsManager settings_{
"rx_capture", app_settings::Mode::RX,
app_settings::Options::UseGlobalTargetFrequency};
uint32_t sampling_rate = 0; uint32_t sampling_rate = 0;
uint32_t anti_alias_baseband_bandwidth_filter = 2500000; // we rename the previous var , and change type static constexpr to normal var. uint32_t anti_alias_baseband_bandwidth_filter = 2500000;
void on_target_frequency_changed(rf::Frequency f); void on_target_frequency_changed(rf::Frequency f);

View File

@ -29,7 +29,6 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "cpld_update.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
using namespace portapack; using namespace portapack;
@ -214,8 +213,7 @@ GpsSimAppView::GpsSimAppView(
GpsSimAppView::~GpsSimAppView() { GpsSimAppView::~GpsSimAppView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void GpsSimAppView::on_hide() { void GpsSimAppView::on_hide() {

View File

@ -27,7 +27,6 @@
#include "lge_app.hpp" #include "lge_app.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "ui_textentry.hpp" #include "ui_textentry.hpp"
#include "string_format.hpp" #include "string_format.hpp"
@ -45,8 +44,7 @@ void LGEView::focus() {
LGEView::~LGEView() { LGEView::~LGEView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void LGEView::generate_lge_frame(const uint8_t command, const uint16_t address_a, const uint16_t address_b, std::vector<uint8_t>& data) { void LGEView::generate_lge_frame(const uint8_t command, const uint16_t address_a, const uint16_t address_b, std::vector<uint8_t>& data) {

View File

@ -26,7 +26,6 @@
#include "ui_fileman.hpp" #include "ui_fileman.hpp"
#include "io_file.hpp" #include "io_file.hpp"
#include "cpld_update.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
@ -226,9 +225,7 @@ ReplayAppView::~ReplayAppView() {
display.fill_rectangle({0, 0, 240, 320}, Color::black()); // Solving sometimes visible bottom waterfall artifacts, clearing all LCD pixels. display.fill_rectangle({0, 0, 240, 320}, Color::black()); // Solving sometimes visible bottom waterfall artifacts, clearing all LCD pixels.
chThdSleepMilliseconds(40); // (that happened sometimes if we interrupt the waterfall play at the beggining of the play around 25% and exit ) chThdSleepMilliseconds(40); // (that happened sometimes if we interrupt the waterfall play at the beggining of the play around 25% and exit )
hackrf::cpld::load_sram_no_verify(); // to leave all RX reception ok, without "ghost interference signal problem" at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, after load_sram(). If not , sometimes produced hang up (now not , it is ok).
} }
void ReplayAppView::on_hide() { void ReplayAppView::on_hide() {

View File

@ -25,7 +25,6 @@
#include "soundboard_app.hpp" #include "soundboard_app.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "tonesets.hpp" #include "tonesets.hpp"
#include "cpld_update.hpp"
using namespace tonekey; using namespace tonekey;
using namespace portapack; using namespace portapack;
@ -275,8 +274,7 @@ SoundBoardView::SoundBoardView(
SoundBoardView::~SoundBoardView() { SoundBoardView::~SoundBoardView() {
stop(); stop();
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
} // namespace ui } // namespace ui

View File

@ -26,7 +26,6 @@
#include "manchester.hpp" #include "manchester.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "cpld_update.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include <cstring> #include <cstring>
@ -274,8 +273,7 @@ void ADSBTxView::focus() {
ADSBTxView::~ADSBTxView() { ADSBTxView::~ADSBTxView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, withouth ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void ADSBTxView::generate_frames() { void ADSBTxView::generate_frames() {

View File

@ -26,7 +26,6 @@
#include "aprs.hpp" #include "aprs.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "portapack.hpp" #include "portapack.hpp"
#include "cpld_update.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
@ -45,8 +44,7 @@ void APRSTXView::focus() {
APRSTXView::~APRSTXView() { APRSTXView::~APRSTXView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void APRSTXView::start_tx() { void APRSTXView::start_tx() {

View File

@ -24,7 +24,6 @@
#include "string_format.hpp" #include "string_format.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
using namespace portapack; using namespace portapack;
@ -138,8 +137,7 @@ void BHTView::on_tx_progress(const uint32_t progress, const bool done) {
BHTView::~BHTView() { BHTView::~BHTView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
BHTView::BHTView(NavigationView& nav) { BHTView::BHTView(NavigationView& nav) {

View File

@ -23,7 +23,6 @@
#include "ui_coasterp.hpp" #include "ui_coasterp.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "portapack_persistent_memory.hpp" #include "portapack_persistent_memory.hpp"
#include <cstring> #include <cstring>
@ -39,8 +38,7 @@ void CoasterPagerView::focus() {
CoasterPagerView::~CoasterPagerView() { CoasterPagerView::~CoasterPagerView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void CoasterPagerView::generate_frame() { void CoasterPagerView::generate_frame() {

View File

@ -24,7 +24,6 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "cpld_update.hpp"
using namespace portapack; using namespace portapack;
@ -201,8 +200,7 @@ void EncodersView::focus() {
EncodersView::~EncodersView() { EncodersView::~EncodersView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // ghost signal c/m to the problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function after load_sram()
} }
void EncodersView::update_progress() { void EncodersView::update_progress() {

View File

@ -25,7 +25,6 @@
#include "ui_freqman.hpp" #include "ui_freqman.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "string_format.hpp" #include "string_format.hpp"
using namespace portapack; using namespace portapack;
@ -180,8 +179,7 @@ void JammerView::focus() {
JammerView::~JammerView() { JammerView::~JammerView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void JammerView::on_retune(const rf::Frequency freq, const uint32_t range) { void JammerView::on_retune(const rf::Frequency freq, const uint32_t range) {

View File

@ -23,7 +23,6 @@
#include "ui_keyfob.hpp" #include "ui_keyfob.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "string_format.hpp" #include "string_format.hpp"
using namespace portapack; using namespace portapack;
@ -141,8 +140,7 @@ KeyfobView::~KeyfobView() {
settings.save("tx_keyfob", &app_settings); settings.save("tx_keyfob", &app_settings);
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void KeyfobView::update_progress(const uint32_t progress) { void KeyfobView::update_progress(const uint32_t progress) {

View File

@ -26,7 +26,6 @@
#include "lcr.hpp" #include "lcr.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "cpld_update.hpp"
#include "serializer.hpp" #include "serializer.hpp"
@ -40,8 +39,7 @@ void LCRView::focus() {
LCRView::~LCRView() { LCRView::~LCRView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
/* /*

View File

@ -30,7 +30,6 @@ using wolfson::wm8731::WM8731;
#include "tonesets.hpp" #include "tonesets.hpp"
#include "portapack_hal.hpp" #include "portapack_hal.hpp"
#include "cpld_update.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "irq_controls.hpp" #include "irq_controls.hpp"
@ -172,7 +171,6 @@ void MicTXView::rxaudio(bool is_on) {
receiver_model.set_vga(rx_vga); receiver_model.set_vga(rx_vga);
receiver_model.set_rf_amp(rx_amp); receiver_model.set_rf_amp(rx_amp);
receiver_model.enable(); receiver_model.enable();
hackrf::cpld::load_sram_no_verify(); // to have a good RX without any ghost inside Mic App
audio::output::start(); audio::output::start();
} else { // These incredibly convoluted steps are required for the vumeter to reappear when stopping RX. } else { // These incredibly convoluted steps are required for the vumeter to reappear when stopping RX.
receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio); // This fixes something with AM RX... receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio); // This fixes something with AM RX...
@ -609,8 +607,7 @@ MicTXView::~MicTXView() {
transmitter_model.disable(); transmitter_model.disable();
if (rx_enabled) // Also turn off audio rx if enabled if (rx_enabled) // Also turn off audio rx if enabled
rxaudio(false); rxaudio(false);
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
} // namespace ui } // namespace ui

View File

@ -26,7 +26,6 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "hackrf_gpio.hpp" #include "hackrf_gpio.hpp"
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include "cpld_update.hpp"
#include "ui_textentry.hpp" #include "ui_textentry.hpp"
#include "string_format.hpp" #include "string_format.hpp"
@ -99,8 +98,7 @@ void MorseView::focus() {
MorseView::~MorseView() { MorseView::~MorseView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void MorseView::paint(Painter&) { void MorseView::paint(Painter&) {

View File

@ -23,7 +23,6 @@
#include "ui_pocsag_tx.hpp" #include "ui_pocsag_tx.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "ui_textentry.hpp" #include "ui_textentry.hpp"
@ -40,8 +39,7 @@ void POCSAGTXView::focus() {
POCSAGTXView::~POCSAGTXView() { POCSAGTXView::~POCSAGTXView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void POCSAGTXView::on_tx_progress(const uint32_t progress, const bool done) { void POCSAGTXView::on_tx_progress(const uint32_t progress, const bool done) {

View File

@ -24,7 +24,6 @@
#include "portapack.hpp" #include "portapack.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "cpld_update.hpp"
#include "portapack_shared_memory.hpp" #include "portapack_shared_memory.hpp"
#include <cstring> #include <cstring>
@ -161,8 +160,7 @@ void RDSView::focus() {
RDSView::~RDSView() { RDSView::~RDSView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void RDSView::start_tx() { void RDSView::start_tx() {

View File

@ -20,7 +20,6 @@
*/ */
#include "ui_spectrum_painter.hpp" #include "ui_spectrum_painter.hpp"
#include "cpld_update.hpp"
#include "bmp.hpp" #include "bmp.hpp"
#include "baseband_api.hpp" #include "baseband_api.hpp"
@ -176,7 +175,6 @@ void SpectrumPainterView::frame_sync() {
SpectrumPainterView::~SpectrumPainterView() { SpectrumPainterView::~SpectrumPainterView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify();
baseband::shutdown(); baseband::shutdown();
} }

View File

@ -25,7 +25,6 @@
#include "portapack.hpp" #include "portapack.hpp"
#include "hackrf_hal.hpp" #include "hackrf_hal.hpp"
#include "cpld_update.hpp"
#include <cstring> #include <cstring>
#include <stdio.h> #include <stdio.h>
@ -89,8 +88,7 @@ void SSTVTXView::paint(Painter&) {
SSTVTXView::~SSTVTXView() { SSTVTXView::~SSTVTXView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void SSTVTXView::prepare_scanline() { void SSTVTXView::prepare_scanline() {

View File

@ -26,7 +26,6 @@
#include "baseband_api.hpp" #include "baseband_api.hpp"
#include "string_format.hpp" #include "string_format.hpp"
#include "cpld_update.hpp"
using namespace portapack; using namespace portapack;
using namespace encoders; using namespace encoders;
@ -39,8 +38,7 @@ void TouchTunesView::focus() {
TouchTunesView::~TouchTunesView() { TouchTunesView::~TouchTunesView() {
transmitter_model.disable(); transmitter_model.disable();
hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. baseband::shutdown();
baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up.
} }
void TouchTunesView::stop_tx() { void TouchTunesView::stop_tx() {

View File

@ -92,7 +92,8 @@ max2839::MAX2839 second_if_max2839{ssp1_target_max283x};
static max5864::MAX5864 baseband_codec{ssp1_target_max5864}; static max5864::MAX5864 baseband_codec{ssp1_target_max5864};
static baseband::CPLD baseband_cpld; static baseband::CPLD baseband_cpld;
static rf::Direction direction{rf::Direction::Receive}; // Set invalid to force the set_direction CPLD workaround to run.
static rf::Direction direction{-1};
static bool baseband_invert = false; static bool baseband_invert = false;
static bool mixer_invert = false; static bool mixer_invert = false;
@ -115,15 +116,15 @@ void set_direction(const rf::Direction new_direction) {
/* TODO: Refactor all the various "Direction" enumerations into one. */ /* TODO: Refactor all the various "Direction" enumerations into one. */
/* TODO: Only make changes if direction changes, but beware of clock enabling. */ /* TODO: Only make changes if direction changes, but beware of clock enabling. */
// Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction // Hack to fix the CPLD (clocking ?) bug: toggle CPLD SRAM overlay depending on new direction.
// Use CPLD's EEPROM config when transmitting // Use CPLD's EEPROM config when transmitting
// Use the SRAM overlay when receiving // Use the SRAM overlay when receiving
if (direction != new_direction) {
// teixeluis: undone "Hack to fix the CPLD (clocking ?) bug". if (new_direction == rf::Direction::Transmit)
// Apparently with current CPLD code from the hackrf repo,
// toggling CPLD overlay should no longer be necessary:
if (direction != new_direction && new_direction == rf::Direction::Transmit) {
hackrf::cpld::init_from_eeprom(); hackrf::cpld::init_from_eeprom();
else
// Prevents ghosting when switching back to RX from TX mode.
hackrf::cpld::load_sram_no_verify();
} }
direction = new_direction; direction = new_direction;

View File

@ -41,13 +41,13 @@ class RadioState {
RadioState(uint32_t new_bandwidth, uint32_t new_sampling_rate) RadioState(uint32_t new_bandwidth, uint32_t new_sampling_rate)
: prev_bandwidth_{model->baseband_bandwidth()}, : prev_bandwidth_{model->baseband_bandwidth()},
prev_sampling_rate_{model->sampling_rate()} { prev_sampling_rate_{model->sampling_rate()} {
model->set_baseband_bandwidth(new_bandwidth); model->set_configuration_without_update(
model->set_sampling_rate(new_sampling_rate); new_bandwidth, new_sampling_rate);
} }
~RadioState() { ~RadioState() {
model->set_baseband_bandwidth(prev_bandwidth_); model->set_configuration_without_update(
model->set_sampling_rate(prev_sampling_rate_); prev_bandwidth_, prev_sampling_rate_);
} }
private: private:

View File

@ -248,12 +248,19 @@ void ReceiverModel::set_wfm_configuration(const size_t n) {
} }
} }
void ReceiverModel::set_configuration_without_init( void ReceiverModel::set_configuration_without_update(
const Mode new_mode, uint32_t baseband_bandwidth,
const rf::Frequency new_frequency_step, uint32_t sampling_rate) {
const size_t new_am_config_index, baseband_bandwidth_ = baseband_bandwidth;
const size_t new_nbfm_config_index, sampling_rate_ = sampling_rate;
const size_t new_wfm_config_index, }
void ReceiverModel::set_configuration_without_update(
Mode new_mode,
rf::Frequency new_frequency_step,
size_t new_am_config_index,
size_t new_nbfm_config_index,
size_t new_wfm_config_index,
uint8_t new_squelch_level) { uint8_t new_squelch_level) {
mode_ = new_mode; mode_ = new_mode;
frequency_step_ = new_frequency_step; frequency_step_ = new_frequency_step;

View File

@ -92,12 +92,17 @@ class ReceiverModel {
size_t wfm_configuration() const; size_t wfm_configuration() const;
void set_wfm_configuration(const size_t n); void set_wfm_configuration(const size_t n);
void set_configuration_without_init( /* Sets the model values without updating the radio. */
const Mode new_mode, void set_configuration_without_update(
const rf::Frequency new_frequency_step, uint32_t baseband_bandwidth,
const size_t new_am_config_index, uint32_t sampling_rate);
const size_t new_nbfm_config_index,
const size_t new_wfm_config_index, void set_configuration_without_update(
Mode new_mode,
rf::Frequency new_frequency_step,
size_t new_am_config_index,
size_t new_nbfm_config_index,
size_t new_wfm_config_index,
uint8_t new_squelch_level); uint8_t new_squelch_level);
void configure_from_app_settings(const app_settings::AppSettings& settings); void configure_from_app_settings(const app_settings::AppSettings& settings);

View File

@ -147,6 +147,13 @@ void TransmitterModel::disable() {
led_tx.off(); led_tx.off();
} }
void TransmitterModel::set_configuration_without_update(
uint32_t baseband_bandwidth,
uint32_t sampling_rate) {
baseband_bandwidth_ = baseband_bandwidth;
sampling_rate_ = sampling_rate;
}
void TransmitterModel::configure_from_app_settings( void TransmitterModel::configure_from_app_settings(
const app_settings::AppSettings& settings) { const app_settings::AppSettings& settings) {
baseband_bandwidth_ = settings.baseband_bandwidth; baseband_bandwidth_ = settings.baseband_bandwidth;

View File

@ -70,6 +70,11 @@ class TransmitterModel {
void enable(); void enable();
void disable(); void disable();
/* Sets the model values without updating the radio. */
void set_configuration_without_update(
uint32_t baseband_bandwidth,
uint32_t sampling_rate);
void configure_from_app_settings(const app_settings::AppSettings& settings); void configure_from_app_settings(const app_settings::AppSettings& settings);
private: private:

View File

@ -113,8 +113,8 @@ bool load_sram() {
} }
void load_sram_no_verify() { void load_sram_no_verify() {
// CoolRunner II family has Hybrid memory CPLD arquitecture (SRAM+NVM) // CoolRunner II family has Hybrid memory CPLD architecture (SRAM+NVM)
// It seems that after using TX App somehow , I do not why , the CPLD_SRAM part needs to be re_loaded to solve #637 ghost beat // It seems that after using a TX App the CPLD_SRAM part needs to be re_loaded to solve #637 ghost beat.
// load_sram() it is already called at each boot in portapack.cpp, including verify CPLD part. // load_sram() it is already called at each boot in portapack.cpp, including verify CPLD part.
// Here we skipped CPLD verify part, just to be quicker (in case any CPLD problem it will be detected in the boot process). // Here we skipped CPLD verify part, just to be quicker (in case any CPLD problem it will be detected in the boot process).

View File

@ -44,7 +44,7 @@ namespace hackrf {
namespace cpld { namespace cpld {
bool load_sram(); bool load_sram();
void load_sram_no_verify(); // added to solve issue #637 , "ghost" signal at RX , after using any TX App void load_sram_no_verify(); // Added to solve issue #637, "ghost" signal at RX, after using any TX App.
bool verify_eeprom(); bool verify_eeprom();
void init_from_eeprom(); void init_from_eeprom();