CARME-M4 BSP  V1.5
stm32f4xx_iwdg.c
Go to the documentation of this file.
1 
84 /* Includes ------------------------------------------------------------------*/
85 #include "stm32f4xx_iwdg.h"
86 
96 /* Private typedef -----------------------------------------------------------*/
97 /* Private define ------------------------------------------------------------*/
98 
99 /* KR register bit mask */
100 #define KR_KEY_RELOAD ((uint16_t)0xAAAA)
101 #define KR_KEY_ENABLE ((uint16_t)0xCCCC)
102 
103 /* Private macro -------------------------------------------------------------*/
104 /* Private variables ---------------------------------------------------------*/
105 /* Private function prototypes -----------------------------------------------*/
106 /* Private functions ---------------------------------------------------------*/
107 
132 void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
133 {
134  /* Check the parameters */
135  assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess));
136  IWDG->KR = IWDG_WriteAccess;
137 }
138 
152 void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
153 {
154  /* Check the parameters */
155  assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler));
156  IWDG->PR = IWDG_Prescaler;
157 }
158 
165 void IWDG_SetReload(uint16_t Reload)
166 {
167  /* Check the parameters */
168  assert_param(IS_IWDG_RELOAD(Reload));
169  IWDG->RLR = Reload;
170 }
171 
179 {
180  IWDG->KR = KR_KEY_RELOAD;
181 }
182 
204 void IWDG_Enable(void)
205 {
206  IWDG->KR = KR_KEY_ENABLE;
207 }
208 
233 FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
234 {
235  FlagStatus bitstatus = RESET;
236  /* Check the parameters */
237  assert_param(IS_IWDG_FLAG(IWDG_FLAG));
238  if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET)
239  {
240  bitstatus = SET;
241  }
242  else
243  {
244  bitstatus = RESET;
245  }
246  /* Return the flag status */
247  return bitstatus;
248 }
249 
266 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG)
Checks whether the specified IWDG flag is set or not.
void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess)
Enables or disables write access to IWDG_PR and IWDG_RLR registers.
void IWDG_Enable(void)
Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).
void IWDG_SetPrescaler(uint8_t IWDG_Prescaler)
Sets IWDG Prescaler value.
void IWDG_ReloadCounter(void)
Reloads IWDG counter with value defined in the reload register (write access to IWDG_PR and IWDG_RLR ...
This file contains all the functions prototypes for the IWDG firmware library.
void IWDG_SetReload(uint16_t Reload)
Sets IWDG Reload value.