From 0cda4a8744329628ea28b616454ee9ce3ecfc754 Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Fri, 22 Jan 2021 01:04:33 +0100 Subject: [PATCH] disable ontime counters in survive mode --- src/eez/firmware.cpp | 7 ++++++- src/eez/modules/psu/psu.cpp | 6 ++++++ src/eez/tasks.cpp | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/eez/firmware.cpp b/src/eez/firmware.cpp index 2590f000f..c46287a4c 100644 --- a/src/eez/firmware.cpp +++ b/src/eez/firmware.cpp @@ -130,7 +130,9 @@ void boot() { bp3c::io_exp::init(); +#if !CONF_SURVIVE_MODE psu::ontime::g_mcuCounter.init(); +#endif psu::persist_conf::init(); @@ -175,8 +177,9 @@ void boot() { if (g_slots[slotIndex]->moduleType != MODULE_TYPE_NONE) { g_slots[slotIndex]->enabled = psu::persist_conf::isSlotEnabled(slotIndex); psu::persist_conf::loadModuleConf(slotIndex); +#if !CONF_SURVIVE_MODE psu::ontime::g_moduleCounters[slotIndex].init(); - +#endif numInstalledModules++; } @@ -446,6 +449,7 @@ void shutdown() { event_queue::shutdownSave(); +#if !CONF_SURVIVE_MODE // save on-time counters persist_conf::writeTotalOnTime(ontime::g_mcuCounter.getType(), ontime::g_mcuCounter.getTotalTime()); for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { @@ -454,6 +458,7 @@ void shutdown() { } WATCHDOG_RESET(WATCHDOG_LONG_OPERATION); } +#endif // for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { diff --git a/src/eez/modules/psu/psu.cpp b/src/eez/modules/psu/psu.cpp index 0b1f89d9c..868dca1a2 100644 --- a/src/eez/modules/psu/psu.cpp +++ b/src/eez/modules/psu/psu.cpp @@ -1013,12 +1013,14 @@ bool powerUp() { psuReset(); +#if !CONF_SURVIVE_MODE ontime::g_mcuCounter.start(); for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { if (g_slots[slotIndex]->moduleType != MODULE_TYPE_NONE) { ontime::g_moduleCounters[slotIndex].start(); } } +#endif // init channels initChannels(); @@ -1069,11 +1071,13 @@ void powerDownOnlyPowerChannels() { board::powerDown(); +#if !CONF_SURVIVE_MODE for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { if (g_slots[slotIndex]->moduleType != MODULE_TYPE_NONE && g_slots[slotIndex]->numPowerChannels > 0) { ontime::g_moduleCounters[slotIndex].stop(); } } +#endif } void powerDown() { @@ -1109,12 +1113,14 @@ void powerDown() { g_powerIsUp = false; +#if !CONF_SURVIVE_MODE ontime::g_mcuCounter.stop(); for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { if (g_slots[slotIndex]->moduleType != MODULE_TYPE_NONE) { ontime::g_moduleCounters[slotIndex].stop(); } } +#endif event_queue::pushEvent(event_queue::EVENT_INFO_POWER_DOWN); diff --git a/src/eez/tasks.cpp b/src/eez/tasks.cpp index 372232c82..0d8db09e6 100644 --- a/src/eez/tasks.cpp +++ b/src/eez/tasks.cpp @@ -461,12 +461,14 @@ void lowPriorityThreadOneIter() { profile::tick(); +#if !CONF_SURVIVE_MODE ontime::g_mcuCounter.tick(); for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) { if (g_slots[slotIndex]->moduleType != MODULE_TYPE_NONE) { ontime::g_moduleCounters[slotIndex].tick(); } } +#endif mcu::battery::tick(); }