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