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