mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
51 lines
990 B
C
51 lines
990 B
C
/* hal_wwdg.h */
|
|
#include "hal_wwdg.h"
|
|
|
|
void WWDG_Init(WWDG_Type * WWDGx, WWDG_Init_Type * init)
|
|
{
|
|
if (NULL != init)
|
|
{
|
|
WWDGx->CFGR = WWDG_CFGR_WDGTB(init->Prescaler)
|
|
| WWDG_CFGR_W(init->UpperLimit);
|
|
}
|
|
}
|
|
|
|
void WWDG_Start(WWDG_Type * WWDGx)
|
|
{
|
|
WWDGx->CR |= WWDG_CR_WDGA_MASK;
|
|
}
|
|
|
|
void WWDG_Reload(WWDG_Type * WWDGx, uint32_t value)
|
|
{
|
|
if (value > WWDG_LOWER_LIMIT)
|
|
{
|
|
WWDGx->CR = (WWDGx->CR & ~WWDG_CR_T_MASK) | WWDG_CR_T(value);
|
|
}
|
|
}
|
|
|
|
void WWDG_EnableInterrupts(WWDG_Type * WWDGx, uint32_t interrupts, bool enable)
|
|
{
|
|
if ( (true == enable) && (WWDG_INT_ALMOST_TIMEOUT == interrupts) )
|
|
{
|
|
WWDGx->CFGR |= WWDG_CFGR_EWI_MASK;
|
|
}
|
|
else
|
|
{
|
|
/* if WWDG_INT_ALMOST_TIMEOUT interrupt is enabled, only MCU reset can close it. */
|
|
}
|
|
}
|
|
|
|
|
|
uint32_t WWDG_GetStatus(WWDG_Type * WWDGx)
|
|
{
|
|
return WWDGx->SR;
|
|
}
|
|
|
|
void WWDG_ClearStatus(WWDG_Type * WWDGx, uint32_t status)
|
|
{
|
|
WWDGx->SR &= ~status;
|
|
}
|
|
|
|
|
|
/* EOF. */
|