@@ -368,20 +368,30 @@ static void powerDownPeripherals(void) {
368368 PIN_DIR_INPUT | PIN_PULLUP_ON | PIN_INPUT_DISABLE);
369369}
370370
371- static void powerUpPeripherals (void ) {
371+ static void powerUpPeripherals (const bool return_leds_to_previous_state ) {
372372
373- pinConfigure (LedCtrl.getLedPin (Led::CELL), PIN_DIR_OUTPUT);
374- pinConfigure (LedCtrl.getLedPin (Led::CON), PIN_DIR_OUTPUT);
375- pinConfigure (LedCtrl.getLedPin (Led::DATA), PIN_DIR_OUTPUT);
376- pinConfigure (LedCtrl.getLedPin (Led::ERROR), PIN_DIR_OUTPUT);
377- pinConfigure (LedCtrl.getLedPin (Led::USER), PIN_DIR_OUTPUT);
373+ pinConfigure (LedCtrl.getLedPin (Led::CELL),
374+ PIN_DIR_OUTPUT | PIN_INPUT_ENABLE);
375+ pinConfigure (LedCtrl.getLedPin (Led::CON),
376+ PIN_DIR_OUTPUT | PIN_INPUT_ENABLE);
377+ pinConfigure (LedCtrl.getLedPin (Led::DATA),
378+ PIN_DIR_OUTPUT | PIN_INPUT_ENABLE);
379+ pinConfigure (LedCtrl.getLedPin (Led::ERROR),
380+ PIN_DIR_OUTPUT | PIN_INPUT_ENABLE);
381+ pinConfigure (LedCtrl.getLedPin (Led::USER),
382+ PIN_DIR_OUTPUT | PIN_INPUT_ENABLE);
378383
379- if (cell_led_state) {
380- LedCtrl.on (Led::CELL, true );
381- }
384+ if (return_leds_to_previous_state) {
385+ if (cell_led_state) {
386+ LedCtrl.on (Led::CELL, true );
387+ }
382388
383- if (con_led_state) {
384- LedCtrl.on (Led::CON, true );
389+ if (con_led_state) {
390+ LedCtrl.on (Led::CON, true );
391+ }
392+ } else {
393+ LedCtrl.off (Led::CELL, true );
394+ LedCtrl.off (Led::CON, true );
385395 }
386396
387397 // Make sure that I2C pins are pulled up and there won't be a voltage drop
@@ -553,7 +563,7 @@ void LowPowerClass::powerSave(void) {
553563 disableLDO ();
554564
555565 SLPCTRL.CTRLA &= ~SLPCTRL_SEN_bm;
556- powerUpPeripherals ();
566+ powerUpPeripherals (true );
557567
558568 modem_is_in_power_save = false ;
559569 }
@@ -594,9 +604,9 @@ void LowPowerClass::powerDown(const uint32_t power_down_time_seconds) {
594604
595605 disableLDO ();
596606 disablePIT ();
597-
598607 SLPCTRL.CTRLA &= ~SLPCTRL_SEN_bm;
599- powerUpPeripherals ();
608+
609+ powerUpPeripherals (false );
600610
601611 Lte.begin ();
602612}
0 commit comments