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