Skip to content

Commit 4231d49

Browse files
committed
feat(wb0): add STM32WB0x support
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 425956c commit 4231d49

File tree

4 files changed

+244
-43
lines changed

4 files changed

+244
-43
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ enable an I2C peripheral in low power mode. See board documentation for low powe
5757
>
5858
> * The board will restart when exit shutdown mode.
5959
60+
> [!Important]
61+
> For STM32WB0x:
62+
> * board will restart when exit shutdown mode and deep sleep.
63+
> * Shutdown wakeup only with reset pin.
64+
> * Wakeup from UART not supported.
65+
6066
## Hardware state
6167

6268
* **Idle mode**: low wake-up latency (µs range) (e.g. ARM WFI). Memories and

src/STM32LowPower.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,23 @@ void STM32LowPower::deepSleep(uint32_t ms)
110110
* @param ms: optional delay before leave the shutdown mode (default: 0).
111111
* @retval None
112112
*/
113+
#if defined(STM32WB0x)
114+
void STM32LowPower::shutdown(void)
115+
{
116+
LowPower_shutdown(false);
117+
}
118+
#else
113119
void STM32LowPower::shutdown(uint32_t ms)
114120
{
115121
if ((ms != 0) || _rtc_wakeup) {
116122
programRtcWakeUp(ms, SHUTDOWN_MODE);
117123
}
124+
118125
/* Get the rtc object to know if it is configured */
119126
STM32RTC &rtc = STM32RTC::getInstance();
120127
LowPower_shutdown(rtc.isConfigured());
121128
}
129+
#endif
122130

123131
/**
124132
* @brief Enable GPIO pin in interrupt mode. If the pin is a wakeup pin, it is
@@ -135,7 +143,11 @@ void STM32LowPower::attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback
135143
{
136144
attachInterrupt(pin, callback, mode);
137145

138-
if (LowPowerMode == SHUTDOWN_MODE) {
146+
if ((LowPowerMode == SHUTDOWN_MODE)
147+
#if defined(PWR_WAKEUP_PA0)
148+
|| (LowPowerMode == DEEP_SLEEP_MODE)
149+
#endif /* PWR_WAKEUP1_SOURCE_SELECTION_0 */
150+
) {
139151
// If Gpio is a Wake up pin activate it for shutdown (standby or shutdown stm32)
140152
LowPower_EnableWakeUpPin(pin, mode);
141153
}
@@ -192,7 +204,11 @@ void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
192204
break;
193205
// LSI or LSE must be selected as clock source to wakeup the device.
194206
case DEEP_SLEEP_MODE:
207+
#if defined(RCC_RTC_WDG_BLEWKUP_CLKSOURCE_HSI64M_DIV2048)
208+
clkSrc = (clkSrc == STM32RTC::HSI_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
209+
#else
195210
clkSrc = (clkSrc == STM32RTC::HSE_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
211+
#endif
196212
break;
197213
default:
198214
case SHUTDOWN_MODE:

src/STM32LowPower.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ class STM32LowPower {
8080
{
8181
deepSleep((uint32_t)ms);
8282
}
83-
83+
#if defined(STM32WB0x)
84+
void shutdown(void);
85+
#else
8486
void shutdown(uint32_t ms = 0);
8587
void shutdown(int ms)
8688
{
8789
shutdown((uint32_t)ms);
8890
}
89-
91+
#endif
9092
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);
9193

9294
void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);

0 commit comments

Comments
 (0)