Skip to content

Commit 15c56c0

Browse files
ABOSTMfpistm
authored andcommitted
ExternalWakeup: LowPowerMode parameter SLEEP_MODE should be used
Last parameter of attachInterruptWakeup(), aka "LowPowerMode", should match lowpower state used (in this case LowPower.sleep()) Fixes #54 Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 9e7829f commit 15c56c0

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Arduino library to support STM32 Low Power.
1212
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.
1313

1414
* **`void sleep(uint32_t ms)`**: enter in sleep mode
15-
**param** ms (optional): number of milliseconds before to exit the mode. he RTC is used in alarm mode to wakeup the chip in ms milliseconds.
15+
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.
1616

1717
* **`void deepSleep(uint32_t ms)`**: enter in deepSleep mode
1818
**param** ms (optional): number of milliseconds before to exit the mode. The RTC is used in alarm mode to wakeup the chip in ms milliseconds.
@@ -22,10 +22,11 @@ Arduino library to support STM32 Low Power.
2222

2323
**Note: With [STM32RTC](https://github.com/stm32duino/STM32RTC) version lower than 1.1.0, the minimum number of milliseconds is 1000 ms.**
2424

25-
* **`void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode)`**: Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is configured as wakeup source (see board documentation).
25+
* **`void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode)`**: Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is configured as wakeup source (see board documentation).
2626
**param** pin: pin number
2727
**param** callback: pointer to callback
28-
**param** mode: interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE)
28+
**param** mode: interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE)
29+
**param** LowPowerMode: Low power mode which will be used (IDLE_MODE, SLEEP_MODE, DEEP_SLEEP_MODE or SHUTDOWN_MODE). In case of SHUTDOWN_MODE only, Wakeup pin capability is activated.
2930

3031
* **`void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback)`**: enable a UART peripheral in low power mode. See board documentation for low power mode compatibility.
3132
**param** serial: pointer to a UART

examples/ExternalWakeup/ExternalWakeup.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ void setup() {
3333
// Configure low power
3434
LowPower.begin();
3535
// Attach a wakeup interrupt on pin, calling repetitionsIncrease when the device is woken up
36-
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING);
36+
// Last parameter (LowPowerMode) should match with the low power state used: in this example LowPower.sleep()
37+
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, RISING, SLEEP_MODE);
3738
}
3839

3940
void loop() {

src/STM32LowPower.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ void STM32LowPower::shutdown(uint32_t ms)
119119
* @param pin: pin number
120120
* @param callback: pointer to callback function.
121121
* @param mode: pin interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE)
122+
* @param LowPowerMode: Low power mode which will be used
123+
* (IDLE_MODE, SLEEP_MODE, DEEP_SLEEP_MODE, SHUTDOWN_MODE)
124+
* In case of SHUTDOWN_MODE only, Wakeup pin capability is activated
122125
* @retval None
123126
*/
124127
void STM32LowPower::attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode)

0 commit comments

Comments
 (0)