FIX: Flash page size check is STM (or clone) specific (#14130)
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_HAL_Driver / Inc / stm32f4xx_hal_rtc.h
blob53d79cfdd4834b804a378b412af99cc119042b0e
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_rtc.h
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 14-April-2017
7 * @brief Header file of RTC HAL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
36 */
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_RTC_H
40 #define __STM32F4xx_HAL_RTC_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f4xx_hal_def.h"
49 /** @addtogroup STM32F4xx_HAL_Driver
50 * @{
53 /** @addtogroup RTC
54 * @{
55 */
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup RTC_Exported_Types RTC Exported Types
59 * @{
62 /**
63 * @brief HAL State structures definition
65 typedef enum
67 HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */
68 HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */
69 HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */
70 HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */
71 HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */
72 }HAL_RTCStateTypeDef;
74 /**
75 * @brief RTC Configuration Structure definition
77 typedef struct
79 uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
80 This parameter can be a value of @ref RTC_Hour_Formats */
82 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
83 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
85 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
86 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFFU */
88 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
89 This parameter can be a value of @ref RTC_Output_selection_Definitions */
91 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
92 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
94 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
95 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
96 }RTC_InitTypeDef;
98 /**
99 * @brief RTC Time structure definition
101 typedef struct
103 uint8_t Hours; /*!< Specifies the RTC Time Hour.
104 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
105 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
107 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
108 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
110 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
111 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
113 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
114 This parameter can be a value of @ref RTC_AM_PM_Definitions */
116 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content.
117 This parameter corresponds to a time unit range between [0-1] Second
118 with [1 Sec / SecondFraction +1] granularity */
120 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content
121 corresponding to Synchronous pre-scaler factor value (PREDIV_S)
122 This parameter corresponds to a time unit range between [0-1] Second
123 with [1 Sec / SecondFraction +1] granularity.
124 This field will be used only by HAL_RTC_GetTime function */
126 uint32_t DayLightSaving; /*!< Specifies DayLight Save Operation.
127 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
129 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
130 in CR register to store the operation.
131 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
132 }RTC_TimeTypeDef;
134 /**
135 * @brief RTC Date structure definition
137 typedef struct
139 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
140 This parameter can be a value of @ref RTC_WeekDay_Definitions */
142 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
143 This parameter can be a value of @ref RTC_Month_Date_Definitions */
145 uint8_t Date; /*!< Specifies the RTC Date.
146 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
148 uint8_t Year; /*!< Specifies the RTC Date Year.
149 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
151 }RTC_DateTypeDef;
153 /**
154 * @brief RTC Alarm structure definition
156 typedef struct
158 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
160 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
161 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
163 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
164 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
166 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
167 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
169 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
170 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
171 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
173 uint32_t Alarm; /*!< Specifies the alarm .
174 This parameter can be a value of @ref RTC_Alarms_Definitions */
175 }RTC_AlarmTypeDef;
177 /**
178 * @brief RTC Handle Structure definition
180 typedef struct
182 RTC_TypeDef *Instance; /*!< Register base address */
184 RTC_InitTypeDef Init; /*!< RTC required parameters */
186 HAL_LockTypeDef Lock; /*!< RTC locking object */
188 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
190 }RTC_HandleTypeDef;
193 * @}
196 /* Exported constants --------------------------------------------------------*/
197 /** @defgroup RTC_Exported_Constants RTC Exported Constants
198 * @{
201 /** @defgroup RTC_Hour_Formats RTC Hour Formats
202 * @{
204 #define RTC_HOURFORMAT_24 0x00000000U
205 #define RTC_HOURFORMAT_12 0x00000040U
207 * @}
210 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions
211 * @{
213 #define RTC_OUTPUT_DISABLE 0x00000000U
214 #define RTC_OUTPUT_ALARMA 0x00200000U
215 #define RTC_OUTPUT_ALARMB 0x00400000U
216 #define RTC_OUTPUT_WAKEUP 0x00600000U
218 * @}
221 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
222 * @{
224 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U
225 #define RTC_OUTPUT_POLARITY_LOW 0x00100000U
227 * @}
230 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
231 * @{
233 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U
234 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00040000U
236 * @}
239 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
240 * @{
242 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
243 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40)
245 * @}
248 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions
249 * @{
251 #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U
252 #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U
253 #define RTC_DAYLIGHTSAVING_NONE 0x00000000U
255 * @}
258 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions
259 * @{
261 #define RTC_STOREOPERATION_RESET 0x00000000U
262 #define RTC_STOREOPERATION_SET 0x00040000U
264 * @}
267 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions
268 * @{
270 #define RTC_FORMAT_BIN 0x00000000U
271 #define RTC_FORMAT_BCD 0x00000001U
273 * @}
276 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
277 * @{
279 /* Coded in BCD format */
280 #define RTC_MONTH_JANUARY ((uint8_t)0x01)
281 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
282 #define RTC_MONTH_MARCH ((uint8_t)0x03)
283 #define RTC_MONTH_APRIL ((uint8_t)0x04)
284 #define RTC_MONTH_MAY ((uint8_t)0x05)
285 #define RTC_MONTH_JUNE ((uint8_t)0x06)
286 #define RTC_MONTH_JULY ((uint8_t)0x07)
287 #define RTC_MONTH_AUGUST ((uint8_t)0x08)
288 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
289 #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
290 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
291 #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
293 * @}
296 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
297 * @{
299 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
300 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
301 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
302 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
303 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
304 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
305 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
307 * @}
310 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions
311 * @{
313 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U
314 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U
316 * @}
319 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions
320 * @{
322 #define RTC_ALARMMASK_NONE 0x00000000U
323 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
324 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
325 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
326 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
327 #define RTC_ALARMMASK_ALL 0x80808080U
329 * @}
332 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
333 * @{
335 #define RTC_ALARM_A RTC_CR_ALRAE
336 #define RTC_ALARM_B RTC_CR_ALRBE
338 * @}
341 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
342 * @{
344 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked.
345 There is no comparison on sub seconds
346 for Alarm */
347 #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U /*!< SS[14:1] are don't care in Alarm
348 comparison. Only SS[0] is compared. */
349 #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U /*!< SS[14:2] are don't care in Alarm
350 comparison. Only SS[1:0] are compared */
351 #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U /*!< SS[14:3] are don't care in Alarm
352 comparison. Only SS[2:0] are compared */
353 #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U /*!< SS[14:4] are don't care in Alarm
354 comparison. Only SS[3:0] are compared */
355 #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U /*!< SS[14:5] are don't care in Alarm
356 comparison. Only SS[4:0] are compared */
357 #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U /*!< SS[14:6] are don't care in Alarm
358 comparison. Only SS[5:0] are compared */
359 #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U /*!< SS[14:7] are don't care in Alarm
360 comparison. Only SS[6:0] are compared */
361 #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U /*!< SS[14:8] are don't care in Alarm
362 comparison. Only SS[7:0] are compared */
363 #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U /*!< SS[14:9] are don't care in Alarm
364 comparison. Only SS[8:0] are compared */
365 #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U /*!< SS[14:10] are don't care in Alarm
366 comparison. Only SS[9:0] are compared */
367 #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U /*!< SS[14:11] are don't care in Alarm
368 comparison. Only SS[10:0] are compared */
369 #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U /*!< SS[14:12] are don't care in Alarm
370 comparison.Only SS[11:0] are compared */
371 #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U /*!< SS[14:13] are don't care in Alarm
372 comparison. Only SS[12:0] are compared */
373 #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U /*!< SS[14] is don't care in Alarm
374 comparison.Only SS[13:0] are compared */
375 #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U /*!< SS[14:0] are compared and must match
376 to activate alarm. */
378 * @}
381 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
382 * @{
384 #define RTC_IT_TS 0x00008000U
385 #define RTC_IT_WUT 0x00004000U
386 #define RTC_IT_ALRB 0x00002000U
387 #define RTC_IT_ALRA 0x00001000U
388 #define RTC_IT_TAMP 0x00000004U /* Used only to Enable the Tamper Interrupt */
389 #define RTC_IT_TAMP1 0x00020000U
390 #define RTC_IT_TAMP2 0x00040000U
392 * @}
395 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
396 * @{
398 #define RTC_FLAG_RECALPF 0x00010000U
399 #define RTC_FLAG_TAMP2F 0x00004000U
400 #define RTC_FLAG_TAMP1F 0x00002000U
401 #define RTC_FLAG_TSOVF 0x00001000U
402 #define RTC_FLAG_TSF 0x00000800U
403 #define RTC_FLAG_WUTF 0x00000400U
404 #define RTC_FLAG_ALRBF 0x00000200U
405 #define RTC_FLAG_ALRAF 0x00000100U
406 #define RTC_FLAG_INITF 0x00000040U
407 #define RTC_FLAG_RSF 0x00000020U
408 #define RTC_FLAG_INITS 0x00000010U
409 #define RTC_FLAG_SHPF 0x00000008U
410 #define RTC_FLAG_WUTWF 0x00000004U
411 #define RTC_FLAG_ALRBWF 0x00000002U
412 #define RTC_FLAG_ALRAWF 0x00000001U
414 * @}
418 * @}
421 /* Exported macro ------------------------------------------------------------*/
422 /** @defgroup RTC_Exported_Macros RTC Exported Macros
423 * @{
426 /** @brief Reset RTC handle state
427 * @param __HANDLE__: specifies the RTC handle.
428 * @retval None
430 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
433 * @brief Disable the write protection for RTC registers.
434 * @param __HANDLE__: specifies the RTC handle.
435 * @retval None
437 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
438 do{ \
439 (__HANDLE__)->Instance->WPR = 0xCAU; \
440 (__HANDLE__)->Instance->WPR = 0x53U; \
441 } while(0U)
444 * @brief Enable the write protection for RTC registers.
445 * @param __HANDLE__: specifies the RTC handle.
446 * @retval None
448 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
449 do{ \
450 (__HANDLE__)->Instance->WPR = 0xFFU; \
451 } while(0U)
454 * @brief Enable the RTC ALARMA peripheral.
455 * @param __HANDLE__: specifies the RTC handle.
456 * @retval None
458 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
461 * @brief Disable the RTC ALARMA peripheral.
462 * @param __HANDLE__: specifies the RTC handle.
463 * @retval None
465 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
468 * @brief Enable the RTC ALARMB peripheral.
469 * @param __HANDLE__: specifies the RTC handle.
470 * @retval None
472 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
475 * @brief Disable the RTC ALARMB peripheral.
476 * @param __HANDLE__: specifies the RTC handle.
477 * @retval None
479 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
482 * @brief Enable the RTC Alarm interrupt.
483 * @param __HANDLE__: specifies the RTC handle.
484 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
485 * This parameter can be any combination of the following values:
486 * @arg RTC_IT_ALRA: Alarm A interrupt
487 * @arg RTC_IT_ALRB: Alarm B interrupt
488 * @retval None
490 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
493 * @brief Disable the RTC Alarm interrupt.
494 * @param __HANDLE__: specifies the RTC handle.
495 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
496 * This parameter can be any combination of the following values:
497 * @arg RTC_IT_ALRA: Alarm A interrupt
498 * @arg RTC_IT_ALRB: Alarm B interrupt
499 * @retval None
501 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
504 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
505 * @param __HANDLE__: specifies the RTC handle.
506 * @param __INTERRUPT__: specifies the RTC Alarm interrupt to check.
507 * This parameter can be:
508 * @arg RTC_IT_ALRA: Alarm A interrupt
509 * @arg RTC_IT_ALRB: Alarm B interrupt
510 * @retval None
512 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET)
515 * @brief Get the selected RTC Alarm's flag status.
516 * @param __HANDLE__: specifies the RTC handle.
517 * @param __FLAG__: specifies the RTC Alarm Flag to check.
518 * This parameter can be:
519 * @arg RTC_FLAG_ALRAF
520 * @arg RTC_FLAG_ALRBF
521 * @arg RTC_FLAG_ALRAWF
522 * @arg RTC_FLAG_ALRBWF
523 * @retval None
525 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
528 * @brief Clear the RTC Alarm's pending flags.
529 * @param __HANDLE__: specifies the RTC handle.
530 * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled.
531 * This parameter can be:
532 * @arg RTC_FLAG_ALRAF
533 * @arg RTC_FLAG_ALRBF
534 * @retval None
536 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
540 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not.
541 * @param __HANDLE__: specifies the RTC handle.
542 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
543 * This parameter can be:
544 * @arg RTC_IT_ALRA: Alarm A interrupt
545 * @arg RTC_IT_ALRB: Alarm B interrupt
546 * @retval None
548 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET)
551 * @brief Enable interrupt on the RTC Alarm associated Exti line.
552 * @retval None
554 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
557 * @brief Disable interrupt on the RTC Alarm associated Exti line.
558 * @retval None
560 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
563 * @brief Enable event on the RTC Alarm associated Exti line.
564 * @retval None.
566 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
569 * @brief Disable event on the RTC Alarm associated Exti line.
570 * @retval None.
572 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
575 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
576 * @retval None.
578 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
581 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
582 * @retval None.
584 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
587 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
588 * @retval None.
590 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
593 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
594 * @retval None.
596 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
599 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
600 * @retval None.
602 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \
603 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();\
604 } while(0U)
607 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
608 * @retval None.
610 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();\
611 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();\
612 } while(0U)
615 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
616 * @retval Line Status.
618 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
621 * @brief Clear the RTC Alarm associated Exti line flag.
622 * @retval None.
624 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
627 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
628 * @retval None.
630 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
632 * @}
635 /* Include RTC HAL Extension module */
636 #include "stm32f4xx_hal_rtc_ex.h"
638 /* Exported functions --------------------------------------------------------*/
639 /** @addtogroup RTC_Exported_Functions
640 * @{
643 /** @addtogroup RTC_Exported_Functions_Group1
644 * @{
646 /* Initialization and de-initialization functions ****************************/
647 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
648 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
649 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
650 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
652 * @}
655 /** @addtogroup RTC_Exported_Functions_Group2
656 * @{
658 /* RTC Time and Date functions ************************************************/
659 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
660 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
661 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
662 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
664 * @}
667 /** @addtogroup RTC_Exported_Functions_Group3
668 * @{
670 /* RTC Alarm functions ********************************************************/
671 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
672 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
673 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
674 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
675 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
676 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
677 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
679 * @}
682 /** @addtogroup RTC_Exported_Functions_Group4
683 * @{
685 /* Peripheral Control functions ***********************************************/
686 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc);
688 * @}
691 /** @addtogroup RTC_Exported_Functions_Group5
692 * @{
694 /* Peripheral State functions *************************************************/
695 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
697 * @}
701 * @}
704 /* Private types -------------------------------------------------------------*/
705 /* Private variables ---------------------------------------------------------*/
706 /* Private constants ---------------------------------------------------------*/
707 /** @defgroup RTC_Private_Constants RTC Private Constants
708 * @{
710 /* Masks Definition */
711 #define RTC_TR_RESERVED_MASK 0x007F7F7FU
712 #define RTC_DR_RESERVED_MASK 0x00FFFF3FU
713 #define RTC_INIT_MASK 0xFFFFFFFFU
714 #define RTC_RSF_MASK 0xFFFFFF5FU
715 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \
716 RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \
717 RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \
718 RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \
719 RTC_FLAG_RECALPF | RTC_FLAG_SHPF))
721 #define RTC_TIMEOUT_VALUE 1000
723 #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */
725 * @}
728 /* Private macros ------------------------------------------------------------*/
729 /** @defgroup RTC_Private_Macros RTC Private Macros
730 * @{
733 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters
734 * @{
736 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \
737 ((FORMAT) == RTC_HOURFORMAT_24))
738 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \
739 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \
740 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \
741 ((OUTPUT) == RTC_OUTPUT_WAKEUP))
742 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
743 ((POL) == RTC_OUTPUT_POLARITY_LOW))
744 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
745 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
746 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U))
747 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U)
748 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU)
749 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU)
750 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U)
751 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U)
753 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM))
754 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
755 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
756 ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
757 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
758 ((OPERATION) == RTC_STOREOPERATION_SET))
759 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
760 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U)
761 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U))
762 #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U))
763 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
764 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
765 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
766 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
767 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
768 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
769 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
770 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U))
771 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
772 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
773 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
774 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \
775 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \
776 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
777 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
778 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
779 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
780 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7FU) == (uint32_t)RESET)
781 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B))
782 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFFU)
784 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \
785 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
786 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
787 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
788 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
789 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
790 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
791 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
792 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
793 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
794 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
795 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
796 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
797 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
798 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \
799 ((MASK) == RTC_ALARMSUBSECONDMASK_NONE))
801 * @}
805 * @}
808 /* Private functions ---------------------------------------------------------*/
809 /** @defgroup RTC_Private_Functions RTC Private Functions
810 * @{
812 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc);
813 uint8_t RTC_ByteToBcd2(uint8_t Value);
814 uint8_t RTC_Bcd2ToByte(uint8_t Value);
816 * @}
820 * @}
824 * @}
827 #ifdef __cplusplus
829 #endif
831 #endif /* __STM32F4xx_HAL_RTC_H */
833 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/