diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index 74b3b4668..c5b1a279d 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -233,20 +233,23 @@ static PortaPackModel portapack_model() { if (!model.is_valid()) { const auto switches_state = get_switches_state(); - if (switches_state[(size_t)ui::KeyEvent::Up]) { - save_config(1); - // model = PortaPackModel::R2_20170522; // Commented these out as they should be set down below anyway - } else if (switches_state[(size_t)ui::KeyEvent::Down]) { - save_config(2); - // model = PortaPackModel::R1_20150901; - } else if (switches_state[(size_t)ui::KeyEvent::Left]) { - save_config(3); - // model = PortaPackModel::R1_20150901; - } else if (switches_state[(size_t)ui::KeyEvent::Right]) { - save_config(4); - // model = PortaPackModel::R2_20170522; - } else if (switches_state[(size_t)ui::KeyEvent::Select]) { - save_config(0); + // Only save config if no other multi key boot action is triggered (like pmem reset) + if (switches_state.count() == 1) { + if (switches_state[(size_t)ui::KeyEvent::Up]) { + save_config(1); + // model = PortaPackModel::R2_20170522; // Commented these out as they should be set down below anyway + } else if (switches_state[(size_t)ui::KeyEvent::Down]) { + save_config(2); + // model = PortaPackModel::R1_20150901; + } else if (switches_state[(size_t)ui::KeyEvent::Left]) { + save_config(3); + // model = PortaPackModel::R1_20150901; + } else if (switches_state[(size_t)ui::KeyEvent::Right]) { + save_config(4); + // model = PortaPackModel::R2_20170522; + } else if (switches_state[(size_t)ui::KeyEvent::Select]) { + save_config(0); + } } if (load_config() == 1) { @@ -469,13 +472,13 @@ bool init() { i2c0.start(i2c_config_fast_clock); chThdSleepMilliseconds(10); - /* Cache some configuration data from persistent memory. */ - persistent_memory::cache::init(); - touch::adc::init(); controls_init(); chThdSleepMilliseconds(10); + /* Cache some configuration data from persistent memory. */ + persistent_memory::cache::init(); + clock_manager.set_reference_ppb(persistent_memory::correction_ppb()); clock_manager.enable_if_clocks(); clock_manager.enable_codec_clocks(); diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index ca5e5b08b..a48d10f21 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -39,6 +39,8 @@ #include #include "file.hpp" +#include "irq_controls.hpp" + using namespace std; namespace portapack { @@ -445,7 +447,8 @@ void defaults() { } void init() { - if (backup_ram->is_valid()) { + const auto switches_state = get_switches_state(); + if (!(switches_state[(size_t)ui::KeyEvent::Left] && switches_state[(size_t)ui::KeyEvent::Right]) && backup_ram->is_valid()) { // Copy valid persistent data into cache. cached_backup_ram = *backup_ram;