Skip to content

feat(wb0): add STM32WB0x support #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ enable an I2C peripheral in low power mode. See board documentation for low powe
>
> * The board will restart when exit shutdown mode.

> [!Important]
> For STM32WB0x:
> * board will restart when exit shutdown mode and deep sleep.
> * Shutdown wakeup only with reset pin.
> * Wakeup from UART not supported.

## Hardware state

* **Idle mode**: low wake-up latency (µs range) (e.g. ARM WFI). Memories and
Expand Down
18 changes: 17 additions & 1 deletion src/STM32LowPower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,23 @@ void STM32LowPower::deepSleep(uint32_t ms)
* @param ms: optional delay before leave the shutdown mode (default: 0).
* @retval None
*/
#if defined(STM32WB0x)
void STM32LowPower::shutdown(void)
{
LowPower_shutdown(false);
}
#else
void STM32LowPower::shutdown(uint32_t ms)
{
if ((ms != 0) || _rtc_wakeup) {
programRtcWakeUp(ms, SHUTDOWN_MODE);
}

/* Get the rtc object to know if it is configured */
STM32RTC &rtc = STM32RTC::getInstance();
LowPower_shutdown(rtc.isConfigured());
}
#endif

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

if (LowPowerMode == SHUTDOWN_MODE) {
if ((LowPowerMode == SHUTDOWN_MODE)
#if defined(PWR_WAKEUP_PA0)
|| (LowPowerMode == DEEP_SLEEP_MODE)
#endif /* PWR_WAKEUP1_SOURCE_SELECTION_0 */
) {
// If Gpio is a Wake up pin activate it for shutdown (standby or shutdown stm32)
LowPower_EnableWakeUpPin(pin, mode);
}
Expand Down Expand Up @@ -192,7 +204,11 @@ void STM32LowPower::programRtcWakeUp(uint32_t ms, LP_Mode lp_mode)
break;
// LSI or LSE must be selected as clock source to wakeup the device.
case DEEP_SLEEP_MODE:
#if defined(RCC_RTC_WDG_BLEWKUP_CLKSOURCE_HSI64M_DIV2048)
clkSrc = (clkSrc == STM32RTC::HSI_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
#else
clkSrc = (clkSrc == STM32RTC::HSE_CLOCK) ? STM32RTC::LSI_CLOCK : clkSrc;
#endif
break;
default:
case SHUTDOWN_MODE:
Expand Down
6 changes: 4 additions & 2 deletions src/STM32LowPower.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ class STM32LowPower {
{
deepSleep((uint32_t)ms);
}

#if defined(STM32WB0x)
void shutdown(void);
#else
void shutdown(uint32_t ms = 0);
void shutdown(int ms)
{
shutdown((uint32_t)ms);
}

#endif
void attachInterruptWakeup(uint32_t pin, voidFuncPtrVoid callback, uint32_t mode, LP_Mode LowPowerMode = SHUTDOWN_MODE);

void enableWakeupFrom(HardwareSerial *serial, voidFuncPtrVoid callback);
Expand Down
Loading