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