HK32F MCU的独立看门狗驱动如下:
/* Includes ------------------------------------------------------------------*/
#include "hk32f030m_iwdg.h"
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] : Max time:8190ms.
* @param : None.
* @retval : None.
*/
void IWDG_Init( uint16_t Time_ms )
{
uint16_t ReloadValue;
if( Time_ms > 8190 )
{
Time_ms = 8190;
}
ReloadValue = Time_ms/2;
IWDG_Enable( );
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
IWDG_SetPrescaler( IWDG_Prescaler_256 );
IWDG_SetReload( ReloadValue );
IWDG_SetWindowValue( ReloadValue );
IWDG_ReloadCounter();
}
/**
* @brief : None.
* @param : None.
* @retval : None.
*/
void IWDG_Feed( void )
{
while( IWDG_GetFlagStatus( IWDG_FLAG_RVU ) != RESET );
IWDG_ReloadCounter();
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|