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