STM32F10x Standard Peripherals Library  3.5.0
/opt/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_iwdg.c
Go to the documentation of this file.
00001 
00022 /* Includes ------------------------------------------------------------------*/
00023 #include "stm32f10x_iwdg.h"
00024 
00046 /* ---------------------- IWDG registers bit mask ----------------------------*/
00047 
00048 /* KR register bit mask */
00049 #define KR_KEY_Reload    ((uint16_t)0xAAAA)
00050 #define KR_KEY_Enable    ((uint16_t)0xCCCC)
00051 
00092 void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
00093 {
00094   /* Check the parameters */
00095   assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
00096   IWDG->KR = IWDG_WriteAccess;
00097 }
00098 
00112 void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
00113 {
00114   /* Check the parameters */
00115   assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler));
00116   IWDG->PR = IWDG_Prescaler;
00117 }
00118 
00125 void IWDG_SetReload(uint16_t Reload)
00126 {
00127   /* Check the parameters */
00128   assert_param(IS_IWDG_RELOAD(Reload));
00129   IWDG->RLR = Reload;
00130 }
00131 
00138 void IWDG_ReloadCounter(void)
00139 {
00140   IWDG->KR = KR_KEY_Reload;
00141 }
00142 
00148 void IWDG_Enable(void)
00149 {
00150   IWDG->KR = KR_KEY_Enable;
00151 }
00152 
00161 FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
00162 {
00163   FlagStatus bitstatus = RESET;
00164   /* Check the parameters */
00165   assert_param(IS_IWDG_FLAG(IWDG_FLAG));
00166   if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET)
00167   {
00168     bitstatus = SET;
00169   }
00170   else
00171   {
00172     bitstatus = RESET;
00173   }
00174   /* Return the flag status */
00175   return bitstatus;
00176 }
00177 
00190 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/