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