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