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:
Thu Jul 02 16:30:08 2015 +0100
Revision:
581:39197bcd20f2
Parent:
489:119543c9f674
Synchronized with git revision ae2d3cdffe70184eb8736d94f76c45c93f4b7724

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

Make it possible to build the core mbed library with yotta

Who changed what in which revision?

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