annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_wwdg.c @ 101:83feba2ad1c3 kittz

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