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