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