Skip to content

Commit ee0e494

Browse files
committed
Don't sync state of leds when powering down, only when power save
1 parent 5ffc374 commit ee0e494

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/examples/power_down/power_down.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#include <Wire.h>
21
#include <avr/io.h>
32
#include <led_ctrl.h>
43
#include <log.h>
54
#include <low_power.h>
65
#include <lte.h>
7-
#include <sequans_controller.h>
86

97
#define SW0 PIN_PD2
108

119
ISR(PORTD_PORT_vect) {
1210
if (PORTD.INTFLAGS & PIN2_bm) {
11+
// Reset the interupt flag so that we can process the next incoming
12+
// interrupt
1313
PORTD.INTFLAGS = PIN2_bm;
1414
}
1515
}
@@ -44,6 +44,8 @@ void setup() {
4444
void loop() {
4545

4646
Log.info("Powering down...");
47+
// Allow some time for the log message to be transmitted before we power
48+
// down
4749
delay(100);
4850

4951
// Power down for 60 seconds

src/low_power.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ static void disablePIT(void) {
331331
static void powerDownPeripherals(void) {
332332

333333
// LEDs
334-
cell_led_state = digitalRead(LedCtrl.getLedPin(Led::CELL));
335-
con_led_state = digitalRead(LedCtrl.getLedPin(Led::CON));
336-
337334
pinConfigure(LedCtrl.getLedPin(Led::CELL),
338335
PIN_DIR_INPUT | PIN_PULLUP_ON | PIN_INPUT_DISABLE);
339336
pinConfigure(LedCtrl.getLedPin(Led::CON),
@@ -510,6 +507,8 @@ bool LowPowerClass::configurePeriodicPowerSave(
510507
}
511508

512509
void LowPowerClass::powerSave(void) {
510+
cell_led_state = digitalRead(LedCtrl.getLedPin(Led::CELL));
511+
con_led_state = digitalRead(LedCtrl.getLedPin(Led::CON));
513512

514513
powerDownPeripherals();
515514
SLPCTRL.CTRLA |= SLPCTRL_SMODE_PDOWN_gc | SLPCTRL_SEN_bm;
@@ -556,6 +555,9 @@ void LowPowerClass::powerSave(void) {
556555

557556
SLPCTRL.CTRLA &= ~SLPCTRL_SEN_bm;
558557
powerUpPeripherals();
558+
559+
digitalWrite(LedCtrl.getLedPin(Led::CELL), cell_led_state);
560+
digitalWrite(LedCtrl.getLedPin(Led::CON), con_led_state);
559561
}
560562

561563
void LowPowerClass::powerDown(const uint32_t power_down_time_seconds) {

0 commit comments

Comments
 (0)