mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
394:83f921546702
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

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