added prescaler for 16 bit pwm in LPC1347 target
Fork of mbed-dev by
targets/cmsis/TARGET_STM/TARGET_STM32F7/stm32f7xx_hal_wwdg.c@144:ef7eb2e8f9f7, 2016-09-02 (annotated)
- Committer:
- <>
- Date:
- Fri Sep 02 15:07:44 2016 +0100
- Revision:
- 144:ef7eb2e8f9f7
- Parent:
- 83:a036322b8637
This updates the lib to the mbed lib v125
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f7xx_hal_wwdg.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 144:ef7eb2e8f9f7 | 5 | * @version V1.1.0 |
<> | 144:ef7eb2e8f9f7 | 6 | * @date 22-April-2016 |
<> | 144:ef7eb2e8f9f7 | 7 | * @brief WWDG HAL module driver. |
<> | 144:ef7eb2e8f9f7 | 8 | * This file provides firmware functions to manage the following |
<> | 144:ef7eb2e8f9f7 | 9 | * functionalities of the Window Watchdog (WWDG) peripheral: |
<> | 144:ef7eb2e8f9f7 | 10 | * + Initialization and Configuration function |
<> | 144:ef7eb2e8f9f7 | 11 | * + IO operation functions |
<> | 144:ef7eb2e8f9f7 | 12 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 13 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 14 | ##### WWDG specific features ##### |
<> | 144:ef7eb2e8f9f7 | 15 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 16 | [..] |
<> | 144:ef7eb2e8f9f7 | 17 | Once enabled the WWDG generates a system reset on expiry of a programmed |
<> | 144:ef7eb2e8f9f7 | 18 | time period, unless the program refreshes the counter (T[6;0] downcounter) |
<> | 144:ef7eb2e8f9f7 | 19 | before reaching 0x3F value (i.e. a reset is generated when the counter |
<> | 144:ef7eb2e8f9f7 | 20 | value rolls over from 0x40 to 0x3F). |
<> | 144:ef7eb2e8f9f7 | 21 | |
<> | 144:ef7eb2e8f9f7 | 22 | (+) An MCU reset is also generated if the counter value is refreshed |
<> | 144:ef7eb2e8f9f7 | 23 | before the counter has reached the refresh window value. This |
<> | 144:ef7eb2e8f9f7 | 24 | implies that the counter must be refreshed in a limited window. |
<> | 144:ef7eb2e8f9f7 | 25 | |
<> | 144:ef7eb2e8f9f7 | 26 | (+) Once enabled the WWDG cannot be disabled except by a system reset. |
<> | 144:ef7eb2e8f9f7 | 27 | |
<> | 144:ef7eb2e8f9f7 | 28 | (+) WWDGRST flag in RCC_CSR register informs when a WWDG reset has |
<> | 144:ef7eb2e8f9f7 | 29 | occurred (check available with __HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)). |
<> | 144:ef7eb2e8f9f7 | 30 | |
<> | 144:ef7eb2e8f9f7 | 31 | (+) The WWDG downcounter input clock is derived from the APB clock divided |
<> | 144:ef7eb2e8f9f7 | 32 | by a programmable prescaler. |
<> | 144:ef7eb2e8f9f7 | 33 | |
<> | 144:ef7eb2e8f9f7 | 34 | (+) WWDG downcounter clock (Hz) = PCLK1 / (4096 * Prescaler) |
<> | 144:ef7eb2e8f9f7 | 35 | |
<> | 144:ef7eb2e8f9f7 | 36 | (+) WWDG timeout (ms) = (1000 * (T[5;0] + 1)) / (WWDG downcounter clock) |
<> | 144:ef7eb2e8f9f7 | 37 | where T[5;0] are the lowest 6 bits of downcounter. |
<> | 144:ef7eb2e8f9f7 | 38 | |
<> | 144:ef7eb2e8f9f7 | 39 | (+) WWDG Counter refresh is allowed between the following limits : |
<> | 144:ef7eb2e8f9f7 | 40 | (++) min time (ms) = (1000 * (T[5;0] - Window)) / (WWDG downcounter clock) |
<> | 144:ef7eb2e8f9f7 | 41 | (++) max time (ms) = (1000 * (T[5;0] - 0x40)) / (WWDG downcounter clock) |
<> | 144:ef7eb2e8f9f7 | 42 | |
<> | 144:ef7eb2e8f9f7 | 43 | (+) Min-max timeout value @80 MHz(PCLK1): ~51.2 us / ~26.22 ms |
<> | 144:ef7eb2e8f9f7 | 44 | |
<> | 144:ef7eb2e8f9f7 | 45 | (+) The Early Wakeup Interrupt (EWI) can be used if specific safety |
<> | 144:ef7eb2e8f9f7 | 46 | operations or data logging must be performed before the actual reset is |
<> | 144:ef7eb2e8f9f7 | 47 | generated. When the downcounter reaches the value 0x40, an EWI interrupt |
<> | 144:ef7eb2e8f9f7 | 48 | is generated and the corresponding interrupt service routine (ISR) can |
<> | 144:ef7eb2e8f9f7 | 49 | be used to trigger specific actions (such as communications or data |
<> | 144:ef7eb2e8f9f7 | 50 | logging), before resetting the device. |
<> | 144:ef7eb2e8f9f7 | 51 | In some applications, the EWI interrupt can be used to manage a software |
<> | 144:ef7eb2e8f9f7 | 52 | system check and/or system recovery/graceful degradation, without |
<> | 144:ef7eb2e8f9f7 | 53 | generating a WWDG reset. In this case, the corresponding interrupt |
<> | 144:ef7eb2e8f9f7 | 54 | service routine (ISR) should reload the WWDG counter to avoid the WWDG |
<> | 144:ef7eb2e8f9f7 | 55 | reset, then trigger the required actions. |
<> | 144:ef7eb2e8f9f7 | 56 | Note:When the EWI interrupt cannot be served, e.g. due to a system lock |
<> | 144:ef7eb2e8f9f7 | 57 | in a higher priority task, the WWDG reset will eventually be generated. |
<> | 144:ef7eb2e8f9f7 | 58 | |
<> | 144:ef7eb2e8f9f7 | 59 | (+) Debug mode : When the microcontroller enters debug mode (core halted), |
<> | 144:ef7eb2e8f9f7 | 60 | the WWDG counter either continues to work normally or stops, depending |
<> | 144:ef7eb2e8f9f7 | 61 | on DBG_WWDG_STOP configuration bit in DBG module, accessible through |
<> | 144:ef7eb2e8f9f7 | 62 | __HAL_DBGMCU_FREEZE_WWDG() and __HAL_DBGMCU_UNFREEZE_WWDG() macros |
<> | 144:ef7eb2e8f9f7 | 63 | |
<> | 144:ef7eb2e8f9f7 | 64 | ##### How to use this driver ##### |
<> | 144:ef7eb2e8f9f7 | 65 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 66 | [..] |
<> | 144:ef7eb2e8f9f7 | 67 | (+) Enable WWDG APB1 clock using __HAL_RCC_WWDG_CLK_ENABLE(). |
<> | 144:ef7eb2e8f9f7 | 68 | |
<> | 144:ef7eb2e8f9f7 | 69 | (+) Set the WWDG prescaler, refresh window, counter value and Early Wakeup |
<> | 144:ef7eb2e8f9f7 | 70 | Interrupt mode using using HAL_WWDG_Init() function. |
<> | 144:ef7eb2e8f9f7 | 71 | This enables WWDG peripheral and the downcounter starts downcounting |
<> | 144:ef7eb2e8f9f7 | 72 | from given counter value. |
<> | 144:ef7eb2e8f9f7 | 73 | Init function can be called again to modify all watchdog parameters, |
<> | 144:ef7eb2e8f9f7 | 74 | however if EWI mode has been set once, it can't be clear until next |
<> | 144:ef7eb2e8f9f7 | 75 | reset. |
<> | 144:ef7eb2e8f9f7 | 76 | |
<> | 144:ef7eb2e8f9f7 | 77 | (+) The application program must refresh the WWDG counter at regular |
<> | 144:ef7eb2e8f9f7 | 78 | intervals during normal operation to prevent an MCU reset using |
<> | 144:ef7eb2e8f9f7 | 79 | HAL_WWDG_Refresh() function. This operation must occur only when |
<> | 144:ef7eb2e8f9f7 | 80 | the counter is lower than the window value already programmed. |
<> | 144:ef7eb2e8f9f7 | 81 | |
<> | 144:ef7eb2e8f9f7 | 82 | (+) if Early Wakeup Interrupt mode is enable an interrupt is generated when |
<> | 144:ef7eb2e8f9f7 | 83 | the counter reaches 0x40. User can add his own code in weak function |
<> | 144:ef7eb2e8f9f7 | 84 | HAL_WWDG_EarlyWakeupCallback(). |
<> | 144:ef7eb2e8f9f7 | 85 | |
<> | 144:ef7eb2e8f9f7 | 86 | *** WWDG HAL driver macros list *** |
<> | 144:ef7eb2e8f9f7 | 87 | ================================== |
<> | 144:ef7eb2e8f9f7 | 88 | [..] |
<> | 144:ef7eb2e8f9f7 | 89 | Below the list of most used macros in WWDG HAL driver. |
<> | 144:ef7eb2e8f9f7 | 90 | |
<> | 144:ef7eb2e8f9f7 | 91 | (+) __HAL_WWDG_GET_IT_SOURCE: Check the selected WWDG's interrupt source. |
<> | 144:ef7eb2e8f9f7 | 92 | (+) __HAL_WWDG_GET_FLAG: Get the selected WWDG's flag status. |
<> | 144:ef7eb2e8f9f7 | 93 | (+) __HAL_WWDG_CLEAR_FLAG: Clear the WWDG's pending flags. |
<> | 144:ef7eb2e8f9f7 | 94 | |
<> | 144:ef7eb2e8f9f7 | 95 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 96 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 97 | * @attention |
<> | 144:ef7eb2e8f9f7 | 98 | * |
<> | 144:ef7eb2e8f9f7 | 99 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 100 | * |
<> | 144:ef7eb2e8f9f7 | 101 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 102 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 103 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 104 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 105 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 106 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 107 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 108 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 109 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 110 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 111 | * |
<> | 144:ef7eb2e8f9f7 | 112 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 113 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 114 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 115 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 116 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 117 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 118 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 119 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 120 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 121 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 122 | * |
<> | 144:ef7eb2e8f9f7 | 123 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 124 | */ |
<> | 144:ef7eb2e8f9f7 | 125 | |
<> | 144:ef7eb2e8f9f7 | 126 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 127 | #include "stm32f7xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 128 | |
<> | 144:ef7eb2e8f9f7 | 129 | /** @addtogroup STM32F7xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 130 | * @{ |
<> | 144:ef7eb2e8f9f7 | 131 | */ |
<> | 144:ef7eb2e8f9f7 | 132 | |
<> | 144:ef7eb2e8f9f7 | 133 | #ifdef HAL_WWDG_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 134 | /** @defgroup WWDG WWDG |
<> | 144:ef7eb2e8f9f7 | 135 | * @brief WWDG HAL module driver. |
<> | 144:ef7eb2e8f9f7 | 136 | * @{ |
<> | 144:ef7eb2e8f9f7 | 137 | */ |
<> | 144:ef7eb2e8f9f7 | 138 | |
<> | 144:ef7eb2e8f9f7 | 139 | /* Private typedef -----------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 140 | /* Private define ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 141 | /* Private macro -------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 142 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 143 | /* Private function prototypes -----------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 144 | /* Exported functions --------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 145 | |
<> | 144:ef7eb2e8f9f7 | 146 | /** @defgroup WWDG_Exported_Functions WWDG Exported Functions |
<> | 144:ef7eb2e8f9f7 | 147 | * @{ |
<> | 144:ef7eb2e8f9f7 | 148 | */ |
<> | 144:ef7eb2e8f9f7 | 149 | |
<> | 144:ef7eb2e8f9f7 | 150 | /** @defgroup WWDG_Exported_Functions_Group1 Initialization and Configuration functions |
<> | 144:ef7eb2e8f9f7 | 151 | * @brief Initialization and Configuration functions. |
<> | 144:ef7eb2e8f9f7 | 152 | * |
<> | 144:ef7eb2e8f9f7 | 153 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 154 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 155 | ##### Initialization and Configuration functions ##### |
<> | 144:ef7eb2e8f9f7 | 156 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 157 | [..] |
<> | 144:ef7eb2e8f9f7 | 158 | This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 159 | (+) Initialize and start the WWDG according to the specified parameters |
<> | 144:ef7eb2e8f9f7 | 160 | in the WWDG_InitTypeDef of associated handle. |
<> | 144:ef7eb2e8f9f7 | 161 | (+) Initialize the WWDG MSP. |
<> | 144:ef7eb2e8f9f7 | 162 | |
<> | 144:ef7eb2e8f9f7 | 163 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 164 | * @{ |
<> | 144:ef7eb2e8f9f7 | 165 | */ |
<> | 144:ef7eb2e8f9f7 | 166 | |
<> | 144:ef7eb2e8f9f7 | 167 | /** |
<> | 144:ef7eb2e8f9f7 | 168 | * @brief Initialize the WWDG according to the specified. |
<> | 144:ef7eb2e8f9f7 | 169 | * parameters in the WWDG_InitTypeDef of associated handle. |
<> | 144:ef7eb2e8f9f7 | 170 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 171 | * the configuration information for the specified WWDG module. |
<> | 144:ef7eb2e8f9f7 | 172 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 173 | */ |
<> | 144:ef7eb2e8f9f7 | 174 | HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg) |
<> | 144:ef7eb2e8f9f7 | 175 | { |
<> | 144:ef7eb2e8f9f7 | 176 | /* Check the WWDG handle allocation */ |
<> | 144:ef7eb2e8f9f7 | 177 | if(hwwdg == NULL) |
<> | 144:ef7eb2e8f9f7 | 178 | { |
<> | 144:ef7eb2e8f9f7 | 179 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 180 | } |
<> | 144:ef7eb2e8f9f7 | 181 | |
<> | 144:ef7eb2e8f9f7 | 182 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 183 | assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance)); |
<> | 144:ef7eb2e8f9f7 | 184 | assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler)); |
<> | 144:ef7eb2e8f9f7 | 185 | assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window)); |
<> | 144:ef7eb2e8f9f7 | 186 | assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter)); |
<> | 144:ef7eb2e8f9f7 | 187 | assert_param(IS_WWDG_EWI_MODE(hwwdg->Init.EWIMode)); |
<> | 144:ef7eb2e8f9f7 | 188 | |
<> | 144:ef7eb2e8f9f7 | 189 | /* Init the low level hardware */ |
<> | 144:ef7eb2e8f9f7 | 190 | HAL_WWDG_MspInit(hwwdg); |
<> | 144:ef7eb2e8f9f7 | 191 | |
<> | 144:ef7eb2e8f9f7 | 192 | /* Set WWDG Counter */ |
<> | 144:ef7eb2e8f9f7 | 193 | WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter)); |
<> | 144:ef7eb2e8f9f7 | 194 | |
<> | 144:ef7eb2e8f9f7 | 195 | /* Set WWDG Prescaler and Window */ |
<> | 144:ef7eb2e8f9f7 | 196 | WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window)); |
<> | 144:ef7eb2e8f9f7 | 197 | |
<> | 144:ef7eb2e8f9f7 | 198 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 199 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 200 | } |
<> | 144:ef7eb2e8f9f7 | 201 | |
<> | 144:ef7eb2e8f9f7 | 202 | |
<> | 144:ef7eb2e8f9f7 | 203 | /** |
<> | 144:ef7eb2e8f9f7 | 204 | * @brief Initialize the WWDG MSP. |
<> | 144:ef7eb2e8f9f7 | 205 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 206 | * the configuration information for the specified WWDG module. |
<> | 144:ef7eb2e8f9f7 | 207 | * @note When rewriting this function in user file, mechanism may be added |
<> | 144:ef7eb2e8f9f7 | 208 | * to avoid multiple initialize when HAL_WWDG_Init function is called |
<> | 144:ef7eb2e8f9f7 | 209 | * again to change parameters. |
<> | 144:ef7eb2e8f9f7 | 210 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 211 | */ |
<> | 144:ef7eb2e8f9f7 | 212 | __weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg) |
<> | 144:ef7eb2e8f9f7 | 213 | { |
<> | 144:ef7eb2e8f9f7 | 214 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 215 | UNUSED(hwwdg); |
<> | 144:ef7eb2e8f9f7 | 216 | |
<> | 144:ef7eb2e8f9f7 | 217 | /* NOTE: This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 218 | the HAL_WWDG_MspInit could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 219 | */ |
<> | 144:ef7eb2e8f9f7 | 220 | } |
<> | 144:ef7eb2e8f9f7 | 221 | |
<> | 144:ef7eb2e8f9f7 | 222 | /** |
<> | 144:ef7eb2e8f9f7 | 223 | * @} |
<> | 144:ef7eb2e8f9f7 | 224 | */ |
<> | 144:ef7eb2e8f9f7 | 225 | |
<> | 144:ef7eb2e8f9f7 | 226 | /** @defgroup WWDG_Exported_Functions_Group2 IO operation functions |
<> | 144:ef7eb2e8f9f7 | 227 | * @brief IO operation functions |
<> | 144:ef7eb2e8f9f7 | 228 | * |
<> | 144:ef7eb2e8f9f7 | 229 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 230 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 231 | ##### IO operation functions ##### |
<> | 144:ef7eb2e8f9f7 | 232 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 233 | [..] |
<> | 144:ef7eb2e8f9f7 | 234 | This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 235 | (+) Refresh the WWDG. |
<> | 144:ef7eb2e8f9f7 | 236 | (+) Handle WWDG interrupt request and associated function callback. |
<> | 144:ef7eb2e8f9f7 | 237 | |
<> | 144:ef7eb2e8f9f7 | 238 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 239 | * @{ |
<> | 144:ef7eb2e8f9f7 | 240 | */ |
<> | 144:ef7eb2e8f9f7 | 241 | |
<> | 144:ef7eb2e8f9f7 | 242 | /** |
<> | 144:ef7eb2e8f9f7 | 243 | * @brief Refresh the WWDG. |
<> | 144:ef7eb2e8f9f7 | 244 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 245 | * the configuration information for the specified WWDG module. |
<> | 144:ef7eb2e8f9f7 | 246 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 247 | */ |
<> | 144:ef7eb2e8f9f7 | 248 | HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg) |
<> | 144:ef7eb2e8f9f7 | 249 | { |
<> | 144:ef7eb2e8f9f7 | 250 | /* Write to WWDG CR the WWDG Counter value to refresh with */ |
<> | 144:ef7eb2e8f9f7 | 251 | WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter)); |
<> | 144:ef7eb2e8f9f7 | 252 | |
<> | 144:ef7eb2e8f9f7 | 253 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 254 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 255 | } |
<> | 144:ef7eb2e8f9f7 | 256 | |
<> | 144:ef7eb2e8f9f7 | 257 | /** |
<> | 144:ef7eb2e8f9f7 | 258 | * @brief Handle WWDG interrupt request. |
<> | 144:ef7eb2e8f9f7 | 259 | * @note The Early Wakeup Interrupt (EWI) can be used if specific safety operations |
<> | 144:ef7eb2e8f9f7 | 260 | * or data logging must be performed before the actual reset is generated. |
<> | 144:ef7eb2e8f9f7 | 261 | * The EWI interrupt is enabled by calling HAL_WWDG_Init function with |
<> | 144:ef7eb2e8f9f7 | 262 | * EWIMode set to WWDG_EWI_ENABLE. |
<> | 144:ef7eb2e8f9f7 | 263 | * When the downcounter reaches the value 0x40, and EWI interrupt is |
<> | 144:ef7eb2e8f9f7 | 264 | * generated and the corresponding Interrupt Service Routine (ISR) can |
<> | 144:ef7eb2e8f9f7 | 265 | * be used to trigger specific actions (such as communications or data |
<> | 144:ef7eb2e8f9f7 | 266 | * logging), before resetting the device. |
<> | 144:ef7eb2e8f9f7 | 267 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 268 | * the configuration information for the specified WWDG module. |
<> | 144:ef7eb2e8f9f7 | 269 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 270 | */ |
<> | 144:ef7eb2e8f9f7 | 271 | void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg) |
<> | 144:ef7eb2e8f9f7 | 272 | { |
<> | 144:ef7eb2e8f9f7 | 273 | /* Check if Early Wakeup Interrupt is enable */ |
<> | 144:ef7eb2e8f9f7 | 274 | if(__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET) |
<> | 144:ef7eb2e8f9f7 | 275 | { |
<> | 144:ef7eb2e8f9f7 | 276 | /* Check if WWDG Early Wakeup Interrupt occurred */ |
<> | 144:ef7eb2e8f9f7 | 277 | if(__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET) |
<> | 144:ef7eb2e8f9f7 | 278 | { |
<> | 144:ef7eb2e8f9f7 | 279 | /* Clear the WWDG Early Wakeup flag */ |
<> | 144:ef7eb2e8f9f7 | 280 | __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF); |
<> | 144:ef7eb2e8f9f7 | 281 | |
<> | 144:ef7eb2e8f9f7 | 282 | /* Early Wakeup callback */ |
<> | 144:ef7eb2e8f9f7 | 283 | HAL_WWDG_EarlyWakeupCallback(hwwdg); |
<> | 144:ef7eb2e8f9f7 | 284 | } |
<> | 144:ef7eb2e8f9f7 | 285 | } |
<> | 144:ef7eb2e8f9f7 | 286 | } |
<> | 144:ef7eb2e8f9f7 | 287 | |
<> | 144:ef7eb2e8f9f7 | 288 | |
<> | 144:ef7eb2e8f9f7 | 289 | /** |
<> | 144:ef7eb2e8f9f7 | 290 | * @brief WWDG Early Wakeup callback. |
<> | 144:ef7eb2e8f9f7 | 291 | * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 292 | * the configuration information for the specified WWDG module. |
<> | 144:ef7eb2e8f9f7 | 293 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 294 | */ |
<> | 144:ef7eb2e8f9f7 | 295 | __weak void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef* hwwdg) |
<> | 144:ef7eb2e8f9f7 | 296 | { |
<> | 144:ef7eb2e8f9f7 | 297 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 298 | UNUSED(hwwdg); |
<> | 144:ef7eb2e8f9f7 | 299 | |
<> | 144:ef7eb2e8f9f7 | 300 | /* NOTE: This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 301 | the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 302 | */ |
<> | 144:ef7eb2e8f9f7 | 303 | } |
<> | 144:ef7eb2e8f9f7 | 304 | |
<> | 144:ef7eb2e8f9f7 | 305 | /** |
<> | 144:ef7eb2e8f9f7 | 306 | * @} |
<> | 144:ef7eb2e8f9f7 | 307 | */ |
<> | 144:ef7eb2e8f9f7 | 308 | |
<> | 144:ef7eb2e8f9f7 | 309 | /** |
<> | 144:ef7eb2e8f9f7 | 310 | * @} |
<> | 144:ef7eb2e8f9f7 | 311 | */ |
<> | 144:ef7eb2e8f9f7 | 312 | |
<> | 144:ef7eb2e8f9f7 | 313 | #endif /* HAL_WWDG_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 314 | /** |
<> | 144:ef7eb2e8f9f7 | 315 | * @} |
<> | 144:ef7eb2e8f9f7 | 316 | */ |
<> | 144:ef7eb2e8f9f7 | 317 | |
<> | 144:ef7eb2e8f9f7 | 318 | /** |
<> | 144:ef7eb2e8f9f7 | 319 | * @} |
<> | 144:ef7eb2e8f9f7 | 320 | */ |
<> | 144:ef7eb2e8f9f7 | 321 | |
<> | 144:ef7eb2e8f9f7 | 322 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |