Skip to content

Commit

Permalink
Merge pull request #1496 from particle-iot/fix/wkp-pin-after-deep-sleep
Browse files Browse the repository at this point in the history
[Photon/Electron] WKP pin needs to be disabled as a wakeup source on boot to allow its normal operation
  • Loading branch information
technobly committed Mar 20, 2018
2 parents b3d586c + d9e528a commit 55b42f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hal/src/stm32f2xx/core_hal_stm32f2xx.c
Expand Up @@ -333,6 +333,8 @@ void HAL_Core_Config(void)

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE);

/* Disable WKP pin */
PWR_WakeUpPinCmd(DISABLE);

//Wiring pins default to inputs
#if !defined(USE_SWD_JTAG) && !defined(USE_SWD)
Expand Down
16 changes: 16 additions & 0 deletions user/tests/wiring/sleep/sleep.cpp
Expand Up @@ -20,6 +20,22 @@ test(sleep_0_device_wakes_from_deep_sleep_with_short_sleep_time)
magick = 0;
// We should have woken up from deep sleep
assertEqual(System.resetReason(), (int)RESET_REASON_POWER_MANAGEMENT);

/**
* Issue #1447 "WKP/A7 ignores pinMode after waking from deep sleep"
* A7/WKP pin must be jumpered to D7 because
* digitalWrite(A7) will be equal to digitalRead(A7) despite this issue.
*/
Serial.println("SETUP: Make sure to jumper A7/WKP pin to D7 pin.");
pinMode(A7, OUTPUT);
pinMode(D7, INPUT);
digitalWrite(A7, HIGH);
delay(1);
assertEqual((int)digitalRead(D7), (int)HIGH);
digitalWrite(A7, LOW);
delay(1);
assertEqual((int)digitalRead(D7), (int)LOW);
// Issue #1447
} else {
Serial.println("Publishing 10 messages, see them at 'particle subscribe mine'");
// Set magic key in retained memory to indicate that we just went into deep sleep
Expand Down

0 comments on commit 55b42f2

Please sign in to comment.