Added iwdg support + early wakeup

This commit is contained in:
Mateusz Myalski
2024-10-17 19:19:03 +02:00
committed by Piotr Esden-Tempski
parent edbb8ed7e3
commit 3f5e250f42
6 changed files with 98 additions and 0 deletions

View File

@@ -150,3 +150,42 @@ void iwdg_reset(void)
}
/**@}*/
/*---------------------------------------------------------------------------*/
/** @brief IWDG enable early wake-up
The watchdog timer will generate IRQ when reaches Early wakeup window value.
The early interrupt is generated when the IWDCNT is lower or equal to EWIT
register.
*/
void iwdg_enable_early_wakeup(uint16_t wakeup_ms) {
IWDG_KR = IWDG_KR_UNLOCK;
// IWDG_EWCR |= IWDG_EWCR_EWIE;
wakeup_ms &= IWDG_EWCR_EWIT_MASK;
wakeup_ms <<= IWDG_EWCR_EWIT_SHIFT;
IWDG_EWCR = IWDG_EWCR_EWIE | wakeup_ms;
}
/**@}*/
/*---------------------------------------------------------------------------*/
/** @brief Disables the watchdog early wake-up
Disable watchdog early wake-up IRQ
*/
void iwdg_disable_early_wakeup(void) {
IWDG_KR = IWDG_KR_UNLOCK;
IWDG_EWCR &= ~IWDG_EWCR_EWIE;
}
/**@}*/
/*---------------------------------------------------------------------------*/
/** @brief Acknowledge early wake-up
The software must write a 1 into this bit in order to acknowledge the early
wake-up interrupt and to clear the EWIF flag.
*/
void iwdg_ack_early_wakeup(void) {
IWDG_KR = IWDG_KR_UNLOCK;
IWDG_EWCR |= IWDG_EWCR_EWIC;
}
/**@}*/

View File

@@ -35,6 +35,7 @@ TGT_CFLAGS += $(STANDARD_FLAGS)
ARFLAGS = rcs
OBJS += iwdg_common_all.o
OBJS += i2c_common_v2.o
OBJS += usart_common_all.o usart_common_v2.o
OBJS += gpio_common_all.o gpio_common_f0234.o