Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 9 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32f1xx_hal_rtc_ex.c |
3 | * @file stm32f1xx_hal_rtc_ex.c |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief Extended RTC HAL module driver. |
5 | * @brief Extended RTC HAL module driver. |
| 6 | * This file provides firmware functions to manage the following |
6 | * This file provides firmware functions to manage the following |
| 7 | * functionalities of the Real Time Clock (RTC) Extension peripheral: |
7 | * functionalities of the Real Time Clock (RTC) Extension peripheral: |
| 8 | * + RTC Tamper functions |
8 | * + RTC Tamper functions |
| 9 | * + Extension Control functions |
9 | * + Extension Control functions |
| 10 | * + Extension RTC features functions |
10 | * + Extension RTC features functions |
| 11 | * |
11 | * |
| 12 | ****************************************************************************** |
12 | ****************************************************************************** |
| 13 | * @attention |
13 | * @attention |
| 14 | * |
14 | * |
| 15 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
15 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
| 16 | * |
- | |
| 17 | * Redistribution and use in source and binary forms, with or without modification, |
- | |
| 18 | * are permitted provided that the following conditions are met: |
- | |
| 19 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
| 20 | * this list of conditions and the following disclaimer. |
- | |
| 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
| 22 | * this list of conditions and the following disclaimer in the documentation |
- | |
| 23 | * and/or other materials provided with the distribution. |
- | |
| 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
| 25 | * may be used to endorse or promote products derived from this software |
- | |
| 26 | * without specific prior written permission. |
16 | * All rights reserved.</center></h2> |
| 27 | * |
17 | * |
| 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
18 | * This software component is licensed by ST under BSD 3-Clause license, |
| 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
| 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
| 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
| 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
| 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
19 | * the "License"; You may not use this file except in compliance with the |
| 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
20 | * License. You may obtain a copy of the License at: |
| 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
| 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
| 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
21 | * opensource.org/licenses/BSD-3-Clause |
| 38 | * |
22 | * |
| 39 | ****************************************************************************** |
23 | ****************************************************************************** |
| 40 | */ |
24 | */ |
| 41 | 25 | ||
| 42 | /* Includes ------------------------------------------------------------------*/ |
26 | /* Includes ------------------------------------------------------------------*/ |
| 43 | #include "stm32f1xx_hal.h" |
27 | #include "stm32f1xx_hal.h" |
| 44 | 28 | ||
| 45 | /** @addtogroup STM32F1xx_HAL_Driver |
29 | /** @addtogroup STM32F1xx_HAL_Driver |
| 46 | * @{ |
30 | * @{ |
| 47 | */ |
31 | */ |
| 48 | 32 | ||
| 49 | #ifdef HAL_RTC_MODULE_ENABLED |
33 | #ifdef HAL_RTC_MODULE_ENABLED |
| 50 | 34 | ||
| 51 | /** @defgroup RTCEx RTCEx |
35 | /** @defgroup RTCEx RTCEx |
| 52 | * @brief RTC Extended HAL module driver |
36 | * @brief RTC Extended HAL module driver |
| 53 | * @{ |
37 | * @{ |
| 54 | */ |
38 | */ |
| 55 | 39 | ||
| 56 | /* Private typedef -----------------------------------------------------------*/ |
40 | /* Private typedef -----------------------------------------------------------*/ |
| 57 | /* Private define ------------------------------------------------------------*/ |
41 | /* Private define ------------------------------------------------------------*/ |
| 58 | /* Private macro -------------------------------------------------------------*/ |
42 | /* Private macro -------------------------------------------------------------*/ |
| 59 | /** @defgroup RTCEx_Private_Macros RTCEx Private Macros |
43 | /** @defgroup RTCEx_Private_Macros RTCEx Private Macros |
| 60 | * @{ |
44 | * @{ |
| 61 | */ |
45 | */ |
| 62 | /** |
46 | /** |
| 63 | * @} |
47 | * @} |
| 64 | */ |
48 | */ |
| 65 | 49 | ||
| 66 | /* Private variables ---------------------------------------------------------*/ |
50 | /* Private variables ---------------------------------------------------------*/ |
| 67 | /* Private function prototypes -----------------------------------------------*/ |
51 | /* Private function prototypes -----------------------------------------------*/ |
| 68 | /* Private functions ---------------------------------------------------------*/ |
52 | /* Private functions ---------------------------------------------------------*/ |
| 69 | 53 | ||
| 70 | /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions |
54 | /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions |
| 71 | * @{ |
55 | * @{ |
| 72 | */ |
56 | */ |
| 73 | 57 | ||
| 74 | /** @defgroup RTCEx_Exported_Functions_Group1 RTC Tamper functions |
58 | /** @defgroup RTCEx_Exported_Functions_Group1 RTC Tamper functions |
| 75 | * @brief RTC Tamper functions |
59 | * @brief RTC Tamper functions |
| 76 | * |
60 | * |
| 77 | @verbatim |
61 | @verbatim |
| 78 | =============================================================================== |
62 | =============================================================================== |
| 79 | ##### RTC Tamper functions ##### |
63 | ##### RTC Tamper functions ##### |
| 80 | =============================================================================== |
64 | =============================================================================== |
| 81 | |
65 | |
| 82 | [..] This section provides functions allowing to configure Tamper feature |
66 | [..] This section provides functions allowing to configure Tamper feature |
| 83 | 67 | ||
| 84 | @endverbatim |
68 | @endverbatim |
| 85 | * @{ |
69 | * @{ |
| 86 | */ |
70 | */ |
| 87 | 71 | ||
| 88 | /** |
72 | /** |
| 89 | * @brief Sets Tamper |
73 | * @brief Sets Tamper |
| 90 | * @note By calling this API we disable the tamper interrupt for all tampers. |
74 | * @note By calling this API we disable the tamper interrupt for all tampers. |
| 91 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
75 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 92 | * the configuration information for RTC. |
76 | * the configuration information for RTC. |
| 93 | * @param sTamper: Pointer to Tamper Structure. |
77 | * @param sTamper: Pointer to Tamper Structure. |
| 94 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
78 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
| 95 | * @retval HAL status |
79 | * @retval HAL status |
| 96 | */ |
80 | */ |
| 97 | HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
81 | HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper) |
| 98 | { |
82 | { |
| 99 | /* Check input parameters */ |
83 | /* Check input parameters */ |
| 100 | if((hrtc == NULL) || (sTamper == NULL)) |
84 | if ((hrtc == NULL) || (sTamper == NULL)) |
| 101 | { |
85 | { |
| 102 | return HAL_ERROR; |
86 | return HAL_ERROR; |
| 103 | } |
87 | } |
| 104 | 88 | ||
| 105 | /* Check the parameters */ |
89 | /* Check the parameters */ |
| 106 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
90 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
| 107 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
91 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
| 108 | 92 | ||
| 109 | /* Process Locked */ |
93 | /* Process Locked */ |
| 110 | __HAL_LOCK(hrtc); |
94 | __HAL_LOCK(hrtc); |
| 111 | 95 | ||
| 112 | hrtc->State = HAL_RTC_STATE_BUSY; |
96 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 113 | 97 | ||
| 114 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
98 | if (HAL_IS_BIT_SET(BKP->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
| 115 | { |
99 | { |
| 116 | hrtc->State = HAL_RTC_STATE_ERROR; |
100 | hrtc->State = HAL_RTC_STATE_ERROR; |
| 117 | 101 | ||
| 118 | /* Process Unlocked */ |
102 | /* Process Unlocked */ |
| 119 | __HAL_UNLOCK(hrtc); |
103 | __HAL_UNLOCK(hrtc); |
| 120 | 104 | ||
| 121 | return HAL_ERROR; |
105 | return HAL_ERROR; |
| 122 | } |
106 | } |
| 123 | 107 | ||
| 124 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
108 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
| 125 | 109 | ||
| 126 | hrtc->State = HAL_RTC_STATE_READY; |
110 | hrtc->State = HAL_RTC_STATE_READY; |
| 127 | 111 | ||
| 128 | /* Process Unlocked */ |
112 | /* Process Unlocked */ |
| 129 | __HAL_UNLOCK(hrtc); |
113 | __HAL_UNLOCK(hrtc); |
| 130 | 114 | ||
| 131 | return HAL_OK; |
115 | return HAL_OK; |
| Line 138... | Line 122... | ||
| 138 | * the configuration information for RTC. |
122 | * the configuration information for RTC. |
| 139 | * @param sTamper: Pointer to RTC Tamper. |
123 | * @param sTamper: Pointer to RTC Tamper. |
| 140 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
124 | * @note Tamper can be enabled only if ASOE and CCO bit are reset |
| 141 | * @retval HAL status |
125 | * @retval HAL status |
| 142 | */ |
126 | */ |
| 143 | HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper) |
127 | HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper) |
| 144 | { |
128 | { |
| 145 | /* Check input parameters */ |
129 | /* Check input parameters */ |
| 146 | if((hrtc == NULL) || (sTamper == NULL)) |
130 | if ((hrtc == NULL) || (sTamper == NULL)) |
| 147 | { |
131 | { |
| 148 | return HAL_ERROR; |
132 | return HAL_ERROR; |
| 149 | } |
133 | } |
| 150 | 134 | ||
| 151 | /* Check the parameters */ |
135 | /* Check the parameters */ |
| 152 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
136 | assert_param(IS_RTC_TAMPER(sTamper->Tamper)); |
| 153 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
137 | assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger)); |
| 154 | 138 | ||
| 155 | /* Process Locked */ |
139 | /* Process Locked */ |
| 156 | __HAL_LOCK(hrtc); |
140 | __HAL_LOCK(hrtc); |
| 157 | 141 | ||
| 158 | hrtc->State = HAL_RTC_STATE_BUSY; |
142 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 159 | 143 | ||
| 160 | if (HAL_IS_BIT_SET(BKP->RTCCR,(BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
144 | if (HAL_IS_BIT_SET(BKP->RTCCR, (BKP_RTCCR_CCO | BKP_RTCCR_ASOE))) |
| 161 | { |
145 | { |
| 162 | hrtc->State = HAL_RTC_STATE_ERROR; |
146 | hrtc->State = HAL_RTC_STATE_ERROR; |
| 163 | 147 | ||
| 164 | /* Process Unlocked */ |
148 | /* Process Unlocked */ |
| 165 | __HAL_UNLOCK(hrtc); |
149 | __HAL_UNLOCK(hrtc); |
| 166 | 150 | ||
| 167 | return HAL_ERROR; |
151 | return HAL_ERROR; |
| 168 | } |
152 | } |
| 169 | 153 | ||
| 170 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
154 | MODIFY_REG(BKP->CR, (BKP_CR_TPE | BKP_CR_TPAL), (sTamper->Tamper | (sTamper->Trigger))); |
| 171 | 155 | ||
| Line 189... | Line 173... | ||
| 189 | * @retval HAL status |
173 | * @retval HAL status |
| 190 | */ |
174 | */ |
| 191 | HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper) |
175 | HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper) |
| 192 | { |
176 | { |
| 193 | /* Check input parameters */ |
177 | /* Check input parameters */ |
| 194 | if(hrtc == NULL) |
178 | if (hrtc == NULL) |
| 195 | { |
179 | { |
| 196 | return HAL_ERROR; |
180 | return HAL_ERROR; |
| 197 | } |
181 | } |
| 198 | /* Prevent unused argument(s) compilation warning */ |
182 | /* Prevent unused argument(s) compilation warning */ |
| 199 | UNUSED(Tamper); |
183 | UNUSED(Tamper); |
| 200 | 184 | ||
| 201 | assert_param(IS_RTC_TAMPER(Tamper)); |
185 | assert_param(IS_RTC_TAMPER(Tamper)); |
| Line 205... | Line 189... | ||
| 205 | 189 | ||
| 206 | hrtc->State = HAL_RTC_STATE_BUSY; |
190 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 207 | 191 | ||
| 208 | /* Disable the selected Tamper pin */ |
192 | /* Disable the selected Tamper pin */ |
| 209 | CLEAR_BIT(BKP->CR, BKP_CR_TPE); |
193 | CLEAR_BIT(BKP->CR, BKP_CR_TPE); |
| 210 | 194 | ||
| 211 | /* Disable the Tamper Interrupt in the BKP->CSR */ |
195 | /* Disable the Tamper Interrupt in the BKP->CSR */ |
| 212 | /* Configure the Tamper Interrupt in the BKP->CSR */ |
196 | /* Configure the Tamper Interrupt in the BKP->CSR */ |
| 213 | __HAL_RTC_TAMPER_DISABLE_IT(hrtc, RTC_IT_TAMP1); |
197 | __HAL_RTC_TAMPER_DISABLE_IT(hrtc, RTC_IT_TAMP1); |
| 214 | 198 | ||
| 215 | /* Clear the Tamper interrupt pending bit */ |
199 | /* Clear the Tamper interrupt pending bit */ |
| 216 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F); |
200 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F); |
| 217 | SET_BIT(BKP->CSR, BKP_CSR_CTE); |
201 | SET_BIT(BKP->CSR, BKP_CSR_CTE); |
| 218 | 202 | ||
| 219 | hrtc->State = HAL_RTC_STATE_READY; |
203 | hrtc->State = HAL_RTC_STATE_READY; |
| 220 | 204 | ||
| 221 | /* Process Unlocked */ |
205 | /* Process Unlocked */ |
| 222 | __HAL_UNLOCK(hrtc); |
206 | __HAL_UNLOCK(hrtc); |
| 223 | 207 | ||
| Line 229... | Line 213... | ||
| 229 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
213 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 230 | * the configuration information for RTC. |
214 | * the configuration information for RTC. |
| 231 | * @retval None |
215 | * @retval None |
| 232 | */ |
216 | */ |
| 233 | void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc) |
217 | void HAL_RTCEx_TamperIRQHandler(RTC_HandleTypeDef *hrtc) |
| 234 | { |
218 | { |
| 235 | /* Get the status of the Interrupt */ |
219 | /* Get the status of the Interrupt */ |
| 236 | if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP1)) |
220 | if (__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP1)) |
| 237 | { |
221 | { |
| 238 | /* Get the TAMPER Interrupt enable bit and pending bit */ |
222 | /* Get the TAMPER Interrupt enable bit and pending bit */ |
| 239 | if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != (uint32_t)RESET) |
223 | if (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != (uint32_t)RESET) |
| 240 | { |
224 | { |
| 241 | /* Tamper callback */ |
225 | /* Tamper callback */ |
| - | 226 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
|
| - | 227 | hrtc->Tamper1EventCallback(hrtc); |
|
| - | 228 | #else |
|
| 242 | HAL_RTCEx_Tamper1EventCallback(hrtc); |
229 | HAL_RTCEx_Tamper1EventCallback(hrtc); |
| - | 230 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
|
| 243 | 231 | ||
| 244 | /* Clear the Tamper interrupt pending bit */ |
232 | /* Clear the Tamper interrupt pending bit */ |
| 245 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F); |
233 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F); |
| 246 | } |
234 | } |
| 247 | } |
235 | } |
| 248 | 236 | ||
| 249 | /* Change RTC state */ |
237 | /* Change RTC state */ |
| 250 | hrtc->State = HAL_RTC_STATE_READY; |
238 | hrtc->State = HAL_RTC_STATE_READY; |
| 251 | } |
239 | } |
| 252 | 240 | ||
| 253 | /** |
241 | /** |
| 254 | * @brief Tamper 1 callback. |
242 | * @brief Tamper 1 callback. |
| 255 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
243 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 256 | * the configuration information for RTC. |
244 | * the configuration information for RTC. |
| 257 | * @retval None |
245 | * @retval None |
| 258 | */ |
246 | */ |
| 259 | __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc) |
247 | __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc) |
| Line 271... | Line 259... | ||
| 271 | * the configuration information for RTC. |
259 | * the configuration information for RTC. |
| 272 | * @param Timeout: Timeout duration |
260 | * @param Timeout: Timeout duration |
| 273 | * @retval HAL status |
261 | * @retval HAL status |
| 274 | */ |
262 | */ |
| 275 | HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout) |
263 | HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout) |
| 276 | { |
264 | { |
| 277 | uint32_t tickstart = HAL_GetTick(); |
265 | uint32_t tickstart = HAL_GetTick(); |
| 278 | 266 | ||
| 279 | /* Check input parameters */ |
267 | /* Check input parameters */ |
| 280 | if(hrtc == NULL) |
268 | if (hrtc == NULL) |
| 281 | { |
269 | { |
| 282 | return HAL_ERROR; |
270 | return HAL_ERROR; |
| 283 | } |
271 | } |
| 284 | 272 | ||
| 285 | /* Get the status of the Interrupt */ |
273 | /* Get the status of the Interrupt */ |
| 286 | while(__HAL_RTC_TAMPER_GET_FLAG(hrtc,RTC_FLAG_TAMP1F)== RESET) |
274 | while (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) == RESET) |
| 287 | { |
275 | { |
| 288 | if(Timeout != HAL_MAX_DELAY) |
276 | if (Timeout != HAL_MAX_DELAY) |
| 289 | { |
277 | { |
| 290 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
278 | if ((Timeout == 0U) || ((HAL_GetTick() - tickstart) > Timeout)) |
| 291 | { |
279 | { |
| 292 | hrtc->State = HAL_RTC_STATE_TIMEOUT; |
280 | hrtc->State = HAL_RTC_STATE_TIMEOUT; |
| 293 | return HAL_TIMEOUT; |
281 | return HAL_TIMEOUT; |
| 294 | } |
282 | } |
| 295 | } |
283 | } |
| 296 | } |
284 | } |
| 297 | 285 | ||
| 298 | /* Clear the Tamper Flag */ |
286 | /* Clear the Tamper Flag */ |
| 299 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F); |
287 | __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F); |
| 300 | 288 | ||
| 301 | /* Change RTC state */ |
289 | /* Change RTC state */ |
| 302 | hrtc->State = HAL_RTC_STATE_READY; |
290 | hrtc->State = HAL_RTC_STATE_READY; |
| 303 | 291 | ||
| 304 | return HAL_OK; |
292 | return HAL_OK; |
| 305 | } |
293 | } |
| 306 | 294 | ||
| 307 | /** |
295 | /** |
| 308 | * @} |
296 | * @} |
| 309 | */ |
297 | */ |
| 310 | 298 | ||
| 311 | /** @defgroup RTCEx_Exported_Functions_Group2 RTC Second functions |
299 | /** @defgroup RTCEx_Exported_Functions_Group2 RTC Second functions |
| 312 | * @brief RTC Second functions |
300 | * @brief RTC Second functions |
| 313 | * |
301 | * |
| 314 | @verbatim |
302 | @verbatim |
| 315 | =============================================================================== |
303 | =============================================================================== |
| 316 | ##### RTC Second functions ##### |
304 | ##### RTC Second functions ##### |
| 317 | =============================================================================== |
305 | =============================================================================== |
| 318 | |
306 | |
| 319 | [..] This section provides functions implementing second interupt handlers |
307 | [..] This section provides functions implementing second interupt handlers |
| 320 | 308 | ||
| 321 | @endverbatim |
309 | @endverbatim |
| 322 | * @{ |
310 | * @{ |
| 323 | */ |
311 | */ |
| Line 329... | Line 317... | ||
| 329 | * @retval HAL status |
317 | * @retval HAL status |
| 330 | */ |
318 | */ |
| 331 | HAL_StatusTypeDef HAL_RTCEx_SetSecond_IT(RTC_HandleTypeDef *hrtc) |
319 | HAL_StatusTypeDef HAL_RTCEx_SetSecond_IT(RTC_HandleTypeDef *hrtc) |
| 332 | { |
320 | { |
| 333 | /* Check input parameters */ |
321 | /* Check input parameters */ |
| 334 | if(hrtc == NULL) |
322 | if (hrtc == NULL) |
| 335 | { |
323 | { |
| 336 | return HAL_ERROR; |
324 | return HAL_ERROR; |
| 337 | } |
325 | } |
| 338 | 326 | ||
| 339 | /* Process Locked */ |
327 | /* Process Locked */ |
| 340 | __HAL_LOCK(hrtc); |
328 | __HAL_LOCK(hrtc); |
| 341 | 329 | ||
| 342 | hrtc->State = HAL_RTC_STATE_BUSY; |
330 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 343 | 331 | ||
| 344 | /* Enable Second interuption */ |
332 | /* Enable Second interuption */ |
| 345 | __HAL_RTC_SECOND_ENABLE_IT(hrtc, RTC_IT_SEC); |
333 | __HAL_RTC_SECOND_ENABLE_IT(hrtc, RTC_IT_SEC); |
| 346 | 334 | ||
| 347 | hrtc->State = HAL_RTC_STATE_READY; |
335 | hrtc->State = HAL_RTC_STATE_READY; |
| 348 | 336 | ||
| 349 | /* Process Unlocked */ |
337 | /* Process Unlocked */ |
| 350 | __HAL_UNLOCK(hrtc); |
338 | __HAL_UNLOCK(hrtc); |
| 351 | 339 | ||
| Line 359... | Line 347... | ||
| 359 | * @retval HAL status |
347 | * @retval HAL status |
| 360 | */ |
348 | */ |
| 361 | HAL_StatusTypeDef HAL_RTCEx_DeactivateSecond(RTC_HandleTypeDef *hrtc) |
349 | HAL_StatusTypeDef HAL_RTCEx_DeactivateSecond(RTC_HandleTypeDef *hrtc) |
| 362 | { |
350 | { |
| 363 | /* Check input parameters */ |
351 | /* Check input parameters */ |
| 364 | if(hrtc == NULL) |
352 | if (hrtc == NULL) |
| 365 | { |
353 | { |
| 366 | return HAL_ERROR; |
354 | return HAL_ERROR; |
| 367 | } |
355 | } |
| 368 | 356 | ||
| 369 | /* Process Locked */ |
357 | /* Process Locked */ |
| 370 | __HAL_LOCK(hrtc); |
358 | __HAL_LOCK(hrtc); |
| 371 | 359 | ||
| 372 | hrtc->State = HAL_RTC_STATE_BUSY; |
360 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 373 | 361 | ||
| 374 | /* Deactivate Second interuption*/ |
362 | /* Deactivate Second interuption*/ |
| 375 | __HAL_RTC_SECOND_DISABLE_IT(hrtc, RTC_IT_SEC); |
363 | __HAL_RTC_SECOND_DISABLE_IT(hrtc, RTC_IT_SEC); |
| 376 | 364 | ||
| 377 | hrtc->State = HAL_RTC_STATE_READY; |
365 | hrtc->State = HAL_RTC_STATE_READY; |
| 378 | 366 | ||
| 379 | /* Process Unlocked */ |
367 | /* Process Unlocked */ |
| 380 | __HAL_UNLOCK(hrtc); |
368 | __HAL_UNLOCK(hrtc); |
| 381 | 369 | ||
| Line 386... | Line 374... | ||
| 386 | * @brief This function handles second interrupt request. |
374 | * @brief This function handles second interrupt request. |
| 387 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
375 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 388 | * the configuration information for RTC. |
376 | * the configuration information for RTC. |
| 389 | * @retval None |
377 | * @retval None |
| 390 | */ |
378 | */ |
| 391 | void HAL_RTCEx_RTCIRQHandler(RTC_HandleTypeDef* hrtc) |
379 | void HAL_RTCEx_RTCIRQHandler(RTC_HandleTypeDef *hrtc) |
| 392 | { |
380 | { |
| 393 | if(__HAL_RTC_SECOND_GET_IT_SOURCE(hrtc, RTC_IT_SEC)) |
381 | if (__HAL_RTC_SECOND_GET_IT_SOURCE(hrtc, RTC_IT_SEC)) |
| 394 | { |
382 | { |
| 395 | /* Get the status of the Interrupt */ |
383 | /* Get the status of the Interrupt */ |
| 396 | if(__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_SEC)) |
384 | if (__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_SEC)) |
| 397 | { |
385 | { |
| 398 | /* Check if Overrun occurred */ |
386 | /* Check if Overrun occurred */ |
| 399 | if (__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_OW)) |
387 | if (__HAL_RTC_SECOND_GET_FLAG(hrtc, RTC_FLAG_OW)) |
| 400 | { |
388 | { |
| 401 | /* Second error callback */ |
389 | /* Second error callback */ |
| 402 | HAL_RTCEx_RTCEventErrorCallback(hrtc); |
390 | HAL_RTCEx_RTCEventErrorCallback(hrtc); |
| 403 | 391 | ||
| 404 | /* Clear flag Second */ |
392 | /* Clear flag Second */ |
| 405 | __HAL_RTC_OVERFLOW_CLEAR_FLAG(hrtc, RTC_FLAG_OW); |
393 | __HAL_RTC_OVERFLOW_CLEAR_FLAG(hrtc, RTC_FLAG_OW); |
| 406 | 394 | ||
| 407 | /* Change RTC state */ |
395 | /* Change RTC state */ |
| 408 | hrtc->State = HAL_RTC_STATE_ERROR; |
396 | hrtc->State = HAL_RTC_STATE_ERROR; |
| 409 | } |
397 | } |
| 410 | else |
398 | else |
| 411 | { |
399 | { |
| 412 | /* Second callback */ |
400 | /* Second callback */ |
| 413 | HAL_RTCEx_RTCEventCallback(hrtc); |
401 | HAL_RTCEx_RTCEventCallback(hrtc); |
| 414 | 402 | ||
| 415 | /* Change RTC state */ |
403 | /* Change RTC state */ |
| 416 | hrtc->State = HAL_RTC_STATE_READY; |
404 | hrtc->State = HAL_RTC_STATE_READY; |
| 417 | } |
405 | } |
| 418 | 406 | ||
| 419 | /* Clear flag Second */ |
407 | /* Clear flag Second */ |
| 420 | __HAL_RTC_SECOND_CLEAR_FLAG(hrtc, RTC_FLAG_SEC); |
408 | __HAL_RTC_SECOND_CLEAR_FLAG(hrtc, RTC_FLAG_SEC); |
| 421 | } |
409 | } |
| 422 | } |
410 | } |
| 423 | } |
411 | } |
| Line 453... | Line 441... | ||
| 453 | } |
441 | } |
| 454 | 442 | ||
| 455 | /** |
443 | /** |
| 456 | * @} |
444 | * @} |
| 457 | */ |
445 | */ |
| 458 | 446 | ||
| 459 | /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions |
447 | /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions |
| 460 | * @brief Extended Peripheral Control functions |
448 | * @brief Extended Peripheral Control functions |
| 461 | * |
449 | * |
| 462 | @verbatim |
450 | @verbatim |
| 463 | =============================================================================== |
451 | =============================================================================== |
| 464 | ##### Extension Peripheral Control functions ##### |
452 | ##### Extension Peripheral Control functions ##### |
| 465 | =============================================================================== |
453 | =============================================================================== |
| 466 | [..] |
454 | [..] |
| 467 | This subsection provides functions allowing to |
455 | This subsection provides functions allowing to |
| 468 | (+) Writes a data in a specified RTC Backup data register |
456 | (+) Writes a data in a specified RTC Backup data register |
| 469 | (+) Read a data in a specified RTC Backup data register |
457 | (+) Read a data in a specified RTC Backup data register |
| 470 | (+) Sets the Smooth calibration parameters. |
458 | (+) Sets the Smooth calibration parameters. |
| Line 474... | Line 462... | ||
| 474 | */ |
462 | */ |
| 475 | 463 | ||
| 476 | /** |
464 | /** |
| 477 | * @brief Writes a data in a specified RTC Backup data register. |
465 | * @brief Writes a data in a specified RTC Backup data register. |
| 478 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
466 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 479 | * the configuration information for RTC. |
467 | * the configuration information for RTC. |
| 480 | * @param BackupRegister: RTC Backup data Register number. |
468 | * @param BackupRegister: RTC Backup data Register number. |
| 481 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
469 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
| 482 | * specify the register (depending devices). |
470 | * specify the register (depending devices). |
| 483 | * @param Data: Data to be written in the specified RTC Backup data register. |
471 | * @param Data: Data to be written in the specified RTC Backup data register. |
| 484 | * @retval None |
472 | * @retval None |
| 485 | */ |
473 | */ |
| 486 | void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data) |
474 | void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data) |
| 487 | { |
475 | { |
| 488 | uint32_t tmp = 0U; |
476 | uint32_t tmp = 0U; |
| Line 490... | Line 478... | ||
| 490 | /* Prevent unused argument(s) compilation warning */ |
478 | /* Prevent unused argument(s) compilation warning */ |
| 491 | UNUSED(hrtc); |
479 | UNUSED(hrtc); |
| 492 | 480 | ||
| 493 | /* Check the parameters */ |
481 | /* Check the parameters */ |
| 494 | assert_param(IS_RTC_BKP(BackupRegister)); |
482 | assert_param(IS_RTC_BKP(BackupRegister)); |
| 495 | 483 | ||
| 496 | tmp = (uint32_t)BKP_BASE; |
484 | tmp = (uint32_t)BKP_BASE; |
| 497 | tmp += (BackupRegister * 4U); |
485 | tmp += (BackupRegister * 4U); |
| 498 | 486 | ||
| 499 | *(__IO uint32_t *) tmp = (Data & BKP_DR1_D); |
487 | *(__IO uint32_t *) tmp = (Data & BKP_DR1_D); |
| 500 | } |
488 | } |
| 501 | 489 | ||
| 502 | /** |
490 | /** |
| 503 | * @brief Reads data from the specified RTC Backup data Register. |
491 | * @brief Reads data from the specified RTC Backup data Register. |
| 504 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
492 | * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains |
| 505 | * the configuration information for RTC. |
493 | * the configuration information for RTC. |
| 506 | * @param BackupRegister: RTC Backup data Register number. |
494 | * @param BackupRegister: RTC Backup data Register number. |
| 507 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
495 | * This parameter can be: RTC_BKP_DRx where x can be from 1 to 10 (or 42) to |
| 508 | * specify the register (depending devices). |
496 | * specify the register (depending devices). |
| 509 | * @retval Read value |
497 | * @retval Read value |
| 510 | */ |
498 | */ |
| 511 | uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) |
499 | uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister) |
| 512 | { |
500 | { |
| Line 517... | Line 505... | ||
| 517 | UNUSED(hrtc); |
505 | UNUSED(hrtc); |
| 518 | 506 | ||
| 519 | /* Check the parameters */ |
507 | /* Check the parameters */ |
| 520 | assert_param(IS_RTC_BKP(BackupRegister)); |
508 | assert_param(IS_RTC_BKP(BackupRegister)); |
| 521 | 509 | ||
| 522 | backupregister = (uint32_t)BKP_BASE; |
510 | backupregister = (uint32_t)BKP_BASE; |
| 523 | backupregister += (BackupRegister * 4U); |
511 | backupregister += (BackupRegister * 4U); |
| 524 | 512 | ||
| 525 | pvalue = (*(__IO uint32_t *)(backupregister)) & BKP_DR1_D; |
513 | pvalue = (*(__IO uint32_t *)(backupregister)) & BKP_DR1_D; |
| 526 | 514 | ||
| 527 | /* Read the specified register */ |
515 | /* Read the specified register */ |
| 528 | return pvalue; |
516 | return pvalue; |
| 529 | } |
517 | } |
| 530 | 518 | ||
| 531 | 519 | ||
| 532 | /** |
520 | /** |
| 533 | * @brief Sets the Smooth calibration parameters. |
521 | * @brief Sets the Smooth calibration parameters. |
| 534 | * @param hrtc: RTC handle |
522 | * @param hrtc: RTC handle |
| 535 | * @param SmoothCalibPeriod: Not used (only present for compatibility with another families) |
523 | * @param SmoothCalibPeriod: Not used (only present for compatibility with another families) |
| 536 | * @param SmoothCalibPlusPulses: Not used (only present for compatibility with another families) |
524 | * @param SmoothCalibPlusPulses: Not used (only present for compatibility with another families) |
| 537 | * @param SmouthCalibMinusPulsesValue: specifies the RTC Clock Calibration value. |
525 | * @param SmouthCalibMinusPulsesValue: specifies the RTC Clock Calibration value. |
| 538 | * This parameter must be a number between 0 and 0x7F. |
526 | * This parameter must be a number between 0 and 0x7F. |
| 539 | * @retval HAL status |
527 | * @retval HAL status |
| 540 | */ |
528 | */ |
| 541 | HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue) |
529 | HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmouthCalibMinusPulsesValue) |
| 542 | { |
530 | { |
| 543 | /* Check input parameters */ |
531 | /* Check input parameters */ |
| 544 | if(hrtc == NULL) |
532 | if (hrtc == NULL) |
| 545 | { |
533 | { |
| 546 | return HAL_ERROR; |
534 | return HAL_ERROR; |
| 547 | } |
535 | } |
| 548 | /* Prevent unused argument(s) compilation warning */ |
536 | /* Prevent unused argument(s) compilation warning */ |
| 549 | UNUSED(SmoothCalibPeriod); |
537 | UNUSED(SmoothCalibPeriod); |
| 550 | UNUSED(SmoothCalibPlusPulses); |
538 | UNUSED(SmoothCalibPlusPulses); |
| 551 | 539 | ||
| 552 | /* Check the parameters */ |
540 | /* Check the parameters */ |
| 553 | assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmouthCalibMinusPulsesValue)); |
541 | assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmouthCalibMinusPulsesValue)); |
| 554 | 542 | ||
| 555 | /* Process Locked */ |
543 | /* Process Locked */ |
| 556 | __HAL_LOCK(hrtc); |
544 | __HAL_LOCK(hrtc); |
| 557 | 545 | ||
| 558 | hrtc->State = HAL_RTC_STATE_BUSY; |
546 | hrtc->State = HAL_RTC_STATE_BUSY; |
| 559 | 547 | ||
| Line 574... | Line 562... | ||
| 574 | */ |
562 | */ |
| 575 | 563 | ||
| 576 | /** |
564 | /** |
| 577 | * @} |
565 | * @} |
| 578 | */ |
566 | */ |
| 579 | 567 | ||
| 580 | /** |
568 | /** |
| 581 | * @} |
569 | * @} |
| 582 | */ |
570 | */ |
| 583 | 571 | ||
| 584 | #endif /* HAL_RTC_MODULE_ENABLED */ |
572 | #endif /* HAL_RTC_MODULE_ENABLED */ |