Skip to content

Commit 2eda8a5

Browse files
committed
fix: check wakeup pin and avoid to use it uninitailized
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 5acd39b commit 2eda8a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/low_power.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
7878
#if !defined(PWR_WAKEUP_PIN1_HIGH)
7979
UNUSED(mode);
8080
#endif
81-
uint32_t wkup_pin;
81+
uint32_t wkup_pin = 0;
8282
PinName p = digitalPinToPinName(pin);
8383
if (p != NC) {
8484
#ifdef PWR_WAKEUP_PIN1
@@ -151,7 +151,9 @@ void LowPower_EnableWakeUpPin(uint32_t pin, uint32_t mode)
151151
wkup_pin = PWR_WAKEUP_PIN8;
152152
}
153153
#endif /* PWR_WAKEUP_PIN8 */
154-
HAL_PWR_EnableWakeUpPin(wkup_pin);
154+
if (IS_PWR_WAKEUP_PIN(wkup_pin)) {
155+
HAL_PWR_EnableWakeUpPin(wkup_pin);
156+
}
155157
}
156158
}
157159

@@ -317,7 +319,7 @@ void LowPower_EnableWakeUpUart(serial_t *serial, void (*FuncPtr)(void))
317319
WakeUpSelection.WakeUpEvent = UART_WAKEUP_ON_READDATA_NONEMPTY;
318320
HAL_UARTEx_StopModeWakeUpSourceConfig(WakeUpUart, WakeUpSelection);
319321

320-
/* Enable the UART Wake UP from STOP1 mode Interrupt */
322+
/* Enable the UART Wake UP from STOPx mode Interrupt */
321323
__HAL_UART_ENABLE_IT(WakeUpUart, UART_IT_WUF);
322324
#else
323325
UNUSED(serial);

0 commit comments

Comments
 (0)