STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_iwdg.c
Go to the documentation of this file.
1 
111 /* Includes ------------------------------------------------------------------*/
112 #include "stm32f7xx_hal.h"
113 
118 #ifdef HAL_IWDG_MODULE_ENABLED
119 
124 /* Private typedef -----------------------------------------------------------*/
125 /* Private define ------------------------------------------------------------*/
129 /* Status register need 5 RC LSI divided by prescaler clock to be updated. With
130  higher prescaler (256), and according to LSI variation, we need to wait at
131  least 6 cycles so 48 ms. */
132 #define HAL_IWDG_DEFAULT_TIMEOUT 48u
133 
137 /* Private macro -------------------------------------------------------------*/
138 /* Private variables ---------------------------------------------------------*/
139 /* Private function prototypes -----------------------------------------------*/
140 /* Exported functions --------------------------------------------------------*/
141 
173 {
174  uint32_t tickstart;
175 
176  /* Check the IWDG handle allocation */
177  if(hiwdg == NULL)
178  {
179  return HAL_ERROR;
180  }
181 
182  /* Check the parameters */
187 
188  /* Enable IWDG. LSI is turned on automaticaly */
189  __HAL_IWDG_START(hiwdg);
190 
191  /* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers by writing
192  0x5555 in KR */
194 
195  /* Write to IWDG registers the Prescaler & Reload values to work with */
196  hiwdg->Instance->PR = hiwdg->Init.Prescaler;
197  hiwdg->Instance->RLR = hiwdg->Init.Reload;
198 
199  /* Check pending flag, if previous update not done, return timeout */
200  tickstart = HAL_GetTick();
201 
202  /* Wait for register to be updated */
203  while(hiwdg->Instance->SR != RESET)
204  {
205  if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
206  {
207  return HAL_TIMEOUT;
208  }
209  }
210 
211  /* If window parameter is different than current value, modify window
212  register */
213  if(hiwdg->Instance->WINR != hiwdg->Init.Window)
214  {
215  /* Write to IWDG WINR the IWDG_Window value to compare with. In any case,
216  even if window feature is disabled, Watchdog will be reloaded by writing
217  windows register */
218  hiwdg->Instance->WINR = hiwdg->Init.Window;
219  }
220  else
221  {
222  /* Reload IWDG counter with value defined in the reload register */
224  }
225 
226  /* Return function status */
227  return HAL_OK;
228 }
229 
257 {
258  /* Reload IWDG counter with value defined in the reload register */
260 
261  /* Return function status */
262  return HAL_OK;
263 }
264 
273 #endif /* HAL_IWDG_MODULE_ENABLED */
274 
282 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define IS_IWDG_WINDOW(__WINDOW__)
Check IWDG window value.
#define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__)
Reload IWDG counter with value defined in the reload register (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled).
IWDG_InitTypeDef Init
__IO uint32_t RLR
Definition: stm32f745xx.h:649
#define assert_param(expr)
Include module's header file.
#define __HAL_IWDG_START(__HANDLE__)
Enable the IWDG peripheral.
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)
IWDG Handle Structure definition.
#define IS_IWDG_RELOAD(__RELOAD__)
Check IWDG reload value.
#define NULL
Definition: usbd_def.h:53
#define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__)
Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
__IO uint32_t WINR
Definition: stm32f745xx.h:651
This file contains all the functions prototypes for the HAL module driver.
#define IS_IWDG_PRESCALER(__PRESCALER__)
Check IWDG prescaler value.
__IO uint32_t SR
Definition: stm32f745xx.h:650
HAL_StatusTypeDef
HAL Status structures definition.
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
IWDG_TypeDef * Instance
#define IS_IWDG_ALL_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9223
__IO uint32_t PR
Definition: stm32f745xx.h:648