Skip to content

Commit 09cf701

Browse files
committed
MCU8MASS-1721 Configure the modem's wake up sources for both power down and power save mode
1 parent ba40f59 commit 09cf701

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

src/low_power.cpp

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -643,32 +643,12 @@ static void disableLDO(void) {
643643
delay(100);
644644
}
645645

646-
void LowPowerClass::configurePowerDown(void) {
647-
648-
// We need sequans controller to be initialized first before configuration.
649-
// This is because we need to disable the PSM mode so that the modem don't
650-
// do periodic power save, but we can shut it down completely.
651-
if (!SequansController.isInitialized()) {
652-
SequansController.begin();
653-
}
654-
655-
// Disable EDRX and PSM
656-
SequansController.writeCommand(AT_COMMAND_DISABLE_EDRX);
657-
SequansController.writeCommand(AT_COMMAND_DISABLE_PSM);
658-
}
659-
660-
void LowPowerClass::configurePeriodicPowerSave(
661-
const PowerSaveModePeriodMultiplier power_save_mode_period_multiplier,
662-
const uint8_t power_save_mode_period_value) {
663-
664-
// Reset in case there is a reconfiguration after sleep has been called
665-
// previously
666-
retrieved_period = false;
667-
668-
// We need sequans controller to be initialized first before configuration
669-
if (!SequansController.isInitialized()) {
670-
SequansController.begin();
671-
}
646+
/**
647+
* @brief Configures the Sequans modem for deep sleep by entering manufacturing
648+
* mode and disabling wake up sources which the low power module does not use.
649+
* If this is not done, the modem won't go to deep sleep.
650+
*/
651+
static void configureModemForDeepSleep(void) {
672652

673653
// First we need to enter manufactoring mode to disable wake up sources
674654
SequansController.writeCommand(AT_COMMAND_ENTER_MANUFACTURING_MODE);
@@ -696,6 +676,38 @@ void LowPowerClass::configurePeriodicPowerSave(
696676
// Set device to sleep when RTS0 is pulled high. By default the modem will
697677
// sleep if RTS0, RTS1 and RTS2 are pulled high, so we want to change that
698678
SequansController.writeCommand(AT_COMMAND_SET_RTS0_HIGH_TRIGGERS_SLEEP);
679+
}
680+
681+
void LowPowerClass::configurePowerDown(void) {
682+
683+
// We need sequans controller to be initialized first before configuration.
684+
// This is because we need to disable the PSM mode so that the modem don't
685+
// do periodic power save, but we can shut it down completely.
686+
if (!SequansController.isInitialized()) {
687+
SequansController.begin();
688+
}
689+
690+
configureModemForDeepSleep();
691+
692+
// Disable EDRX and PSM
693+
SequansController.writeCommand(AT_COMMAND_DISABLE_EDRX);
694+
SequansController.writeCommand(AT_COMMAND_DISABLE_PSM);
695+
}
696+
697+
void LowPowerClass::configurePeriodicPowerSave(
698+
const PowerSaveModePeriodMultiplier power_save_mode_period_multiplier,
699+
const uint8_t power_save_mode_period_value) {
700+
701+
// Reset in case there is a reconfiguration after sleep has been called
702+
// previously
703+
retrieved_period = false;
704+
705+
// We need sequans controller to be initialized first before configuration
706+
if (!SequansController.isInitialized()) {
707+
SequansController.begin();
708+
}
709+
710+
configureModemForDeepSleep();
699711

700712
// Disable EDRX as we use PSM
701713
SequansController.writeCommand(AT_COMMAND_DISABLE_EDRX);

0 commit comments

Comments
 (0)