Skip to content

Commit

Permalink
disable ontime counters in survive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 22, 2021
1 parent 0de6fe4 commit 0cda4a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/eez/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ void boot() {

bp3c::io_exp::init();

#if !CONF_SURVIVE_MODE
psu::ontime::g_mcuCounter.init();
#endif

psu::persist_conf::init();

Expand Down Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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++) {
Expand All @@ -454,6 +458,7 @@ void shutdown() {
}
WATCHDOG_RESET(WATCHDOG_LONG_OPERATION);
}
#endif

//
for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) {
Expand Down
6 changes: 6 additions & 0 deletions src/eez/modules/psu/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/eez/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 0cda4a8

Please sign in to comment.