Skip to content

Commit 77e567b

Browse files
committed
attachInterruptWakeup() add parameter to define LowPowerMode
Up to now, when configuring pin for wakeup, if pin has system wakeup capability (able to wakeup from Shutdown), this capabilty is enable (even if we only want to go in idle, sleep or depsleep). It has the inconvenient to enable automaticvally pull down on the pin, on some sTM32 families like L0. Aim of this patch is to be able to configure pins to wakeup from idle, sleep or deepsleep, but without activating System wakeup capability. It means it will not be able to wake from Shutdown. And thus there is no pull down activated. For backward compatibility, default LowPowerMode is SHUTDOWN_MODE Fixes #19
1 parent b3afb49 commit 77e567b

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

keywords.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ shutdown KEYWORD2
2121
attachInterruptWakeup KEYWORD2
2222
enableWakeupFrom KEYWORD2
2323

24+
IDLE_MODE LITERAL1
25+
SLEEP_MODE LITERAL1
26+
DEEP_SLEEP_MODE LITERAL1
27+
SHUTDOWN_MODE LITERAL1
28+
2429
#######################################
2530
# Constants (LITERAL1)
2631
#######################################

src/STM32LowPower.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,15 @@ void STM32LowPower::shutdown(uint32_t millis)
123123
* @param mode: pin interrupt mode (HIGH, LOW, RISING, FALLING or CHANGE)
124124
* @retval None
125125
*/
126-
void STM32LowPower::attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode)
126+
void STM32LowPower::attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode)
127127
{
128128
// All GPIO for idle (smt32 sleep) and sleep (stm32 stop)
129129
attachInterrupt(pin, callback, mode);
130130

131-
// If Gpio is a Wake up pin activate it for deepSleep (standby stm32) and shutdown
132-
LowPower_EnableWakeUpPin(pin, mode);
131+
if (LowPowerMode == SHUTDOWN_MODE) {
132+
// If Gpio is a Wake up pin activate it for deepSleep (standby stm32) and shutdown
133+
LowPower_EnableWakeUpPin(pin, mode);
134+
}
133135
}
134136

135137
/**

src/STM32LowPower.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
#include "STM32RTC.h"
5050
#include "Wire.h"
5151

52+
enum LP_Mode : uint8_t {
53+
IDLE_MODE,
54+
SLEEP_MODE,
55+
DEEP_SLEEP_MODE,
56+
SHUTDOWN_MODE
57+
};
58+
5259
typedef void (*voidFuncPtrVoid)( void ) ;
5360

5461
class STM32LowPower {
@@ -77,20 +84,12 @@ class STM32LowPower {
7784
shutdown((uint32_t)millis);
7885
}
7986

80-
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode);
87+
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
8188

8289
void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);
8390
void enableWakeupFrom(STM32RTC *rtc, voidFuncPtr callback, void *data = NULL);
8491

8592
private:
86-
enum LP_Mode: uint8_t
87-
{
88-
IDLE_MODE,
89-
SLEEP_MODE,
90-
DEEP_SLEEP_MODE,
91-
SHUTDOWN_MODE
92-
};
93-
9493
bool _configured; // Low Power mode initialization status
9594
serial_t *_serial; // Serial for wakeup from deep sleep
9695
bool _rtc_wakeup; // Is RTC wakeup?

0 commit comments

Comments
 (0)