mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Fri Nov 07 08:15:08 2014 +0000
Revision:
392:2b59412bb664
Parent:
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F091RC/stm32f0xx_hal_wwdg.c@340:28d1f895c6fe
Child:
441:d2c15dda23c1
Synchronized with git revision eec0be05cd92349bee83c65f9e1302b25b5badf4

Full URL: https://github.com/mbedmicro/mbed/commit/eec0be05cd92349bee83c65f9e1302b25b5badf4/

Targets: STM32F0 - Factorisation of NUCLEO_F030R8/F072RB/F091RC cmsis folders

Who changed what in which revision?

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