mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F334R8/stm32f3xx_hal_wwdg.c@237:f3da66175598, 2014-06-24 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Jun 24 14:45:08 2014 +0100
- Revision:
- 237:f3da66175598
- Child:
- 375:3d36234a1087
Synchronized with git revision 8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7
Full URL: https://github.com/mbedmicro/mbed/commit/8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7/
[NUCLEO_F334R8] Add platform files
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 | 237:f3da66175598 | 5 | * @version V1.0.1 |
mbed_official | 237:f3da66175598 | 6 | * @date 18-June-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 | 237:f3da66175598 | 92 | /** @defgroup WWDG |
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 | 237:f3da66175598 | 104 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 237:f3da66175598 | 105 | |
mbed_official | 237:f3da66175598 | 106 | /** @defgroup WWDG_Private_Functions |
mbed_official | 237:f3da66175598 | 107 | * @{ |
mbed_official | 237:f3da66175598 | 108 | */ |
mbed_official | 237:f3da66175598 | 109 | |
mbed_official | 237:f3da66175598 | 110 | /** @defgroup HAL_WWDG_Group1 Initialization/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 | uint32_t tmp = 0; |
mbed_official | 237:f3da66175598 | 137 | |
mbed_official | 237:f3da66175598 | 138 | /* Check the WWDG handle allocation */ |
mbed_official | 237:f3da66175598 | 139 | if(hwwdg == NULL) |
mbed_official | 237:f3da66175598 | 140 | { |
mbed_official | 237:f3da66175598 | 141 | return HAL_ERROR; |
mbed_official | 237:f3da66175598 | 142 | } |
mbed_official | 237:f3da66175598 | 143 | |
mbed_official | 237:f3da66175598 | 144 | /* Check the parameters */ |
mbed_official | 237:f3da66175598 | 145 | assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); |
mbed_official | 237:f3da66175598 | 146 | assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler)); |
mbed_official | 237:f3da66175598 | 147 | assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window)); |
mbed_official | 237:f3da66175598 | 148 | assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter)); |
mbed_official | 237:f3da66175598 | 149 | |
mbed_official | 237:f3da66175598 | 150 | if(hwwdg->State == HAL_WWDG_STATE_RESET) |
mbed_official | 237:f3da66175598 | 151 | { |
mbed_official | 237:f3da66175598 | 152 | /* Init the low level hardware */ |
mbed_official | 237:f3da66175598 | 153 | HAL_WWDG_MspInit(hwwdg); |
mbed_official | 237:f3da66175598 | 154 | } |
mbed_official | 237:f3da66175598 | 155 | |
mbed_official | 237:f3da66175598 | 156 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 157 | hwwdg->State = HAL_WWDG_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 158 | |
mbed_official | 237:f3da66175598 | 159 | /* Set WWDG Prescaler and Window */ |
mbed_official | 237:f3da66175598 | 160 | /* Get the CFR register value */ |
mbed_official | 237:f3da66175598 | 161 | tmp = hwwdg->Instance->CFR; |
mbed_official | 237:f3da66175598 | 162 | |
mbed_official | 237:f3da66175598 | 163 | /* Clear WDGTB[1:0] and W[6:0] bits */ |
mbed_official | 237:f3da66175598 | 164 | tmp &= ((uint32_t)~(WWDG_CFR_WDGTB | WWDG_CFR_W)); |
mbed_official | 237:f3da66175598 | 165 | |
mbed_official | 237:f3da66175598 | 166 | /* Prepare the WWDG Prescaler and Window parameters */ |
mbed_official | 237:f3da66175598 | 167 | tmp |= hwwdg->Init.Prescaler | hwwdg->Init.Window; |
mbed_official | 237:f3da66175598 | 168 | |
mbed_official | 237:f3da66175598 | 169 | /* Write to WWDG CFR */ |
mbed_official | 237:f3da66175598 | 170 | hwwdg->Instance->CFR = tmp; |
mbed_official | 237:f3da66175598 | 171 | |
mbed_official | 237:f3da66175598 | 172 | /* Set WWDG Counter */ |
mbed_official | 237:f3da66175598 | 173 | /* Get the CR register value */ |
mbed_official | 237:f3da66175598 | 174 | tmp = hwwdg->Instance->CR; |
mbed_official | 237:f3da66175598 | 175 | |
mbed_official | 237:f3da66175598 | 176 | /* Clear T[6:0] bits */ |
mbed_official | 237:f3da66175598 | 177 | tmp &= ((uint32_t)~(WWDG_CR_T)); |
mbed_official | 237:f3da66175598 | 178 | |
mbed_official | 237:f3da66175598 | 179 | /* Prepare the WWDG Counter parameter */ |
mbed_official | 237:f3da66175598 | 180 | tmp |= (hwwdg->Init.Counter); |
mbed_official | 237:f3da66175598 | 181 | |
mbed_official | 237:f3da66175598 | 182 | /* Write to WWDG CR */ |
mbed_official | 237:f3da66175598 | 183 | hwwdg->Instance->CR = tmp; |
mbed_official | 237:f3da66175598 | 184 | |
mbed_official | 237:f3da66175598 | 185 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 186 | hwwdg->State = HAL_WWDG_STATE_READY; |
mbed_official | 237:f3da66175598 | 187 | |
mbed_official | 237:f3da66175598 | 188 | /* Return function status */ |
mbed_official | 237:f3da66175598 | 189 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 190 | } |
mbed_official | 237:f3da66175598 | 191 | |
mbed_official | 237:f3da66175598 | 192 | /** |
mbed_official | 237:f3da66175598 | 193 | * @brief DeInitializes the WWDG peripheral. |
mbed_official | 237:f3da66175598 | 194 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 195 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 196 | */ |
mbed_official | 237:f3da66175598 | 197 | HAL_StatusTypeDef HAL_WWDG_DeInit(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 198 | { |
mbed_official | 237:f3da66175598 | 199 | /* Check the parameters */ |
mbed_official | 237:f3da66175598 | 200 | assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); |
mbed_official | 237:f3da66175598 | 201 | |
mbed_official | 237:f3da66175598 | 202 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 203 | hwwdg->State = HAL_WWDG_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 204 | |
mbed_official | 237:f3da66175598 | 205 | /* DeInit the low level hardware */ |
mbed_official | 237:f3da66175598 | 206 | HAL_WWDG_MspDeInit(hwwdg); |
mbed_official | 237:f3da66175598 | 207 | |
mbed_official | 237:f3da66175598 | 208 | /* Reset WWDG Control register */ |
mbed_official | 237:f3da66175598 | 209 | hwwdg->Instance->CR = (uint32_t)0x0000007F; |
mbed_official | 237:f3da66175598 | 210 | |
mbed_official | 237:f3da66175598 | 211 | /* Reset WWDG Configuration register */ |
mbed_official | 237:f3da66175598 | 212 | hwwdg->Instance->CFR = (uint32_t)0x0000007F; |
mbed_official | 237:f3da66175598 | 213 | |
mbed_official | 237:f3da66175598 | 214 | /* Reset WWDG Status register */ |
mbed_official | 237:f3da66175598 | 215 | hwwdg->Instance->SR = 0; |
mbed_official | 237:f3da66175598 | 216 | |
mbed_official | 237:f3da66175598 | 217 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 218 | hwwdg->State = HAL_WWDG_STATE_RESET; |
mbed_official | 237:f3da66175598 | 219 | |
mbed_official | 237:f3da66175598 | 220 | /* Return function status */ |
mbed_official | 237:f3da66175598 | 221 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 222 | } |
mbed_official | 237:f3da66175598 | 223 | |
mbed_official | 237:f3da66175598 | 224 | /** |
mbed_official | 237:f3da66175598 | 225 | * @brief Initializes the WWDG MSP. |
mbed_official | 237:f3da66175598 | 226 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 227 | * @retval None |
mbed_official | 237:f3da66175598 | 228 | */ |
mbed_official | 237:f3da66175598 | 229 | __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 230 | { |
mbed_official | 237:f3da66175598 | 231 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 232 | the HAL_WWDG_MspInit could be implemented in the user file |
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 | * @brief DeInitializes the WWDG MSP. |
mbed_official | 237:f3da66175598 | 238 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 239 | * @retval None |
mbed_official | 237:f3da66175598 | 240 | */ |
mbed_official | 237:f3da66175598 | 241 | __weak void HAL_WWDG_MspDeInit(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 242 | { |
mbed_official | 237:f3da66175598 | 243 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 244 | the HAL_WWDG_MspDeInit could be implemented in the user file |
mbed_official | 237:f3da66175598 | 245 | */ |
mbed_official | 237:f3da66175598 | 246 | } |
mbed_official | 237:f3da66175598 | 247 | |
mbed_official | 237:f3da66175598 | 248 | /** |
mbed_official | 237:f3da66175598 | 249 | * @brief Early Wakeup WWDG callback. |
mbed_official | 237:f3da66175598 | 250 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 251 | * @retval None |
mbed_official | 237:f3da66175598 | 252 | */ |
mbed_official | 237:f3da66175598 | 253 | __weak void HAL_WWDG_WakeupCallback(WWDG_HandleTypeDef* hwwdg) |
mbed_official | 237:f3da66175598 | 254 | { |
mbed_official | 237:f3da66175598 | 255 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 237:f3da66175598 | 256 | the HAL_WWDG_WakeupCallback could be implemented in the user file |
mbed_official | 237:f3da66175598 | 257 | */ |
mbed_official | 237:f3da66175598 | 258 | } |
mbed_official | 237:f3da66175598 | 259 | |
mbed_official | 237:f3da66175598 | 260 | /** |
mbed_official | 237:f3da66175598 | 261 | * @} |
mbed_official | 237:f3da66175598 | 262 | */ |
mbed_official | 237:f3da66175598 | 263 | |
mbed_official | 237:f3da66175598 | 264 | /** @defgroup HAL_WWDG_Group2 I/O operation functions |
mbed_official | 237:f3da66175598 | 265 | * @brief I/O operation functions |
mbed_official | 237:f3da66175598 | 266 | * |
mbed_official | 237:f3da66175598 | 267 | @verbatim |
mbed_official | 237:f3da66175598 | 268 | =============================================================================== |
mbed_official | 237:f3da66175598 | 269 | ##### IO operation functions ##### |
mbed_official | 237:f3da66175598 | 270 | =============================================================================== |
mbed_official | 237:f3da66175598 | 271 | [..] This section provides functions allowing to: |
mbed_official | 237:f3da66175598 | 272 | (+) Start the WWDG. |
mbed_official | 237:f3da66175598 | 273 | (+) Refresh the WWDG. |
mbed_official | 237:f3da66175598 | 274 | (+) Handle WWDG interrupt request. |
mbed_official | 237:f3da66175598 | 275 | |
mbed_official | 237:f3da66175598 | 276 | @endverbatim |
mbed_official | 237:f3da66175598 | 277 | * @{ |
mbed_official | 237:f3da66175598 | 278 | */ |
mbed_official | 237:f3da66175598 | 279 | |
mbed_official | 237:f3da66175598 | 280 | /** |
mbed_official | 237:f3da66175598 | 281 | * @brief Starts the WWDG |
mbed_official | 237:f3da66175598 | 282 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 283 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 284 | */ |
mbed_official | 237:f3da66175598 | 285 | HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 286 | { |
mbed_official | 237:f3da66175598 | 287 | /* Process locked */ |
mbed_official | 237:f3da66175598 | 288 | __HAL_LOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 289 | |
mbed_official | 237:f3da66175598 | 290 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 291 | hwwdg->State = HAL_WWDG_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 292 | |
mbed_official | 237:f3da66175598 | 293 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 294 | __HAL_WWDG_ENABLE(hwwdg); |
mbed_official | 237:f3da66175598 | 295 | |
mbed_official | 237:f3da66175598 | 296 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 297 | hwwdg->State = HAL_WWDG_STATE_READY; |
mbed_official | 237:f3da66175598 | 298 | |
mbed_official | 237:f3da66175598 | 299 | /* Process unlocked */ |
mbed_official | 237:f3da66175598 | 300 | __HAL_UNLOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 301 | |
mbed_official | 237:f3da66175598 | 302 | /* Return function status */ |
mbed_official | 237:f3da66175598 | 303 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 304 | } |
mbed_official | 237:f3da66175598 | 305 | |
mbed_official | 237:f3da66175598 | 306 | /** |
mbed_official | 237:f3da66175598 | 307 | * @brief Starts the WWDG with interrupt enabled. |
mbed_official | 237:f3da66175598 | 308 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 309 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 310 | */ |
mbed_official | 237:f3da66175598 | 311 | HAL_StatusTypeDef HAL_WWDG_Start_IT(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 312 | { |
mbed_official | 237:f3da66175598 | 313 | /* Process locked */ |
mbed_official | 237:f3da66175598 | 314 | __HAL_LOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 315 | |
mbed_official | 237:f3da66175598 | 316 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 317 | hwwdg->State = HAL_WWDG_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 318 | |
mbed_official | 237:f3da66175598 | 319 | /* Enable the Early Wakeup Interrupt */ |
mbed_official | 237:f3da66175598 | 320 | __HAL_WWDG_ENABLE_IT(WWDG_IT_EWI); |
mbed_official | 237:f3da66175598 | 321 | |
mbed_official | 237:f3da66175598 | 322 | /* Enable the Peripheral */ |
mbed_official | 237:f3da66175598 | 323 | __HAL_WWDG_ENABLE(hwwdg); |
mbed_official | 237:f3da66175598 | 324 | |
mbed_official | 237:f3da66175598 | 325 | /* Return function status */ |
mbed_official | 237:f3da66175598 | 326 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 327 | } |
mbed_official | 237:f3da66175598 | 328 | |
mbed_official | 237:f3da66175598 | 329 | /** |
mbed_official | 237:f3da66175598 | 330 | * @brief Refreshes the WWDG. |
mbed_official | 237:f3da66175598 | 331 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 332 | * @param Counter: Counter value to refresh WWDG with |
mbed_official | 237:f3da66175598 | 333 | * @retval HAL status |
mbed_official | 237:f3da66175598 | 334 | */ |
mbed_official | 237:f3da66175598 | 335 | HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg, uint32_t Counter) |
mbed_official | 237:f3da66175598 | 336 | { |
mbed_official | 237:f3da66175598 | 337 | /* Process locked */ |
mbed_official | 237:f3da66175598 | 338 | __HAL_LOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 339 | |
mbed_official | 237:f3da66175598 | 340 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 341 | hwwdg->State = HAL_WWDG_STATE_BUSY; |
mbed_official | 237:f3da66175598 | 342 | |
mbed_official | 237:f3da66175598 | 343 | /* Check the parameters */ |
mbed_official | 237:f3da66175598 | 344 | assert_param(IS_WWDG_COUNTER(Counter)); |
mbed_official | 237:f3da66175598 | 345 | |
mbed_official | 237:f3da66175598 | 346 | /* Write to WWDG CR the WWDG Counter value to refresh with */ |
mbed_official | 237:f3da66175598 | 347 | MODIFY_REG(hwwdg->Instance->CR, WWDG_CR_T, Counter); |
mbed_official | 237:f3da66175598 | 348 | |
mbed_official | 237:f3da66175598 | 349 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 350 | hwwdg->State = HAL_WWDG_STATE_READY; |
mbed_official | 237:f3da66175598 | 351 | |
mbed_official | 237:f3da66175598 | 352 | /* Process unlocked */ |
mbed_official | 237:f3da66175598 | 353 | __HAL_UNLOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 354 | |
mbed_official | 237:f3da66175598 | 355 | /* Return function status */ |
mbed_official | 237:f3da66175598 | 356 | return HAL_OK; |
mbed_official | 237:f3da66175598 | 357 | } |
mbed_official | 237:f3da66175598 | 358 | |
mbed_official | 237:f3da66175598 | 359 | /** |
mbed_official | 237:f3da66175598 | 360 | * @brief Handles WWDG interrupt request. |
mbed_official | 237:f3da66175598 | 361 | * @note The Early Wakeup Interrupt (EWI) can be used if specific safety operations |
mbed_official | 237:f3da66175598 | 362 | * or data logging must be performed before the actual reset is generated. |
mbed_official | 237:f3da66175598 | 363 | * The EWI interrupt is enabled using __HAL_WWDG_ENABLE_IT() macro. |
mbed_official | 237:f3da66175598 | 364 | * When the downcounter reaches the value 0x40, and EWI interrupt is |
mbed_official | 237:f3da66175598 | 365 | * generated and the corresponding Interrupt Service Routine (ISR) can |
mbed_official | 237:f3da66175598 | 366 | * be used to trigger specific actions (such as communications or data |
mbed_official | 237:f3da66175598 | 367 | * logging), before resetting the device. |
mbed_official | 237:f3da66175598 | 368 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 369 | * @retval None |
mbed_official | 237:f3da66175598 | 370 | */ |
mbed_official | 237:f3da66175598 | 371 | void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 372 | { |
mbed_official | 237:f3da66175598 | 373 | /* WWDG Early Wakeup Interrupt occurred */ |
mbed_official | 237:f3da66175598 | 374 | if(__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET) |
mbed_official | 237:f3da66175598 | 375 | { |
mbed_official | 237:f3da66175598 | 376 | /* Early Wakeup callback */ |
mbed_official | 237:f3da66175598 | 377 | HAL_WWDG_WakeupCallback(hwwdg); |
mbed_official | 237:f3da66175598 | 378 | |
mbed_official | 237:f3da66175598 | 379 | /* Change WWDG peripheral state */ |
mbed_official | 237:f3da66175598 | 380 | hwwdg->State = HAL_WWDG_STATE_READY; |
mbed_official | 237:f3da66175598 | 381 | |
mbed_official | 237:f3da66175598 | 382 | /* Clear the WWDG Data Ready flag */ |
mbed_official | 237:f3da66175598 | 383 | __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF); |
mbed_official | 237:f3da66175598 | 384 | |
mbed_official | 237:f3da66175598 | 385 | /* Process unlocked */ |
mbed_official | 237:f3da66175598 | 386 | __HAL_UNLOCK(hwwdg); |
mbed_official | 237:f3da66175598 | 387 | } |
mbed_official | 237:f3da66175598 | 388 | } |
mbed_official | 237:f3da66175598 | 389 | |
mbed_official | 237:f3da66175598 | 390 | /** |
mbed_official | 237:f3da66175598 | 391 | * @} |
mbed_official | 237:f3da66175598 | 392 | */ |
mbed_official | 237:f3da66175598 | 393 | |
mbed_official | 237:f3da66175598 | 394 | /** @defgroup HAL_WWDG_Group3 Peripheral State functions |
mbed_official | 237:f3da66175598 | 395 | * @brief Peripheral State functions. |
mbed_official | 237:f3da66175598 | 396 | * |
mbed_official | 237:f3da66175598 | 397 | @verbatim |
mbed_official | 237:f3da66175598 | 398 | =============================================================================== |
mbed_official | 237:f3da66175598 | 399 | ##### Peripheral State functions ##### |
mbed_official | 237:f3da66175598 | 400 | =============================================================================== |
mbed_official | 237:f3da66175598 | 401 | [..] |
mbed_official | 237:f3da66175598 | 402 | This subsection permits to get in run-time the status of the peripheral |
mbed_official | 237:f3da66175598 | 403 | and the data flow. |
mbed_official | 237:f3da66175598 | 404 | |
mbed_official | 237:f3da66175598 | 405 | @endverbatim |
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 | * @brief Returns the WWDG state. |
mbed_official | 237:f3da66175598 | 411 | * @param hwwdg: WWDG handle |
mbed_official | 237:f3da66175598 | 412 | * @retval HAL state |
mbed_official | 237:f3da66175598 | 413 | */ |
mbed_official | 237:f3da66175598 | 414 | HAL_WWDG_StateTypeDef HAL_WWDG_GetState(WWDG_HandleTypeDef *hwwdg) |
mbed_official | 237:f3da66175598 | 415 | { |
mbed_official | 237:f3da66175598 | 416 | return hwwdg->State; |
mbed_official | 237:f3da66175598 | 417 | } |
mbed_official | 237:f3da66175598 | 418 | /** |
mbed_official | 237:f3da66175598 | 419 | * @} |
mbed_official | 237:f3da66175598 | 420 | */ |
mbed_official | 237:f3da66175598 | 421 | |
mbed_official | 237:f3da66175598 | 422 | /** |
mbed_official | 237:f3da66175598 | 423 | * @} |
mbed_official | 237:f3da66175598 | 424 | */ |
mbed_official | 237:f3da66175598 | 425 | |
mbed_official | 237:f3da66175598 | 426 | #endif /* HAL_WWDG_MODULE_ENABLED */ |
mbed_official | 237:f3da66175598 | 427 | /** |
mbed_official | 237:f3da66175598 | 428 | * @} |
mbed_official | 237:f3da66175598 | 429 | */ |
mbed_official | 237:f3da66175598 | 430 | |
mbed_official | 237:f3da66175598 | 431 | /** |
mbed_official | 237:f3da66175598 | 432 | * @} |
mbed_official | 237:f3da66175598 | 433 | */ |
mbed_official | 237:f3da66175598 | 434 | |
mbed_official | 237:f3da66175598 | 435 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |