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