mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
Parent:
0:9b334a45a8ff
This updates the lib to the mbed lib v125

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /**
<> 144:ef7eb2e8f9f7 2 ******************************************************************************
<> 144:ef7eb2e8f9f7 3 * @file stm32f0xx_hal_iwdg.c
<> 144:ef7eb2e8f9f7 4 * @author MCD Application Team
<> 144:ef7eb2e8f9f7 5 * @version V1.4.0
<> 144:ef7eb2e8f9f7 6 * @date 27-May-2016
<> 144:ef7eb2e8f9f7 7 * @brief IWDG HAL module driver.
<> 144:ef7eb2e8f9f7 8 * This file provides firmware functions to manage the following
<> 144:ef7eb2e8f9f7 9 * functionalities of the Independent Watchdog (IWDG) peripheral:
<> 144:ef7eb2e8f9f7 10 * + Initialization and Configuration functions
<> 144:ef7eb2e8f9f7 11 * + IO operation functions
<> 144:ef7eb2e8f9f7 12 * + Peripheral State functions
<> 144:ef7eb2e8f9f7 13 *
<> 144:ef7eb2e8f9f7 14 @verbatim
<> 144:ef7eb2e8f9f7 15 ===============================================================================
<> 144:ef7eb2e8f9f7 16 ##### IWDG Specific features #####
<> 144:ef7eb2e8f9f7 17 ===============================================================================
<> 144:ef7eb2e8f9f7 18 [..]
<> 144:ef7eb2e8f9f7 19 (+) The IWDG can be started by either software or hardware (configurable
<> 144:ef7eb2e8f9f7 20 through option byte).
<> 144:ef7eb2e8f9f7 21 (+) The IWDG is clocked by its own dedicated Low-Speed clock (LSI) and
<> 144:ef7eb2e8f9f7 22 thus stays active even if the main clock fails.
<> 144:ef7eb2e8f9f7 23 (+) Once the IWDG is started, the LSI is forced ON and cannot be disabled
<> 144:ef7eb2e8f9f7 24 (LSI cannot be disabled too), and the counter starts counting down from
<> 144:ef7eb2e8f9f7 25 the reset value of 0xFFF. When it reaches the end of count value (0x000)
<> 144:ef7eb2e8f9f7 26 a system reset is generated.
<> 144:ef7eb2e8f9f7 27 (+) The IWDG counter should be refreshed at regular intervals, otherwise the
<> 144:ef7eb2e8f9f7 28 watchdog generates an MCU reset when the counter reaches 0.
<> 144:ef7eb2e8f9f7 29 (+) The IWDG is implemented in the VDD voltage domain that is still functional
<> 144:ef7eb2e8f9f7 30 in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY).
<> 144:ef7eb2e8f9f7 31 (+) IWDGRST flag in RCC_CSR register can be used to inform when an IWDG
<> 144:ef7eb2e8f9f7 32 reset occurs.
<> 144:ef7eb2e8f9f7 33 (+) Min-max timeout value @41KHz (LSI): ~0.1ms / ~25.5s
<> 144:ef7eb2e8f9f7 34 The IWDG timeout may vary due to LSI frequency dispersion. STM32F0x
<> 144:ef7eb2e8f9f7 35 devices provide the capability to measure the LSI frequency (LSI clock
<> 144:ef7eb2e8f9f7 36 connected internally to TIM16 CH1 input capture). The measured value
<> 144:ef7eb2e8f9f7 37 can be used to have an IWDG timeout with an acceptable accuracy.
<> 144:ef7eb2e8f9f7 38 For more information, please refer to the STM32F0x Reference manual.
<> 144:ef7eb2e8f9f7 39
<> 144:ef7eb2e8f9f7 40 ##### How to use this driver #####
<> 144:ef7eb2e8f9f7 41 ===============================================================================
<> 144:ef7eb2e8f9f7 42 [..]
<> 144:ef7eb2e8f9f7 43 (#) if Window option is disabled
<> 144:ef7eb2e8f9f7 44 (++) Use IWDG using HAL_IWDG_Init() function to :
<> 144:ef7eb2e8f9f7 45 (+++) Enable write access to IWDG_PR, IWDG_RLR.
<> 144:ef7eb2e8f9f7 46 (+++) Configure the IWDG prescaler, counter reload value.
<> 144:ef7eb2e8f9f7 47 This reload value will be loaded in the IWDG counter each time the counter
<> 144:ef7eb2e8f9f7 48 is reloaded, then the IWDG will start counting down from this value.
<> 144:ef7eb2e8f9f7 49 (++) Use IWDG using HAL_IWDG_Start() function to :
<> 144:ef7eb2e8f9f7 50 (+++) Reload IWDG counter with value defined in the IWDG_RLR register.
<> 144:ef7eb2e8f9f7 51 (+++) Start the IWDG, when the IWDG is used in software mode (no need
<> 144:ef7eb2e8f9f7 52 to enable the LSI, it will be enabled by hardware).
<> 144:ef7eb2e8f9f7 53 (++) Then the application program must refresh the IWDG counter at regular
<> 144:ef7eb2e8f9f7 54 intervals during normal operation to prevent an MCU reset, using
<> 144:ef7eb2e8f9f7 55 HAL_IWDG_Refresh() function.
<> 144:ef7eb2e8f9f7 56 (#) if Window option is enabled:
<> 144:ef7eb2e8f9f7 57 (++) Use IWDG using HAL_IWDG_Start() function to enable IWDG downcounter
<> 144:ef7eb2e8f9f7 58 (++) Use IWDG using HAL_IWDG_Init() function to :
<> 144:ef7eb2e8f9f7 59 (+++) Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers.
<> 144:ef7eb2e8f9f7 60 (+++) Configure the IWDG prescaler, reload value and window value.
<> 144:ef7eb2e8f9f7 61 (++) Then the application program must refresh the IWDG counter at regular
<> 144:ef7eb2e8f9f7 62 intervals during normal operation to prevent an MCU reset, using
<> 144:ef7eb2e8f9f7 63 HAL_IWDG_Refresh() function.
<> 144:ef7eb2e8f9f7 64
<> 144:ef7eb2e8f9f7 65 *** IWDG HAL driver macros list ***
<> 144:ef7eb2e8f9f7 66 ====================================
<> 144:ef7eb2e8f9f7 67 [..]
<> 144:ef7eb2e8f9f7 68 Below the list of most used macros in IWDG HAL driver.
<> 144:ef7eb2e8f9f7 69
<> 144:ef7eb2e8f9f7 70 (+) __HAL_IWDG_START: Enable the IWDG peripheral
<> 144:ef7eb2e8f9f7 71 (+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register
<> 144:ef7eb2e8f9f7 72 (+) IWDG_ENABLE_WRITE_ACCESS : Enable write access to IWDG_PR and IWDG_RLR registers
<> 144:ef7eb2e8f9f7 73 (+) IWDG_DISABLE_WRITE_ACCESS : Disable write access to IWDG_PR and IWDG_RLR registers
<> 144:ef7eb2e8f9f7 74 (+) __HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 @endverbatim
<> 144:ef7eb2e8f9f7 77 ******************************************************************************
<> 144:ef7eb2e8f9f7 78 * @attention
<> 144:ef7eb2e8f9f7 79 *
<> 144:ef7eb2e8f9f7 80 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
<> 144:ef7eb2e8f9f7 81 *
<> 144:ef7eb2e8f9f7 82 * Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 83 * are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 84 * 1. Redistributions of source code must retain the above copyright notice,
<> 144:ef7eb2e8f9f7 85 * this list of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 86 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 144:ef7eb2e8f9f7 87 * this list of conditions and the following disclaimer in the documentation
<> 144:ef7eb2e8f9f7 88 * and/or other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 89 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 144:ef7eb2e8f9f7 90 * may be used to endorse or promote products derived from this software
<> 144:ef7eb2e8f9f7 91 * without specific prior written permission.
<> 144:ef7eb2e8f9f7 92 *
<> 144:ef7eb2e8f9f7 93 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 144:ef7eb2e8f9f7 94 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 144:ef7eb2e8f9f7 95 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 96 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 144:ef7eb2e8f9f7 97 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 144:ef7eb2e8f9f7 98 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 144:ef7eb2e8f9f7 99 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 144:ef7eb2e8f9f7 100 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 144:ef7eb2e8f9f7 101 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 144:ef7eb2e8f9f7 102 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 103 *
<> 144:ef7eb2e8f9f7 104 ******************************************************************************
<> 144:ef7eb2e8f9f7 105 */
<> 144:ef7eb2e8f9f7 106
<> 144:ef7eb2e8f9f7 107 /* Includes ------------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 108 #include "stm32f0xx_hal.h"
<> 144:ef7eb2e8f9f7 109
<> 144:ef7eb2e8f9f7 110 /** @addtogroup STM32F0xx_HAL_Driver
<> 144:ef7eb2e8f9f7 111 * @{
<> 144:ef7eb2e8f9f7 112 */
<> 144:ef7eb2e8f9f7 113
<> 144:ef7eb2e8f9f7 114 /** @defgroup IWDG IWDG
<> 144:ef7eb2e8f9f7 115 * @brief IWDG HAL module driver.
<> 144:ef7eb2e8f9f7 116 * @{
<> 144:ef7eb2e8f9f7 117 */
<> 144:ef7eb2e8f9f7 118
<> 144:ef7eb2e8f9f7 119 #ifdef HAL_IWDG_MODULE_ENABLED
<> 144:ef7eb2e8f9f7 120
<> 144:ef7eb2e8f9f7 121 /* Private typedef -----------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 122 /* Private define ------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 123 /** @defgroup IWDG_Private_Defines IWDG Private Defines
<> 144:ef7eb2e8f9f7 124 * @{
<> 144:ef7eb2e8f9f7 125 */
<> 144:ef7eb2e8f9f7 126
<> 144:ef7eb2e8f9f7 127 #define HAL_IWDG_DEFAULT_TIMEOUT (uint32_t)1000
<> 144:ef7eb2e8f9f7 128
<> 144:ef7eb2e8f9f7 129 /**
<> 144:ef7eb2e8f9f7 130 * @}
<> 144:ef7eb2e8f9f7 131 */
<> 144:ef7eb2e8f9f7 132 /* Private macro -------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 133 /* Private variables ---------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 134 /* Private function prototypes -----------------------------------------------*/
<> 144:ef7eb2e8f9f7 135 /* Exported functions --------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 136
<> 144:ef7eb2e8f9f7 137 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions
<> 144:ef7eb2e8f9f7 138 * @{
<> 144:ef7eb2e8f9f7 139 */
<> 144:ef7eb2e8f9f7 140
<> 144:ef7eb2e8f9f7 141 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and de-initialization functions
<> 144:ef7eb2e8f9f7 142 * @brief Initialization and Configuration functions.
<> 144:ef7eb2e8f9f7 143 *
<> 144:ef7eb2e8f9f7 144 @verbatim
<> 144:ef7eb2e8f9f7 145 ===============================================================================
<> 144:ef7eb2e8f9f7 146 ##### Initialization and de-initialization functions #####
<> 144:ef7eb2e8f9f7 147 ===============================================================================
<> 144:ef7eb2e8f9f7 148 [..] This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 149 (+) Initialize the IWDG according to the specified parameters
<> 144:ef7eb2e8f9f7 150 in the IWDG_InitTypeDef and create the associated handle
<> 144:ef7eb2e8f9f7 151 (+) Manage Window option
<> 144:ef7eb2e8f9f7 152 (+) Initialize the IWDG MSP
<> 144:ef7eb2e8f9f7 153 (+) DeInitialize the IWDG MSP
<> 144:ef7eb2e8f9f7 154
<> 144:ef7eb2e8f9f7 155 @endverbatim
<> 144:ef7eb2e8f9f7 156 * @{
<> 144:ef7eb2e8f9f7 157 */
<> 144:ef7eb2e8f9f7 158
<> 144:ef7eb2e8f9f7 159 /**
<> 144:ef7eb2e8f9f7 160 * @brief Initialize the IWDG according to the specified
<> 144:ef7eb2e8f9f7 161 * parameters in the IWDG_InitTypeDef and initialize the associated handle.
<> 144:ef7eb2e8f9f7 162 * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 163 * the configuration information for the specified IWDG module.
<> 144:ef7eb2e8f9f7 164 * @retval HAL status
<> 144:ef7eb2e8f9f7 165 */
<> 144:ef7eb2e8f9f7 166 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)
<> 144:ef7eb2e8f9f7 167 {
<> 144:ef7eb2e8f9f7 168 uint32_t tickstart = 0;
<> 144:ef7eb2e8f9f7 169
<> 144:ef7eb2e8f9f7 170 /* Check the IWDG handle allocation */
<> 144:ef7eb2e8f9f7 171 if(hiwdg == NULL)
<> 144:ef7eb2e8f9f7 172 {
<> 144:ef7eb2e8f9f7 173 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 174 }
<> 144:ef7eb2e8f9f7 175
<> 144:ef7eb2e8f9f7 176 /* Check the parameters */
<> 144:ef7eb2e8f9f7 177 assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance));
<> 144:ef7eb2e8f9f7 178 assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler));
<> 144:ef7eb2e8f9f7 179 assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload));
<> 144:ef7eb2e8f9f7 180 assert_param(IS_IWDG_WINDOW(hiwdg->Init.Window));
<> 144:ef7eb2e8f9f7 181
<> 144:ef7eb2e8f9f7 182 /* Check pending flag, if previous update not done, return error */
<> 144:ef7eb2e8f9f7 183 if((__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_PVU) != RESET)
<> 144:ef7eb2e8f9f7 184 &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
<> 144:ef7eb2e8f9f7 185 &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_WVU) != RESET))
<> 144:ef7eb2e8f9f7 186 {
<> 144:ef7eb2e8f9f7 187 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 188 }
<> 144:ef7eb2e8f9f7 189
<> 144:ef7eb2e8f9f7 190 if(hiwdg->State == HAL_IWDG_STATE_RESET)
<> 144:ef7eb2e8f9f7 191 {
<> 144:ef7eb2e8f9f7 192 /* Allocate lock resource and initialize it */
<> 144:ef7eb2e8f9f7 193 hiwdg->Lock = HAL_UNLOCKED;
<> 144:ef7eb2e8f9f7 194
<> 144:ef7eb2e8f9f7 195 /* Init the low level hardware */
<> 144:ef7eb2e8f9f7 196 HAL_IWDG_MspInit(hiwdg);
<> 144:ef7eb2e8f9f7 197 }
<> 144:ef7eb2e8f9f7 198
<> 144:ef7eb2e8f9f7 199 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 200 hiwdg->State = HAL_IWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 201
<> 144:ef7eb2e8f9f7 202 /* Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers */
<> 144:ef7eb2e8f9f7 203 /* by writing 0x5555 in KR */
<> 144:ef7eb2e8f9f7 204 IWDG_ENABLE_WRITE_ACCESS(hiwdg);
<> 144:ef7eb2e8f9f7 205
<> 144:ef7eb2e8f9f7 206 /* Write to IWDG registers the IWDG_Prescaler & IWDG_Reload values to work with */
<> 144:ef7eb2e8f9f7 207 MODIFY_REG(hiwdg->Instance->PR, IWDG_PR_PR, hiwdg->Init.Prescaler);
<> 144:ef7eb2e8f9f7 208 MODIFY_REG(hiwdg->Instance->RLR, IWDG_RLR_RL, hiwdg->Init.Reload);
<> 144:ef7eb2e8f9f7 209
<> 144:ef7eb2e8f9f7 210 /* check if window option is enabled */
<> 144:ef7eb2e8f9f7 211 if (((hiwdg->Init.Window) != IWDG_WINDOW_DISABLE) || ((hiwdg->Instance->WINR) != IWDG_WINDOW_DISABLE))
<> 144:ef7eb2e8f9f7 212 {
<> 144:ef7eb2e8f9f7 213 tickstart = HAL_GetTick();
<> 144:ef7eb2e8f9f7 214
<> 144:ef7eb2e8f9f7 215 /* Wait for register to be updated */
<> 144:ef7eb2e8f9f7 216 while((uint32_t)(hiwdg->Instance->SR) != RESET)
<> 144:ef7eb2e8f9f7 217 {
<> 144:ef7eb2e8f9f7 218 if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
<> 144:ef7eb2e8f9f7 219 {
<> 144:ef7eb2e8f9f7 220 /* Set IWDG state */
<> 144:ef7eb2e8f9f7 221 hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
<> 144:ef7eb2e8f9f7 222 return HAL_TIMEOUT;
<> 144:ef7eb2e8f9f7 223 }
<> 144:ef7eb2e8f9f7 224 }
<> 144:ef7eb2e8f9f7 225
<> 144:ef7eb2e8f9f7 226 /* Write to IWDG WINR the IWDG_Window value to compare with */
<> 144:ef7eb2e8f9f7 227 MODIFY_REG(hiwdg->Instance->WINR, IWDG_WINR_WIN, hiwdg->Init.Window);
<> 144:ef7eb2e8f9f7 228 }
<> 144:ef7eb2e8f9f7 229
<> 144:ef7eb2e8f9f7 230 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 231 hiwdg->State = HAL_IWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 232
<> 144:ef7eb2e8f9f7 233 /* Return function status */
<> 144:ef7eb2e8f9f7 234 return HAL_OK;
<> 144:ef7eb2e8f9f7 235 }
<> 144:ef7eb2e8f9f7 236
<> 144:ef7eb2e8f9f7 237 /**
<> 144:ef7eb2e8f9f7 238 * @brief Initialize the IWDG MSP.
<> 144:ef7eb2e8f9f7 239 * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 240 * the configuration information for the specified IWDG module.
<> 144:ef7eb2e8f9f7 241 * @retval None
<> 144:ef7eb2e8f9f7 242 */
<> 144:ef7eb2e8f9f7 243 __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg)
<> 144:ef7eb2e8f9f7 244 {
<> 144:ef7eb2e8f9f7 245 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 246 UNUSED(hiwdg);
<> 144:ef7eb2e8f9f7 247
<> 144:ef7eb2e8f9f7 248 /* NOTE : This function should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 249 the HAL_IWDG_MspInit could be implemented in the user file
<> 144:ef7eb2e8f9f7 250 */
<> 144:ef7eb2e8f9f7 251 }
<> 144:ef7eb2e8f9f7 252
<> 144:ef7eb2e8f9f7 253 /**
<> 144:ef7eb2e8f9f7 254 * @}
<> 144:ef7eb2e8f9f7 255 */
<> 144:ef7eb2e8f9f7 256
<> 144:ef7eb2e8f9f7 257 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
<> 144:ef7eb2e8f9f7 258 * @brief IO operation functions
<> 144:ef7eb2e8f9f7 259 *
<> 144:ef7eb2e8f9f7 260 @verbatim
<> 144:ef7eb2e8f9f7 261 ===============================================================================
<> 144:ef7eb2e8f9f7 262 ##### IO operation functions #####
<> 144:ef7eb2e8f9f7 263 ===============================================================================
<> 144:ef7eb2e8f9f7 264 [..] This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 265 (+) Start the IWDG.
<> 144:ef7eb2e8f9f7 266 (+) Refresh the IWDG.
<> 144:ef7eb2e8f9f7 267
<> 144:ef7eb2e8f9f7 268 @endverbatim
<> 144:ef7eb2e8f9f7 269 * @{
<> 144:ef7eb2e8f9f7 270 */
<> 144:ef7eb2e8f9f7 271
<> 144:ef7eb2e8f9f7 272 /**
<> 144:ef7eb2e8f9f7 273 * @brief Start the IWDG.
<> 144:ef7eb2e8f9f7 274 * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 275 * the configuration information for the specified IWDG module.
<> 144:ef7eb2e8f9f7 276 * @retval HAL status
<> 144:ef7eb2e8f9f7 277 */
<> 144:ef7eb2e8f9f7 278 HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg)
<> 144:ef7eb2e8f9f7 279 {
<> 144:ef7eb2e8f9f7 280 uint32_t tickstart = 0;
<> 144:ef7eb2e8f9f7 281
<> 144:ef7eb2e8f9f7 282 /* Process locked */
<> 144:ef7eb2e8f9f7 283 __HAL_LOCK(hiwdg);
<> 144:ef7eb2e8f9f7 284
<> 144:ef7eb2e8f9f7 285 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 286 hiwdg->State = HAL_IWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 287
<> 144:ef7eb2e8f9f7 288 /* Reload IWDG counter with value defined in the RLR register */
<> 144:ef7eb2e8f9f7 289 if ((hiwdg->Init.Window) == IWDG_WINDOW_DISABLE)
<> 144:ef7eb2e8f9f7 290 {
<> 144:ef7eb2e8f9f7 291 __HAL_IWDG_RELOAD_COUNTER(hiwdg);
<> 144:ef7eb2e8f9f7 292 }
<> 144:ef7eb2e8f9f7 293
<> 144:ef7eb2e8f9f7 294 /* Start the IWDG peripheral */
<> 144:ef7eb2e8f9f7 295 __HAL_IWDG_START(hiwdg);
<> 144:ef7eb2e8f9f7 296
<> 144:ef7eb2e8f9f7 297 tickstart = HAL_GetTick();
<> 144:ef7eb2e8f9f7 298
<> 144:ef7eb2e8f9f7 299 /* Wait until PVU, RVU, WVU flag are RESET */
<> 144:ef7eb2e8f9f7 300 while( (__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_PVU) != RESET)
<> 144:ef7eb2e8f9f7 301 &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
<> 144:ef7eb2e8f9f7 302 &&(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_WVU) != RESET) )
<> 144:ef7eb2e8f9f7 303 {
<> 144:ef7eb2e8f9f7 304
<> 144:ef7eb2e8f9f7 305 if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
<> 144:ef7eb2e8f9f7 306 {
<> 144:ef7eb2e8f9f7 307 /* Set IWDG state */
<> 144:ef7eb2e8f9f7 308 hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
<> 144:ef7eb2e8f9f7 309
<> 144:ef7eb2e8f9f7 310 /* Process unlocked */
<> 144:ef7eb2e8f9f7 311 __HAL_UNLOCK(hiwdg);
<> 144:ef7eb2e8f9f7 312
<> 144:ef7eb2e8f9f7 313 return HAL_TIMEOUT;
<> 144:ef7eb2e8f9f7 314 }
<> 144:ef7eb2e8f9f7 315 }
<> 144:ef7eb2e8f9f7 316
<> 144:ef7eb2e8f9f7 317 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 318 hiwdg->State = HAL_IWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 319
<> 144:ef7eb2e8f9f7 320 /* Process Unlocked */
<> 144:ef7eb2e8f9f7 321 __HAL_UNLOCK(hiwdg);
<> 144:ef7eb2e8f9f7 322
<> 144:ef7eb2e8f9f7 323 /* Return function status */
<> 144:ef7eb2e8f9f7 324 return HAL_OK;
<> 144:ef7eb2e8f9f7 325 }
<> 144:ef7eb2e8f9f7 326
<> 144:ef7eb2e8f9f7 327 /**
<> 144:ef7eb2e8f9f7 328 * @brief Refresh the IWDG.
<> 144:ef7eb2e8f9f7 329 * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 330 * the configuration information for the specified IWDG module.
<> 144:ef7eb2e8f9f7 331 * @retval HAL status
<> 144:ef7eb2e8f9f7 332 */
<> 144:ef7eb2e8f9f7 333 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
<> 144:ef7eb2e8f9f7 334 {
<> 144:ef7eb2e8f9f7 335 uint32_t tickstart = 0;
<> 144:ef7eb2e8f9f7 336
<> 144:ef7eb2e8f9f7 337 /* Process Locked */
<> 144:ef7eb2e8f9f7 338 __HAL_LOCK(hiwdg);
<> 144:ef7eb2e8f9f7 339
<> 144:ef7eb2e8f9f7 340 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 341 hiwdg->State = HAL_IWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 342
<> 144:ef7eb2e8f9f7 343 tickstart = HAL_GetTick();
<> 144:ef7eb2e8f9f7 344
<> 144:ef7eb2e8f9f7 345 /* Wait until RVU flag is RESET */
<> 144:ef7eb2e8f9f7 346 while(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET)
<> 144:ef7eb2e8f9f7 347 {
<> 144:ef7eb2e8f9f7 348 if((HAL_GetTick() - tickstart ) > HAL_IWDG_DEFAULT_TIMEOUT)
<> 144:ef7eb2e8f9f7 349 {
<> 144:ef7eb2e8f9f7 350 /* Set IWDG state */
<> 144:ef7eb2e8f9f7 351 hiwdg->State = HAL_IWDG_STATE_TIMEOUT;
<> 144:ef7eb2e8f9f7 352
<> 144:ef7eb2e8f9f7 353 /* Process unlocked */
<> 144:ef7eb2e8f9f7 354 __HAL_UNLOCK(hiwdg);
<> 144:ef7eb2e8f9f7 355
<> 144:ef7eb2e8f9f7 356 return HAL_TIMEOUT;
<> 144:ef7eb2e8f9f7 357 }
<> 144:ef7eb2e8f9f7 358 }
<> 144:ef7eb2e8f9f7 359
<> 144:ef7eb2e8f9f7 360 /* Reload IWDG counter with value defined in the reload register */
<> 144:ef7eb2e8f9f7 361 __HAL_IWDG_RELOAD_COUNTER(hiwdg);
<> 144:ef7eb2e8f9f7 362
<> 144:ef7eb2e8f9f7 363 /* Change IWDG peripheral state */
<> 144:ef7eb2e8f9f7 364 hiwdg->State = HAL_IWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 365
<> 144:ef7eb2e8f9f7 366 /* Process Unlocked */
<> 144:ef7eb2e8f9f7 367 __HAL_UNLOCK(hiwdg);
<> 144:ef7eb2e8f9f7 368
<> 144:ef7eb2e8f9f7 369 /* Return function status */
<> 144:ef7eb2e8f9f7 370 return HAL_OK;
<> 144:ef7eb2e8f9f7 371 }
<> 144:ef7eb2e8f9f7 372
<> 144:ef7eb2e8f9f7 373 /**
<> 144:ef7eb2e8f9f7 374 * @}
<> 144:ef7eb2e8f9f7 375 */
<> 144:ef7eb2e8f9f7 376
<> 144:ef7eb2e8f9f7 377 /** @defgroup IWDG_Exported_Functions_Group3 Peripheral State functions
<> 144:ef7eb2e8f9f7 378 * @brief Peripheral State functions.
<> 144:ef7eb2e8f9f7 379 *
<> 144:ef7eb2e8f9f7 380 @verbatim
<> 144:ef7eb2e8f9f7 381 ===============================================================================
<> 144:ef7eb2e8f9f7 382 ##### Peripheral State functions #####
<> 144:ef7eb2e8f9f7 383 ===============================================================================
<> 144:ef7eb2e8f9f7 384 [..]
<> 144:ef7eb2e8f9f7 385 This subsection permits to get in run-time the status of the peripheral.
<> 144:ef7eb2e8f9f7 386
<> 144:ef7eb2e8f9f7 387 @endverbatim
<> 144:ef7eb2e8f9f7 388 * @{
<> 144:ef7eb2e8f9f7 389 */
<> 144:ef7eb2e8f9f7 390
<> 144:ef7eb2e8f9f7 391 /**
<> 144:ef7eb2e8f9f7 392 * @brief Return the IWDG handle state.
<> 144:ef7eb2e8f9f7 393 * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 394 * the configuration information for the specified IWDG module.
<> 144:ef7eb2e8f9f7 395 * @retval HAL state
<> 144:ef7eb2e8f9f7 396 */
<> 144:ef7eb2e8f9f7 397 HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg)
<> 144:ef7eb2e8f9f7 398 {
<> 144:ef7eb2e8f9f7 399 /* Return IWDG handle state */
<> 144:ef7eb2e8f9f7 400 return hiwdg->State;
<> 144:ef7eb2e8f9f7 401 }
<> 144:ef7eb2e8f9f7 402
<> 144:ef7eb2e8f9f7 403 /**
<> 144:ef7eb2e8f9f7 404 * @}
<> 144:ef7eb2e8f9f7 405 */
<> 144:ef7eb2e8f9f7 406
<> 144:ef7eb2e8f9f7 407 /**
<> 144:ef7eb2e8f9f7 408 * @}
<> 144:ef7eb2e8f9f7 409 */
<> 144:ef7eb2e8f9f7 410
<> 144:ef7eb2e8f9f7 411 #endif /* HAL_IWDG_MODULE_ENABLED */
<> 144:ef7eb2e8f9f7 412 /**
<> 144:ef7eb2e8f9f7 413 * @}
<> 144:ef7eb2e8f9f7 414 */
<> 144:ef7eb2e8f9f7 415
<> 144:ef7eb2e8f9f7 416 /**
<> 144:ef7eb2e8f9f7 417 * @}
<> 144:ef7eb2e8f9f7 418 */
<> 144:ef7eb2e8f9f7 419
<> 144:ef7eb2e8f9f7 420 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/