teralytic / mbed-dev

Fork of mbed by teralytic

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 stm32l1xx_hal_wwdg.c
<> 144:ef7eb2e8f9f7 4 * @author MCD Application Team
<> 144:ef7eb2e8f9f7 5 * @version V1.1.3
<> 144:ef7eb2e8f9f7 6 * @date 04-March-2016
<> 144:ef7eb2e8f9f7 7 * @brief WWDG HAL module driver.
<> 144:ef7eb2e8f9f7 8 * This file provides firmware functions to manage the following
<> 144:ef7eb2e8f9f7 9 * functionalities of the Window Watchdog (WWDG) peripheral:
<> 144:ef7eb2e8f9f7 10 * + Initialization and de-initialization functions
<> 144:ef7eb2e8f9f7 11 * + IO operation functions
<> 144:ef7eb2e8f9f7 12 * + Peripheral State functions
<> 144:ef7eb2e8f9f7 13 @verbatim
<> 144:ef7eb2e8f9f7 14 ==============================================================================
<> 144:ef7eb2e8f9f7 15 ##### WWDG specific features #####
<> 144:ef7eb2e8f9f7 16 ==============================================================================
<> 144:ef7eb2e8f9f7 17 [..]
<> 144:ef7eb2e8f9f7 18 Once enabled the WWDG generates a system reset on expiry of a programmed
<> 144:ef7eb2e8f9f7 19 time period, unless the program refreshes the counter (downcounter)
<> 144:ef7eb2e8f9f7 20 before reaching 0x3F value (i.e. a reset is generated when the counter
<> 144:ef7eb2e8f9f7 21 value rolls over from 0x40 to 0x3F).
<> 144:ef7eb2e8f9f7 22
<> 144:ef7eb2e8f9f7 23 (+) An MCU reset is also generated if the counter value is refreshed
<> 144:ef7eb2e8f9f7 24 before the counter has reached the refresh window value. This
<> 144:ef7eb2e8f9f7 25 implies that the counter must be refreshed in a limited window.
<> 144:ef7eb2e8f9f7 26 (+) Once enabled the WWDG cannot be disabled except by a system reset.
<> 144:ef7eb2e8f9f7 27 (+) WWDGRST flag in RCC_CSR register can be used to inform when a WWDG
<> 144:ef7eb2e8f9f7 28 reset occurs.
<> 144:ef7eb2e8f9f7 29 (+) The WWDG counter input clock is derived from the APB clock divided
<> 144:ef7eb2e8f9f7 30 by a programmable prescaler.
<> 144:ef7eb2e8f9f7 31 (+) WWDG clock (Hz) = PCLK1 / (4096 * Prescaler)
<> 144:ef7eb2e8f9f7 32 (+) WWDG timeout (mS) = 1000 * Counter / WWDG clock
<> 144:ef7eb2e8f9f7 33 (+) WWDG Counter refresh is allowed between the following limits :
<> 144:ef7eb2e8f9f7 34 (++) min time (mS) = 1000 * (Counter - Window) / WWDG clock
<> 144:ef7eb2e8f9f7 35 (++) max time (mS) = 1000 * (Counter - 0x40) / WWDG clock
<> 144:ef7eb2e8f9f7 36
<> 144:ef7eb2e8f9f7 37 (+) Min-max timeout value at @32MHz (PCLK1): ~128us / ~65.6ms.
<> 144:ef7eb2e8f9f7 38
<> 144:ef7eb2e8f9f7 39
<> 144:ef7eb2e8f9f7 40 ##### How to use this driver #####
<> 144:ef7eb2e8f9f7 41 ==============================================================================
<> 144:ef7eb2e8f9f7 42 [..]
<> 144:ef7eb2e8f9f7 43 (+) Enable WWDG APB1 clock using __HAL_RCC_WWDG_CLK_ENABLE().
<> 144:ef7eb2e8f9f7 44 (+) Set the WWDG prescaler, refresh window and counter value
<> 144:ef7eb2e8f9f7 45 using HAL_WWDG_Init() function.
<> 144:ef7eb2e8f9f7 46 (+) Start the WWDG using HAL_WWDG_Start() function.
<> 144:ef7eb2e8f9f7 47 When the WWDG is enabled the counter value should be configured to
<> 144:ef7eb2e8f9f7 48 a value greater than 0x40 to prevent generating an immediate reset.
<> 144:ef7eb2e8f9f7 49 (+) Optionally you can enable the Early Wakeup Interrupt (EWI) which is
<> 144:ef7eb2e8f9f7 50 generated when the counter reaches 0x40, and then start the WWDG using
<> 144:ef7eb2e8f9f7 51 HAL_WWDG_Start_IT(). At EWI HAL_WWDG_WakeupCallback is executed and user can
<> 144:ef7eb2e8f9f7 52 add his own code by customization of function pointer HAL_WWDG_WakeupCallback
<> 144:ef7eb2e8f9f7 53 Once enabled, EWI interrupt cannot be disabled except by a system reset.
<> 144:ef7eb2e8f9f7 54 (+) Then the application program must refresh the WWDG counter at regular
<> 144:ef7eb2e8f9f7 55 intervals during normal operation to prevent an MCU reset, using
<> 144:ef7eb2e8f9f7 56 HAL_WWDG_Refresh() function. This operation must occur only when
<> 144:ef7eb2e8f9f7 57 the counter is lower than the refresh window value already programmed.
<> 144:ef7eb2e8f9f7 58
<> 144:ef7eb2e8f9f7 59 *** WWDG HAL driver macros list ***
<> 144:ef7eb2e8f9f7 60 ==================================
<> 144:ef7eb2e8f9f7 61 [..]
<> 144:ef7eb2e8f9f7 62 Below the list of most used macros in WWDG HAL driver.
<> 144:ef7eb2e8f9f7 63
<> 144:ef7eb2e8f9f7 64 (+) __HAL_WWDG_ENABLE: Enable the WWDG peripheral
<> 144:ef7eb2e8f9f7 65 (+) __HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status
<> 144:ef7eb2e8f9f7 66 (+) __HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags
<> 144:ef7eb2e8f9f7 67 (+) __HAL_WWDG_ENABLE_IT: Enables the WWDG early wakeup interrupt
<> 144:ef7eb2e8f9f7 68
<> 144:ef7eb2e8f9f7 69 @endverbatim
<> 144:ef7eb2e8f9f7 70 ******************************************************************************
<> 144:ef7eb2e8f9f7 71 * @attention
<> 144:ef7eb2e8f9f7 72 *
<> 144:ef7eb2e8f9f7 73 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
<> 144:ef7eb2e8f9f7 74 *
<> 144:ef7eb2e8f9f7 75 * Redistribution and use in source and binary forms, with or without modification,
<> 144:ef7eb2e8f9f7 76 * are permitted provided that the following conditions are met:
<> 144:ef7eb2e8f9f7 77 * 1. Redistributions of source code must retain the above copyright notice,
<> 144:ef7eb2e8f9f7 78 * this list of conditions and the following disclaimer.
<> 144:ef7eb2e8f9f7 79 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 144:ef7eb2e8f9f7 80 * this list of conditions and the following disclaimer in the documentation
<> 144:ef7eb2e8f9f7 81 * and/or other materials provided with the distribution.
<> 144:ef7eb2e8f9f7 82 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 144:ef7eb2e8f9f7 83 * may be used to endorse or promote products derived from this software
<> 144:ef7eb2e8f9f7 84 * without specific prior written permission.
<> 144:ef7eb2e8f9f7 85 *
<> 144:ef7eb2e8f9f7 86 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 144:ef7eb2e8f9f7 87 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 144:ef7eb2e8f9f7 88 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 144:ef7eb2e8f9f7 89 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 144:ef7eb2e8f9f7 90 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 144:ef7eb2e8f9f7 91 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 144:ef7eb2e8f9f7 92 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 144:ef7eb2e8f9f7 93 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 144:ef7eb2e8f9f7 94 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 144:ef7eb2e8f9f7 95 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 144:ef7eb2e8f9f7 96 *
<> 144:ef7eb2e8f9f7 97 ******************************************************************************
<> 144:ef7eb2e8f9f7 98 */
<> 144:ef7eb2e8f9f7 99
<> 144:ef7eb2e8f9f7 100 /* Includes ------------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 101 #include "stm32l1xx_hal.h"
<> 144:ef7eb2e8f9f7 102
<> 144:ef7eb2e8f9f7 103 /** @addtogroup STM32L1xx_HAL_Driver
<> 144:ef7eb2e8f9f7 104 * @{
<> 144:ef7eb2e8f9f7 105 */
<> 144:ef7eb2e8f9f7 106
<> 144:ef7eb2e8f9f7 107 /** @defgroup WWDG WWDG
<> 144:ef7eb2e8f9f7 108 * @brief WWDG HAL module driver.
<> 144:ef7eb2e8f9f7 109 * @{
<> 144:ef7eb2e8f9f7 110 */
<> 144:ef7eb2e8f9f7 111
<> 144:ef7eb2e8f9f7 112 #ifdef HAL_WWDG_MODULE_ENABLED
<> 144:ef7eb2e8f9f7 113
<> 144:ef7eb2e8f9f7 114 /* Private typedef -----------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 115 /* Private define ------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 116 /* Private macro -------------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 117 /* Private variables ---------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 118 /* Private function prototypes -----------------------------------------------*/
<> 144:ef7eb2e8f9f7 119 /* Exported functions --------------------------------------------------------*/
<> 144:ef7eb2e8f9f7 120
<> 144:ef7eb2e8f9f7 121 /** @defgroup WWDG_Exported_Functions WWDG Exported Functions
<> 144:ef7eb2e8f9f7 122 * @{
<> 144:ef7eb2e8f9f7 123 */
<> 144:ef7eb2e8f9f7 124
<> 144:ef7eb2e8f9f7 125 /** @defgroup WWDG_Exported_Functions_Group1 Initialization and de-initialization functions
<> 144:ef7eb2e8f9f7 126 * @brief Initialization and Configuration functions.
<> 144:ef7eb2e8f9f7 127 *
<> 144:ef7eb2e8f9f7 128 @verbatim
<> 144:ef7eb2e8f9f7 129 ==============================================================================
<> 144:ef7eb2e8f9f7 130 ##### Initialization and de-initialization functions #####
<> 144:ef7eb2e8f9f7 131 ==============================================================================
<> 144:ef7eb2e8f9f7 132 [..]
<> 144:ef7eb2e8f9f7 133 This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 134 (+) Initialize the WWDG according to the specified parameters
<> 144:ef7eb2e8f9f7 135 in the WWDG_InitTypeDef and create the associated handle
<> 144:ef7eb2e8f9f7 136 (+) DeInitialize the WWDG peripheral
<> 144:ef7eb2e8f9f7 137 (+) Initialize the WWDG MSP
<> 144:ef7eb2e8f9f7 138 (+) DeInitialize the WWDG MSP
<> 144:ef7eb2e8f9f7 139
<> 144:ef7eb2e8f9f7 140 @endverbatim
<> 144:ef7eb2e8f9f7 141 * @{
<> 144:ef7eb2e8f9f7 142 */
<> 144:ef7eb2e8f9f7 143
<> 144:ef7eb2e8f9f7 144 /**
<> 144:ef7eb2e8f9f7 145 * @brief Initializes the WWDG according to the specified
<> 144:ef7eb2e8f9f7 146 * parameters in the WWDG_InitTypeDef and creates the associated handle.
<> 144:ef7eb2e8f9f7 147 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 148 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 149 * @retval HAL status
<> 144:ef7eb2e8f9f7 150 */
<> 144:ef7eb2e8f9f7 151 HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 152 {
<> 144:ef7eb2e8f9f7 153 /* Check the WWDG handle allocation */
<> 144:ef7eb2e8f9f7 154 if(hwwdg == NULL)
<> 144:ef7eb2e8f9f7 155 {
<> 144:ef7eb2e8f9f7 156 return HAL_ERROR;
<> 144:ef7eb2e8f9f7 157 }
<> 144:ef7eb2e8f9f7 158
<> 144:ef7eb2e8f9f7 159 /* Check the parameters */
<> 144:ef7eb2e8f9f7 160 assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
<> 144:ef7eb2e8f9f7 161 assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler));
<> 144:ef7eb2e8f9f7 162 assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window));
<> 144:ef7eb2e8f9f7 163 assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter));
<> 144:ef7eb2e8f9f7 164
<> 144:ef7eb2e8f9f7 165 if(hwwdg->State == HAL_WWDG_STATE_RESET)
<> 144:ef7eb2e8f9f7 166 {
<> 144:ef7eb2e8f9f7 167 /* Allocate lock resource and initialize it */
<> 144:ef7eb2e8f9f7 168 hwwdg->Lock = HAL_UNLOCKED;
<> 144:ef7eb2e8f9f7 169
<> 144:ef7eb2e8f9f7 170 /* Init the low level hardware */
<> 144:ef7eb2e8f9f7 171 HAL_WWDG_MspInit(hwwdg);
<> 144:ef7eb2e8f9f7 172 }
<> 144:ef7eb2e8f9f7 173
<> 144:ef7eb2e8f9f7 174 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 175 hwwdg->State = HAL_WWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 176
<> 144:ef7eb2e8f9f7 177 /* Set WWDG Prescaler and Window */
<> 144:ef7eb2e8f9f7 178 MODIFY_REG(hwwdg->Instance->CFR, (WWDG_CFR_WDGTB | WWDG_CFR_W), (hwwdg->Init.Prescaler | hwwdg->Init.Window));
<> 144:ef7eb2e8f9f7 179
<> 144:ef7eb2e8f9f7 180 /* Set WWDG Counter */
<> 144:ef7eb2e8f9f7 181 MODIFY_REG(hwwdg->Instance->CR, WWDG_CR_T, hwwdg->Init.Counter);
<> 144:ef7eb2e8f9f7 182
<> 144:ef7eb2e8f9f7 183 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 184 hwwdg->State = HAL_WWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 185
<> 144:ef7eb2e8f9f7 186 /* Return function status */
<> 144:ef7eb2e8f9f7 187 return HAL_OK;
<> 144:ef7eb2e8f9f7 188 }
<> 144:ef7eb2e8f9f7 189
<> 144:ef7eb2e8f9f7 190 /**
<> 144:ef7eb2e8f9f7 191 * @brief DeInitializes the WWDG peripheral.
<> 144:ef7eb2e8f9f7 192 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 193 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 194 * @retval HAL status
<> 144:ef7eb2e8f9f7 195 */
<> 144:ef7eb2e8f9f7 196 HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 197 {
<> 144:ef7eb2e8f9f7 198 /* Check the parameters */
<> 144:ef7eb2e8f9f7 199 assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
<> 144:ef7eb2e8f9f7 200
<> 144:ef7eb2e8f9f7 201 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 202 hwwdg->State = HAL_WWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 203
<> 144:ef7eb2e8f9f7 204 /* DeInit the low level hardware */
<> 144:ef7eb2e8f9f7 205 HAL_WWDG_MspDeInit(hwwdg);
<> 144:ef7eb2e8f9f7 206
<> 144:ef7eb2e8f9f7 207 /* Reset WWDG Control register */
<> 144:ef7eb2e8f9f7 208 hwwdg->Instance->CR = (uint32_t)0x0000007F;
<> 144:ef7eb2e8f9f7 209
<> 144:ef7eb2e8f9f7 210 /* Reset WWDG Configuration register */
<> 144:ef7eb2e8f9f7 211 hwwdg->Instance->CFR = (uint32_t)0x0000007F;
<> 144:ef7eb2e8f9f7 212
<> 144:ef7eb2e8f9f7 213 /* Reset WWDG Status register */
<> 144:ef7eb2e8f9f7 214 hwwdg->Instance->SR = 0;
<> 144:ef7eb2e8f9f7 215
<> 144:ef7eb2e8f9f7 216 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 217 hwwdg->State = HAL_WWDG_STATE_RESET;
<> 144:ef7eb2e8f9f7 218
<> 144:ef7eb2e8f9f7 219 /* Release Lock */
<> 144:ef7eb2e8f9f7 220 __HAL_UNLOCK(hwwdg);
<> 144:ef7eb2e8f9f7 221
<> 144:ef7eb2e8f9f7 222 /* Return function status */
<> 144:ef7eb2e8f9f7 223 return HAL_OK;
<> 144:ef7eb2e8f9f7 224 }
<> 144:ef7eb2e8f9f7 225
<> 144:ef7eb2e8f9f7 226 /**
<> 144:ef7eb2e8f9f7 227 * @brief Initializes the WWDG MSP.
<> 144:ef7eb2e8f9f7 228 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 229 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 230 * @retval None
<> 144:ef7eb2e8f9f7 231 */
<> 144:ef7eb2e8f9f7 232 __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 233 {
<> 144:ef7eb2e8f9f7 234 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 235 UNUSED(hwwdg);
<> 144:ef7eb2e8f9f7 236
<> 144:ef7eb2e8f9f7 237 /* NOTE: This function Should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 238 the HAL_WWDG_MspInit could be implemented in the user file
<> 144:ef7eb2e8f9f7 239 */
<> 144:ef7eb2e8f9f7 240 }
<> 144:ef7eb2e8f9f7 241
<> 144:ef7eb2e8f9f7 242 /**
<> 144:ef7eb2e8f9f7 243 * @brief DeInitializes the WWDG MSP.
<> 144:ef7eb2e8f9f7 244 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 245 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 246 * @retval None
<> 144:ef7eb2e8f9f7 247 */
<> 144:ef7eb2e8f9f7 248 __weak void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 249 {
<> 144:ef7eb2e8f9f7 250 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 251 UNUSED(hwwdg);
<> 144:ef7eb2e8f9f7 252
<> 144:ef7eb2e8f9f7 253 /* NOTE: This function Should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 254 the HAL_WWDG_MspDeInit could be implemented in the user file
<> 144:ef7eb2e8f9f7 255 */
<> 144:ef7eb2e8f9f7 256 }
<> 144:ef7eb2e8f9f7 257
<> 144:ef7eb2e8f9f7 258 /**
<> 144:ef7eb2e8f9f7 259 * @}
<> 144:ef7eb2e8f9f7 260 */
<> 144:ef7eb2e8f9f7 261
<> 144:ef7eb2e8f9f7 262 /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions
<> 144:ef7eb2e8f9f7 263 * @brief IO operation functions
<> 144:ef7eb2e8f9f7 264 *
<> 144:ef7eb2e8f9f7 265 @verbatim
<> 144:ef7eb2e8f9f7 266 ==============================================================================
<> 144:ef7eb2e8f9f7 267 ##### IO operation functions #####
<> 144:ef7eb2e8f9f7 268 ==============================================================================
<> 144:ef7eb2e8f9f7 269 [..]
<> 144:ef7eb2e8f9f7 270 This section provides functions allowing to:
<> 144:ef7eb2e8f9f7 271 (+) Start the WWDG.
<> 144:ef7eb2e8f9f7 272 (+) Refresh the WWDG.
<> 144:ef7eb2e8f9f7 273 (+) Handle WWDG interrupt request.
<> 144:ef7eb2e8f9f7 274
<> 144:ef7eb2e8f9f7 275 @endverbatim
<> 144:ef7eb2e8f9f7 276 * @{
<> 144:ef7eb2e8f9f7 277 */
<> 144:ef7eb2e8f9f7 278
<> 144:ef7eb2e8f9f7 279 /**
<> 144:ef7eb2e8f9f7 280 * @brief Starts the WWDG.
<> 144:ef7eb2e8f9f7 281 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 282 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 283 * @retval HAL status
<> 144:ef7eb2e8f9f7 284 */
<> 144:ef7eb2e8f9f7 285 HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 286 {
<> 144:ef7eb2e8f9f7 287 /* Process Locked */
<> 144:ef7eb2e8f9f7 288 __HAL_LOCK(hwwdg);
<> 144:ef7eb2e8f9f7 289
<> 144:ef7eb2e8f9f7 290 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 291 hwwdg->State = HAL_WWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 292
<> 144:ef7eb2e8f9f7 293 /* Enable the peripheral */
<> 144:ef7eb2e8f9f7 294 __HAL_WWDG_ENABLE(hwwdg);
<> 144:ef7eb2e8f9f7 295
<> 144:ef7eb2e8f9f7 296 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 297 hwwdg->State = HAL_WWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 298
<> 144:ef7eb2e8f9f7 299 /* Process Unlocked */
<> 144:ef7eb2e8f9f7 300 __HAL_UNLOCK(hwwdg);
<> 144:ef7eb2e8f9f7 301
<> 144:ef7eb2e8f9f7 302 /* Return function status */
<> 144:ef7eb2e8f9f7 303 return HAL_OK;
<> 144:ef7eb2e8f9f7 304 }
<> 144:ef7eb2e8f9f7 305
<> 144:ef7eb2e8f9f7 306 /**
<> 144:ef7eb2e8f9f7 307 * @brief Starts the WWDG with interrupt enabled.
<> 144:ef7eb2e8f9f7 308 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 309 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 310 * @retval HAL status
<> 144:ef7eb2e8f9f7 311 */
<> 144:ef7eb2e8f9f7 312 HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 313 {
<> 144:ef7eb2e8f9f7 314 /* Process Locked */
<> 144:ef7eb2e8f9f7 315 __HAL_LOCK(hwwdg);
<> 144:ef7eb2e8f9f7 316
<> 144:ef7eb2e8f9f7 317 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 318 hwwdg->State = HAL_WWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 319
<> 144:ef7eb2e8f9f7 320 /* Enable the Early Wakeup Interrupt */
<> 144:ef7eb2e8f9f7 321 __HAL_WWDG_ENABLE_IT(hwwdg, WWDG_IT_EWI);
<> 144:ef7eb2e8f9f7 322
<> 144:ef7eb2e8f9f7 323 /* Enable the peripheral */
<> 144:ef7eb2e8f9f7 324 __HAL_WWDG_ENABLE(hwwdg);
<> 144:ef7eb2e8f9f7 325
<> 144:ef7eb2e8f9f7 326 /* Return function status */
<> 144:ef7eb2e8f9f7 327 return HAL_OK;
<> 144:ef7eb2e8f9f7 328 }
<> 144:ef7eb2e8f9f7 329
<> 144:ef7eb2e8f9f7 330 /**
<> 144:ef7eb2e8f9f7 331 * @brief Refreshes the WWDG.
<> 144:ef7eb2e8f9f7 332 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 333 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 334 * @param Counter: value of counter to put in WWDG counter
<> 144:ef7eb2e8f9f7 335 * @retval HAL status
<> 144:ef7eb2e8f9f7 336 */
<> 144:ef7eb2e8f9f7 337 HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter)
<> 144:ef7eb2e8f9f7 338 {
<> 144:ef7eb2e8f9f7 339 /* Process Locked */
<> 144:ef7eb2e8f9f7 340 __HAL_LOCK(hwwdg);
<> 144:ef7eb2e8f9f7 341
<> 144:ef7eb2e8f9f7 342 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 343 hwwdg->State = HAL_WWDG_STATE_BUSY;
<> 144:ef7eb2e8f9f7 344
<> 144:ef7eb2e8f9f7 345 /* Check the parameters */
<> 144:ef7eb2e8f9f7 346 assert_param(IS_WWDG_COUNTER(Counter));
<> 144:ef7eb2e8f9f7 347
<> 144:ef7eb2e8f9f7 348 /* Write to WWDG CR the WWDG Counter value to refresh with */
<> 144:ef7eb2e8f9f7 349 MODIFY_REG(hwwdg->Instance->CR, (uint32_t)WWDG_CR_T, Counter);
<> 144:ef7eb2e8f9f7 350
<> 144:ef7eb2e8f9f7 351 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 352 hwwdg->State = HAL_WWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 353
<> 144:ef7eb2e8f9f7 354 /* Process Unlocked */
<> 144:ef7eb2e8f9f7 355 __HAL_UNLOCK(hwwdg);
<> 144:ef7eb2e8f9f7 356
<> 144:ef7eb2e8f9f7 357 /* Return function status */
<> 144:ef7eb2e8f9f7 358 return HAL_OK;
<> 144:ef7eb2e8f9f7 359 }
<> 144:ef7eb2e8f9f7 360
<> 144:ef7eb2e8f9f7 361 /**
<> 144:ef7eb2e8f9f7 362 * @brief Handles WWDG interrupt request.
<> 144:ef7eb2e8f9f7 363 * @note The Early Wakeup Interrupt (EWI) can be used if specific safety operations
<> 144:ef7eb2e8f9f7 364 * or data logging must be performed before the actual reset is generated.
<> 144:ef7eb2e8f9f7 365 * The EWI interrupt is enabled when calling HAL_WWDG_Start_IT function.
<> 144:ef7eb2e8f9f7 366 * When the downcounter reaches the value 0x40, and EWI interrupt is
<> 144:ef7eb2e8f9f7 367 * generated and the corresponding Interrupt Service Routine (ISR) can
<> 144:ef7eb2e8f9f7 368 * be used to trigger specific actions (such as communications or data
<> 144:ef7eb2e8f9f7 369 * logging), before resetting the device.
<> 144:ef7eb2e8f9f7 370 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 371 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 372 * @retval None
<> 144:ef7eb2e8f9f7 373 */
<> 144:ef7eb2e8f9f7 374 void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 375 {
<> 144:ef7eb2e8f9f7 376 /* Check if Early Wakeup Interrupt is enable */
<> 144:ef7eb2e8f9f7 377 if(__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET)
<> 144:ef7eb2e8f9f7 378 {
<> 144:ef7eb2e8f9f7 379 /* Wheck if WWDG Early Wakeup Interrupt occurred */
<> 144:ef7eb2e8f9f7 380 if(__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET)
<> 144:ef7eb2e8f9f7 381 {
<> 144:ef7eb2e8f9f7 382 /* Early Wakeup callback */
<> 144:ef7eb2e8f9f7 383 HAL_WWDG_WakeupCallback(hwwdg);
<> 144:ef7eb2e8f9f7 384
<> 144:ef7eb2e8f9f7 385 /* Change WWDG peripheral state */
<> 144:ef7eb2e8f9f7 386 hwwdg->State = HAL_WWDG_STATE_READY;
<> 144:ef7eb2e8f9f7 387
<> 144:ef7eb2e8f9f7 388 /* Clear the WWDG Early Wakeup flag */
<> 144:ef7eb2e8f9f7 389 __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF);
<> 144:ef7eb2e8f9f7 390
<> 144:ef7eb2e8f9f7 391 /* Process Unlocked */
<> 144:ef7eb2e8f9f7 392 __HAL_UNLOCK(hwwdg);
<> 144:ef7eb2e8f9f7 393 }
<> 144:ef7eb2e8f9f7 394 }
<> 144:ef7eb2e8f9f7 395 }
<> 144:ef7eb2e8f9f7 396
<> 144:ef7eb2e8f9f7 397 /**
<> 144:ef7eb2e8f9f7 398 * @brief Early Wakeup WWDG callback.
<> 144:ef7eb2e8f9f7 399 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 400 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 401 * @retval None
<> 144:ef7eb2e8f9f7 402 */
<> 144:ef7eb2e8f9f7 403 __weak void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg)
<> 144:ef7eb2e8f9f7 404 {
<> 144:ef7eb2e8f9f7 405 /* Prevent unused argument(s) compilation warning */
<> 144:ef7eb2e8f9f7 406 UNUSED(hwwdg);
<> 144:ef7eb2e8f9f7 407
<> 144:ef7eb2e8f9f7 408 /* NOTE: This function Should not be modified, when the callback is needed,
<> 144:ef7eb2e8f9f7 409 the HAL_WWDG_WakeupCallback could be implemented in the user file
<> 144:ef7eb2e8f9f7 410 */
<> 144:ef7eb2e8f9f7 411 }
<> 144:ef7eb2e8f9f7 412
<> 144:ef7eb2e8f9f7 413 /**
<> 144:ef7eb2e8f9f7 414 * @}
<> 144:ef7eb2e8f9f7 415 */
<> 144:ef7eb2e8f9f7 416
<> 144:ef7eb2e8f9f7 417 /** @defgroup WWDG_Exported_Functions_Group3 Peripheral State functions
<> 144:ef7eb2e8f9f7 418 * @brief Peripheral State functions.
<> 144:ef7eb2e8f9f7 419 *
<> 144:ef7eb2e8f9f7 420 @verbatim
<> 144:ef7eb2e8f9f7 421 ==============================================================================
<> 144:ef7eb2e8f9f7 422 ##### Peripheral State functions #####
<> 144:ef7eb2e8f9f7 423 ==============================================================================
<> 144:ef7eb2e8f9f7 424 [..]
<> 144:ef7eb2e8f9f7 425 This subsection permits to get in run-time the status of the peripheral
<> 144:ef7eb2e8f9f7 426 and the data flow.
<> 144:ef7eb2e8f9f7 427
<> 144:ef7eb2e8f9f7 428 @endverbatim
<> 144:ef7eb2e8f9f7 429 * @{
<> 144:ef7eb2e8f9f7 430 */
<> 144:ef7eb2e8f9f7 431
<> 144:ef7eb2e8f9f7 432 /**
<> 144:ef7eb2e8f9f7 433 * @brief Returns the WWDG state.
<> 144:ef7eb2e8f9f7 434 * @param hwwdg: pointer to a WWDG_HandleTypeDef structure that contains
<> 144:ef7eb2e8f9f7 435 * the configuration information for the specified WWDG module.
<> 144:ef7eb2e8f9f7 436 * @retval HAL state
<> 144:ef7eb2e8f9f7 437 */
<> 144:ef7eb2e8f9f7 438 HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg)
<> 144:ef7eb2e8f9f7 439 {
<> 144:ef7eb2e8f9f7 440 return hwwdg->State;
<> 144:ef7eb2e8f9f7 441 }
<> 144:ef7eb2e8f9f7 442
<> 144:ef7eb2e8f9f7 443 /**
<> 144:ef7eb2e8f9f7 444 * @}
<> 144:ef7eb2e8f9f7 445 */
<> 144:ef7eb2e8f9f7 446
<> 144:ef7eb2e8f9f7 447 /**
<> 144:ef7eb2e8f9f7 448 * @}
<> 144:ef7eb2e8f9f7 449 */
<> 144:ef7eb2e8f9f7 450
<> 144:ef7eb2e8f9f7 451 #endif /* HAL_WWDG_MODULE_ENABLED */
<> 144:ef7eb2e8f9f7 452 /**
<> 144:ef7eb2e8f9f7 453 * @}
<> 144:ef7eb2e8f9f7 454 */
<> 144:ef7eb2e8f9f7 455
<> 144:ef7eb2e8f9f7 456 /**
<> 144:ef7eb2e8f9f7 457 * @}
<> 144:ef7eb2e8f9f7 458 */
<> 144:ef7eb2e8f9f7 459
<> 144:ef7eb2e8f9f7 460 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/