mbed library sources. Supersedes mbed-src.

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

Committer:
<>
Date:
Wed Jan 04 16:58:05 2017 +0000
Revision:
154:37f96f9d4de2
Parent:
149:156823d33999
Child:
165:e614a9f1c9e2
This updates the lib to the mbed lib v133

Who changed what in which revision?

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