inport from local
Dependents: Hobbyking_Cheetah_0511
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_wwdg.c@0:85b3fd62ea1a, 2020-03-16 (annotated)
- Committer:
- NYX
- Date:
- Mon Mar 16 06:35:48 2020 +0000
- Revision:
- 0:85b3fd62ea1a
reinport to mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NYX | 0:85b3fd62ea1a | 1 | /** |
NYX | 0:85b3fd62ea1a | 2 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 3 | * @file stm32f4xx_hal_wwdg.c |
NYX | 0:85b3fd62ea1a | 4 | * @author MCD Application Team |
NYX | 0:85b3fd62ea1a | 5 | * @version V1.7.1 |
NYX | 0:85b3fd62ea1a | 6 | * @date 14-April-2017 |
NYX | 0:85b3fd62ea1a | 7 | * @brief WWDG HAL module driver. |
NYX | 0:85b3fd62ea1a | 8 | * This file provides firmware functions to manage the following |
NYX | 0:85b3fd62ea1a | 9 | * functionalities of the Window Watchdog (WWDG) peripheral: |
NYX | 0:85b3fd62ea1a | 10 | * + Initialization and de-initialization functions |
NYX | 0:85b3fd62ea1a | 11 | * + IO operation functions |
NYX | 0:85b3fd62ea1a | 12 | * + Peripheral State functions |
NYX | 0:85b3fd62ea1a | 13 | @verbatim |
NYX | 0:85b3fd62ea1a | 14 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 15 | ##### WWDG specific features ##### |
NYX | 0:85b3fd62ea1a | 16 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 17 | [..] |
NYX | 0:85b3fd62ea1a | 18 | Once enabled the WWDG generates a system reset on expiry of a programmed |
NYX | 0:85b3fd62ea1a | 19 | time period, unless the program refreshes the counter (downcounter) |
NYX | 0:85b3fd62ea1a | 20 | before reaching 0x3F value (i.e. a reset is generated when the counter |
NYX | 0:85b3fd62ea1a | 21 | value rolls over from 0x40 to 0x3F). |
NYX | 0:85b3fd62ea1a | 22 | |
NYX | 0:85b3fd62ea1a | 23 | (+) An MCU reset is also generated if the counter value is refreshed |
NYX | 0:85b3fd62ea1a | 24 | before the counter has reached the refresh window value. This |
NYX | 0:85b3fd62ea1a | 25 | implies that the counter must be refreshed in a limited window. |
NYX | 0:85b3fd62ea1a | 26 | (+) Once enabled the WWDG cannot be disabled except by a system reset. |
NYX | 0:85b3fd62ea1a | 27 | (+) WWDGRST flag in RCC_CSR register can be used to inform when a WWDG |
NYX | 0:85b3fd62ea1a | 28 | reset occurs. |
NYX | 0:85b3fd62ea1a | 29 | (+) The WWDG counter input clock is derived from the APB clock divided |
NYX | 0:85b3fd62ea1a | 30 | by a programmable prescaler. |
NYX | 0:85b3fd62ea1a | 31 | (+) WWDG clock (Hz) = PCLK1 / (4096 * Prescaler) |
NYX | 0:85b3fd62ea1a | 32 | (+) WWDG timeout (mS) = 1000 * Counter / WWDG clock |
NYX | 0:85b3fd62ea1a | 33 | (+) WWDG Counter refresh is allowed between the following limits : |
NYX | 0:85b3fd62ea1a | 34 | (++) min time (mS) = 1000 * (Counter _ Window) / WWDG clock |
NYX | 0:85b3fd62ea1a | 35 | (++) max time (mS) = 1000 * (Counter _ 0x40) / WWDG clock |
NYX | 0:85b3fd62ea1a | 36 | |
NYX | 0:85b3fd62ea1a | 37 | (+) Min-max timeout value at 50 MHz(PCLK1): 81.9 us / 41.9 ms |
NYX | 0:85b3fd62ea1a | 38 | |
NYX | 0:85b3fd62ea1a | 39 | (+) The Early Wakeup Interrupt (EWI) can be used if specific safety |
NYX | 0:85b3fd62ea1a | 40 | operations or data logging must be performed before the actual reset is |
NYX | 0:85b3fd62ea1a | 41 | generated. When the downcounter reaches the value 0x40, an EWI interrupt |
NYX | 0:85b3fd62ea1a | 42 | is generated and the corresponding interrupt service routine (ISR) can |
NYX | 0:85b3fd62ea1a | 43 | be used to trigger specific actions (such as communications or data |
NYX | 0:85b3fd62ea1a | 44 | logging), before resetting the device. |
NYX | 0:85b3fd62ea1a | 45 | In some applications, the EWI interrupt can be used to manage a software |
NYX | 0:85b3fd62ea1a | 46 | system check and/or system recovery/graceful degradation, without |
NYX | 0:85b3fd62ea1a | 47 | generating a WWDG reset. In this case, the corresponding interrupt |
NYX | 0:85b3fd62ea1a | 48 | service routine (ISR) should reload the WWDG counter to avoid the WWDG |
NYX | 0:85b3fd62ea1a | 49 | reset, then trigger the required actions. |
NYX | 0:85b3fd62ea1a | 50 | Note:When the EWI interrupt cannot be served, e.g. due to a system lock |
NYX | 0:85b3fd62ea1a | 51 | in a higher priority task, the WWDG reset will eventually be generated. |
NYX | 0:85b3fd62ea1a | 52 | |
NYX | 0:85b3fd62ea1a | 53 | (+) Debug mode : When the microcontroller enters debug mode (core halted), |
NYX | 0:85b3fd62ea1a | 54 | the WWDG counter either continues to work normally or stops, depending |
NYX | 0:85b3fd62ea1a | 55 | on DBG_WWDG_STOP configuration bit in DBG module, accessible through |
NYX | 0:85b3fd62ea1a | 56 | __HAL_DBGMCU_FREEZE_WWDG() and __HAL_DBGMCU_UNFREEZE_WWDG() macros |
NYX | 0:85b3fd62ea1a | 57 | |
NYX | 0:85b3fd62ea1a | 58 | ##### How to use this driver ##### |
NYX | 0:85b3fd62ea1a | 59 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 60 | [..] |
NYX | 0:85b3fd62ea1a | 61 | (+) Enable WWDG APB1 clock using __HAL_RCC_WWDG_CLK_ENABLE(). |
NYX | 0:85b3fd62ea1a | 62 | |
NYX | 0:85b3fd62ea1a | 63 | (+) Set the WWDG prescaler, refresh window, counter value and Early Wakeup |
NYX | 0:85b3fd62ea1a | 64 | Interrupt mode using using HAL_WWDG_Init() function. |
NYX | 0:85b3fd62ea1a | 65 | This enables WWDG peripheral and the downcounter starts downcounting |
NYX | 0:85b3fd62ea1a | 66 | from given counter value. |
NYX | 0:85b3fd62ea1a | 67 | Init function can be called again to modify all watchdog parameters, |
NYX | 0:85b3fd62ea1a | 68 | however if EWI mode has been set once, it can't be clear until next |
NYX | 0:85b3fd62ea1a | 69 | reset. |
NYX | 0:85b3fd62ea1a | 70 | |
NYX | 0:85b3fd62ea1a | 71 | (+) The application program must refresh the WWDG counter at regular |
NYX | 0:85b3fd62ea1a | 72 | intervals during normal operation to prevent an MCU reset using |
NYX | 0:85b3fd62ea1a | 73 | HAL_WWDG_Refresh() function. This operation must occur only when |
NYX | 0:85b3fd62ea1a | 74 | the counter is lower than the window value already programmed. |
NYX | 0:85b3fd62ea1a | 75 | |
NYX | 0:85b3fd62ea1a | 76 | (+) if Early Wakeup Interrupt mode is enable an interrupt is generated when |
NYX | 0:85b3fd62ea1a | 77 | the counter reaches 0x40. User can add his own code in weak function |
NYX | 0:85b3fd62ea1a | 78 | HAL_WWDG_EarlyWakeupCallback(). |
NYX | 0:85b3fd62ea1a | 79 | |
NYX | 0:85b3fd62ea1a | 80 | *** WWDG HAL driver macros list *** |
NYX | 0:85b3fd62ea1a | 81 | ================================== |
NYX | 0:85b3fd62ea1a | 82 | [..] |
NYX | 0:85b3fd62ea1a | 83 | Below the list of most used macros in WWDG HAL driver. |
NYX | 0:85b3fd62ea1a | 84 | |
NYX | 0:85b3fd62ea1a | 85 | (+) __HAL_WWDG_GET_IT_SOURCE: Check the selected WWDG's interrupt source. |
NYX | 0:85b3fd62ea1a | 86 | (+) __HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status. |
NYX | 0:85b3fd62ea1a | 87 | (+) __HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags. |
NYX | 0:85b3fd62ea1a | 88 | |
NYX | 0:85b3fd62ea1a | 89 | @endverbatim |
NYX | 0:85b3fd62ea1a | 90 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 91 | * @attention |
NYX | 0:85b3fd62ea1a | 92 | * |
NYX | 0:85b3fd62ea1a | 93 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
NYX | 0:85b3fd62ea1a | 94 | * |
NYX | 0:85b3fd62ea1a | 95 | * Redistribution and use in source and binary forms, with or without modification, |
NYX | 0:85b3fd62ea1a | 96 | * are permitted provided that the following conditions are met: |
NYX | 0:85b3fd62ea1a | 97 | * 1. Redistributions of source code must retain the above copyright notice, |
NYX | 0:85b3fd62ea1a | 98 | * this list of conditions and the following disclaimer. |
NYX | 0:85b3fd62ea1a | 99 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NYX | 0:85b3fd62ea1a | 100 | * this list of conditions and the following disclaimer in the documentation |
NYX | 0:85b3fd62ea1a | 101 | * and/or other materials provided with the distribution. |
NYX | 0:85b3fd62ea1a | 102 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NYX | 0:85b3fd62ea1a | 103 | * may be used to endorse or promote products derived from this software |
NYX | 0:85b3fd62ea1a | 104 | * without specific prior written permission. |
NYX | 0:85b3fd62ea1a | 105 | * |
NYX | 0:85b3fd62ea1a | 106 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NYX | 0:85b3fd62ea1a | 107 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NYX | 0:85b3fd62ea1a | 108 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NYX | 0:85b3fd62ea1a | 109 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NYX | 0:85b3fd62ea1a | 110 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NYX | 0:85b3fd62ea1a | 111 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NYX | 0:85b3fd62ea1a | 112 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NYX | 0:85b3fd62ea1a | 113 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NYX | 0:85b3fd62ea1a | 114 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NYX | 0:85b3fd62ea1a | 115 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NYX | 0:85b3fd62ea1a | 116 | * |
NYX | 0:85b3fd62ea1a | 117 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 118 | */ |
NYX | 0:85b3fd62ea1a | 119 | |
NYX | 0:85b3fd62ea1a | 120 | /* Includes ------------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 121 | #include "stm32f4xx_hal.h" |
NYX | 0:85b3fd62ea1a | 122 | |
NYX | 0:85b3fd62ea1a | 123 | /** @addtogroup STM32F4xx_HAL_Driver |
NYX | 0:85b3fd62ea1a | 124 | * @{ |
NYX | 0:85b3fd62ea1a | 125 | */ |
NYX | 0:85b3fd62ea1a | 126 | |
NYX | 0:85b3fd62ea1a | 127 | #ifdef HAL_WWDG_MODULE_ENABLED |
NYX | 0:85b3fd62ea1a | 128 | /** @defgroup WWDG WWDG |
NYX | 0:85b3fd62ea1a | 129 | * @brief WWDG HAL module driver. |
NYX | 0:85b3fd62ea1a | 130 | * @{ |
NYX | 0:85b3fd62ea1a | 131 | */ |
NYX | 0:85b3fd62ea1a | 132 | |
NYX | 0:85b3fd62ea1a | 133 | /* Private typedef -----------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 134 | /* Private define ------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 135 | /* Private macro -------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 136 | /* Private variables ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 137 | /* Private function prototypes -----------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 138 | /* Exported functions --------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 139 | |
NYX | 0:85b3fd62ea1a | 140 | /** @defgroup WWDG_Exported_Functions WWDG Exported Functions |
NYX | 0:85b3fd62ea1a | 141 | * @{ |
NYX | 0:85b3fd62ea1a | 142 | */ |
NYX | 0:85b3fd62ea1a | 143 | |
NYX | 0:85b3fd62ea1a | 144 | /** @defgroup WWDG_Exported_Functions_Group1 Initialization and Configuration functions |
NYX | 0:85b3fd62ea1a | 145 | * @brief Initialization and Configuration functions. |
NYX | 0:85b3fd62ea1a | 146 | * |
NYX | 0:85b3fd62ea1a | 147 | @verbatim |
NYX | 0:85b3fd62ea1a | 148 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 149 | ##### Initialization and Configuration functions ##### |
NYX | 0:85b3fd62ea1a | 150 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 151 | [..] |
NYX | 0:85b3fd62ea1a | 152 | This section provides functions allowing to: |
NYX | 0:85b3fd62ea1a | 153 | (+) Initialize and start the WWDG according to the specified parameters |
NYX | 0:85b3fd62ea1a | 154 | in the WWDG_InitTypeDef of associated handle. |
NYX | 0:85b3fd62ea1a | 155 | (+) Initialize the WWDG MSP. |
NYX | 0:85b3fd62ea1a | 156 | |
NYX | 0:85b3fd62ea1a | 157 | @endverbatim |
NYX | 0:85b3fd62ea1a | 158 | * @{ |
NYX | 0:85b3fd62ea1a | 159 | */ |
NYX | 0:85b3fd62ea1a | 160 | |
NYX | 0:85b3fd62ea1a | 161 | /** |
NYX | 0:85b3fd62ea1a | 162 | * @brief Initialize the WWDG according to the specified. |
NYX | 0:85b3fd62ea1a | 163 | * parameters in the WWDG_InitTypeDef of associated handle. |
NYX | 0:85b3fd62ea1a | 164 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 165 | * the configuration information for the specified WWDG module. |
NYX | 0:85b3fd62ea1a | 166 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 167 | */ |
NYX | 0:85b3fd62ea1a | 168 | HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg) |
NYX | 0:85b3fd62ea1a | 169 | { |
NYX | 0:85b3fd62ea1a | 170 | /* Check the WWDG handle allocation */ |
NYX | 0:85b3fd62ea1a | 171 | if(hwwdg == NULL) |
NYX | 0:85b3fd62ea1a | 172 | { |
NYX | 0:85b3fd62ea1a | 173 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 174 | } |
NYX | 0:85b3fd62ea1a | 175 | |
NYX | 0:85b3fd62ea1a | 176 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 177 | assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); |
NYX | 0:85b3fd62ea1a | 178 | assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler)); |
NYX | 0:85b3fd62ea1a | 179 | assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window)); |
NYX | 0:85b3fd62ea1a | 180 | assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter)); |
NYX | 0:85b3fd62ea1a | 181 | assert_param(IS_WWDG_EWI_MODE(hwwdg->Init.EWIMode)); |
NYX | 0:85b3fd62ea1a | 182 | |
NYX | 0:85b3fd62ea1a | 183 | /* Init the low level hardware */ |
NYX | 0:85b3fd62ea1a | 184 | HAL_WWDG_MspInit(hwwdg); |
NYX | 0:85b3fd62ea1a | 185 | |
NYX | 0:85b3fd62ea1a | 186 | /* Set WWDG Counter */ |
NYX | 0:85b3fd62ea1a | 187 | WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter)); |
NYX | 0:85b3fd62ea1a | 188 | |
NYX | 0:85b3fd62ea1a | 189 | /* Set WWDG Prescaler and Window */ |
NYX | 0:85b3fd62ea1a | 190 | WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window)); |
NYX | 0:85b3fd62ea1a | 191 | |
NYX | 0:85b3fd62ea1a | 192 | /* Return function status */ |
NYX | 0:85b3fd62ea1a | 193 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 194 | } |
NYX | 0:85b3fd62ea1a | 195 | |
NYX | 0:85b3fd62ea1a | 196 | /** |
NYX | 0:85b3fd62ea1a | 197 | * @brief Initialize the WWDG MSP. |
NYX | 0:85b3fd62ea1a | 198 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 199 | * the configuration information for the specified WWDG module. |
NYX | 0:85b3fd62ea1a | 200 | * @note When rewriting this function in user file, mechanism may be added |
NYX | 0:85b3fd62ea1a | 201 | * to avoid multiple initialize when HAL_WWDG_Init function is called |
NYX | 0:85b3fd62ea1a | 202 | * again to change parameters. |
NYX | 0:85b3fd62ea1a | 203 | * @retval None |
NYX | 0:85b3fd62ea1a | 204 | */ |
NYX | 0:85b3fd62ea1a | 205 | __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg) |
NYX | 0:85b3fd62ea1a | 206 | { |
NYX | 0:85b3fd62ea1a | 207 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 208 | UNUSED(hwwdg); |
NYX | 0:85b3fd62ea1a | 209 | |
NYX | 0:85b3fd62ea1a | 210 | /* NOTE: This function should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 211 | the HAL_WWDG_MspInit could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 212 | */ |
NYX | 0:85b3fd62ea1a | 213 | } |
NYX | 0:85b3fd62ea1a | 214 | |
NYX | 0:85b3fd62ea1a | 215 | /** |
NYX | 0:85b3fd62ea1a | 216 | * @} |
NYX | 0:85b3fd62ea1a | 217 | */ |
NYX | 0:85b3fd62ea1a | 218 | |
NYX | 0:85b3fd62ea1a | 219 | /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions |
NYX | 0:85b3fd62ea1a | 220 | * @brief IO operation functions |
NYX | 0:85b3fd62ea1a | 221 | * |
NYX | 0:85b3fd62ea1a | 222 | @verbatim |
NYX | 0:85b3fd62ea1a | 223 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 224 | ##### IO operation functions ##### |
NYX | 0:85b3fd62ea1a | 225 | ============================================================================== |
NYX | 0:85b3fd62ea1a | 226 | [..] |
NYX | 0:85b3fd62ea1a | 227 | This section provides functions allowing to: |
NYX | 0:85b3fd62ea1a | 228 | (+) Refresh the WWDG. |
NYX | 0:85b3fd62ea1a | 229 | (+) Handle WWDG interrupt request and associated function callback. |
NYX | 0:85b3fd62ea1a | 230 | |
NYX | 0:85b3fd62ea1a | 231 | @endverbatim |
NYX | 0:85b3fd62ea1a | 232 | * @{ |
NYX | 0:85b3fd62ea1a | 233 | */ |
NYX | 0:85b3fd62ea1a | 234 | |
NYX | 0:85b3fd62ea1a | 235 | /** |
NYX | 0:85b3fd62ea1a | 236 | * @brief Refresh the WWDG. |
NYX | 0:85b3fd62ea1a | 237 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 238 | * the configuration information for the specified WWDG module. |
NYX | 0:85b3fd62ea1a | 239 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 240 | */ |
NYX | 0:85b3fd62ea1a | 241 | HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg) |
NYX | 0:85b3fd62ea1a | 242 | { |
NYX | 0:85b3fd62ea1a | 243 | /* Write to WWDG CR the WWDG Counter value to refresh with */ |
NYX | 0:85b3fd62ea1a | 244 | WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter)); |
NYX | 0:85b3fd62ea1a | 245 | |
NYX | 0:85b3fd62ea1a | 246 | /* Return function status */ |
NYX | 0:85b3fd62ea1a | 247 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 248 | } |
NYX | 0:85b3fd62ea1a | 249 | |
NYX | 0:85b3fd62ea1a | 250 | /** |
NYX | 0:85b3fd62ea1a | 251 | * @brief Handle WWDG interrupt request. |
NYX | 0:85b3fd62ea1a | 252 | * @note The Early Wakeup Interrupt (EWI) can be used if specific safety operations |
NYX | 0:85b3fd62ea1a | 253 | * or data logging must be performed before the actual reset is generated. |
NYX | 0:85b3fd62ea1a | 254 | * The EWI interrupt is enabled by calling HAL_WWDG_Init function with |
NYX | 0:85b3fd62ea1a | 255 | * EWIMode set to WWDG_EWI_ENABLE. |
NYX | 0:85b3fd62ea1a | 256 | * When the downcounter reaches the value 0x40, and EWI interrupt is |
NYX | 0:85b3fd62ea1a | 257 | * generated and the corresponding Interrupt Service Routine (ISR) can |
NYX | 0:85b3fd62ea1a | 258 | * be used to trigger specific actions (such as communications or data |
NYX | 0:85b3fd62ea1a | 259 | * logging), before resetting the device. |
NYX | 0:85b3fd62ea1a | 260 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 261 | * the configuration information for the specified WWDG module. |
NYX | 0:85b3fd62ea1a | 262 | * @retval None |
NYX | 0:85b3fd62ea1a | 263 | */ |
NYX | 0:85b3fd62ea1a | 264 | void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg) |
NYX | 0:85b3fd62ea1a | 265 | { |
NYX | 0:85b3fd62ea1a | 266 | /* Check if Early Wakeup Interrupt is enable */ |
NYX | 0:85b3fd62ea1a | 267 | if(__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET) |
NYX | 0:85b3fd62ea1a | 268 | { |
NYX | 0:85b3fd62ea1a | 269 | /* Check if WWDG Early Wakeup Interrupt occurred */ |
NYX | 0:85b3fd62ea1a | 270 | if(__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET) |
NYX | 0:85b3fd62ea1a | 271 | { |
NYX | 0:85b3fd62ea1a | 272 | /* Clear the WWDG Early Wakeup flag */ |
NYX | 0:85b3fd62ea1a | 273 | __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF); |
NYX | 0:85b3fd62ea1a | 274 | |
NYX | 0:85b3fd62ea1a | 275 | /* Early Wakeup callback */ |
NYX | 0:85b3fd62ea1a | 276 | HAL_WWDG_EarlyWakeupCallback(hwwdg); |
NYX | 0:85b3fd62ea1a | 277 | } |
NYX | 0:85b3fd62ea1a | 278 | } |
NYX | 0:85b3fd62ea1a | 279 | } |
NYX | 0:85b3fd62ea1a | 280 | |
NYX | 0:85b3fd62ea1a | 281 | /** |
NYX | 0:85b3fd62ea1a | 282 | * @brief WWDG Early Wakeup callback. |
NYX | 0:85b3fd62ea1a | 283 | * @param hwwdg : pointer to a WWDG_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 284 | * the configuration information for the specified WWDG module. |
NYX | 0:85b3fd62ea1a | 285 | * @retval None |
NYX | 0:85b3fd62ea1a | 286 | */ |
NYX | 0:85b3fd62ea1a | 287 | __weak void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef* hwwdg) |
NYX | 0:85b3fd62ea1a | 288 | { |
NYX | 0:85b3fd62ea1a | 289 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 290 | UNUSED(hwwdg); |
NYX | 0:85b3fd62ea1a | 291 | |
NYX | 0:85b3fd62ea1a | 292 | /* NOTE: This function should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 293 | the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 294 | */ |
NYX | 0:85b3fd62ea1a | 295 | } |
NYX | 0:85b3fd62ea1a | 296 | |
NYX | 0:85b3fd62ea1a | 297 | /** |
NYX | 0:85b3fd62ea1a | 298 | * @} |
NYX | 0:85b3fd62ea1a | 299 | */ |
NYX | 0:85b3fd62ea1a | 300 | |
NYX | 0:85b3fd62ea1a | 301 | /** |
NYX | 0:85b3fd62ea1a | 302 | * @} |
NYX | 0:85b3fd62ea1a | 303 | */ |
NYX | 0:85b3fd62ea1a | 304 | |
NYX | 0:85b3fd62ea1a | 305 | #endif /* HAL_WWDG_MODULE_ENABLED */ |
NYX | 0:85b3fd62ea1a | 306 | /** |
NYX | 0:85b3fd62ea1a | 307 | * @} |
NYX | 0:85b3fd62ea1a | 308 | */ |
NYX | 0:85b3fd62ea1a | 309 | |
NYX | 0:85b3fd62ea1a | 310 | /** |
NYX | 0:85b3fd62ea1a | 311 | * @} |
NYX | 0:85b3fd62ea1a | 312 | */ |
NYX | 0:85b3fd62ea1a | 313 | |
NYX | 0:85b3fd62ea1a | 314 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |