Skip to content

Commit afca0ac

Browse files
committed
chore(wb0): add IWDG support
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 6edf842 commit afca0ac

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

libraries/IWatchdog/src/IWatchdog.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
// Initialize static variable
2525
bool IWatchdogClass::_enabled = false;
2626

27+
IWatchdogClass::IWatchdogClass()
28+
{
29+
#if defined(LL_APB0_GRP1_PERIPH_WDG)
30+
LL_APB0_GRP1_EnableClock(LL_APB0_GRP1_PERIPH_WDG);
31+
#endif
32+
}
33+
2734
/**
2835
* @brief Enable IWDG, must be called once
2936
* @param timeout: value in microseconds
@@ -46,6 +53,9 @@ void IWatchdogClass::begin(uint32_t timeout, uint32_t window)
4653
LL_RCC_LSI_Enable();
4754
while (LL_RCC_LSI_IsReady() != 1) {
4855
}
56+
#endif
57+
#if defined(LL_RCC_LSCO_CLKSOURCE_LSI)
58+
LL_RCC_LSCO_SetSource(LL_RCC_LSCO_CLKSOURCE_LSI);
4959
#endif
5060
// Enable the IWDG by writing 0x0000 CCCC in the IWDG_KR register
5161
LL_IWDG_Enable(IWDG);
@@ -168,8 +178,10 @@ void IWatchdogClass::reload(void)
168178
*/
169179
bool IWatchdogClass::isReset(bool clear)
170180
{
171-
#ifdef IWDG1
181+
#if defined(IWDG1)
172182
bool status = LL_RCC_IsActiveFlag_IWDG1RST();
183+
#elif defined(STM32WB0x)
184+
bool status = LL_RCC_IsActiveFlag_WDGRST();
173185
#else
174186
bool status = LL_RCC_IsActiveFlag_IWDGRST();
175187
#endif

libraries/IWatchdog/src/IWatchdog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
class IWatchdogClass {
3838

3939
public:
40+
IWatchdogClass();
4041
void begin(uint32_t timeout, uint32_t window = IWDG_TIMEOUT_MAX);
4142
void set(uint32_t timeout, uint32_t window = IWDG_TIMEOUT_MAX);
4243
void get(uint32_t *timeout, uint32_t *window = NULL);

0 commit comments

Comments
 (0)