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