mbed library sources, include can_api for nucleo-f091rc

Dependents:   CanNucleoF0_example

Fork of mbed-src by mbed official

Committer:
ptpaterson
Date:
Thu Jan 07 05:49:05 2016 +0000
Revision:
645:13c87cbecd54
Parent:
610:813dcc80987e
corrected freeze on CAN_RECEIVE_IT

Who changed what in which revision?

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