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