mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

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