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