Iftikhar Aziz / mbed-dev

Dependents:   LSS_Rev_1

Fork of mbed-dev by Umar Naeem

Committer:
mbed_official
Date:
Mon May 09 18:30:12 2016 +0100
Revision:
124:6a4a5b7d7324
Parent:
0:9b334a45a8ff
Child:
144:ef7eb2e8f9f7
Synchronized with git revision ad75bdcde34d7da9d54b7669010c7fb968a99c7c

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

[STMF1] Stm32f1_hal_cube update

Who changed what in which revision?

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