STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_rtc.h 00004 * @author MCD Application Team 00005 * @brief Header file of RTC HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32H7xx_HAL_RTC_H 00021 #define STM32H7xx_HAL_RTC_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx_hal_def.h" 00029 00030 /** @addtogroup STM32H7xx_HAL_Driver 00031 * @{ 00032 */ 00033 00034 /** @defgroup RTC RTC 00035 * @{ 00036 */ 00037 00038 /* Exported types ------------------------------------------------------------*/ 00039 /** @defgroup RTC_Exported_Types RTC Exported Types 00040 * @{ 00041 */ 00042 00043 /** 00044 * @brief HAL State structures definition 00045 */ 00046 typedef enum 00047 { 00048 HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ 00049 HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ 00050 HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ 00051 HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ 00052 HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ 00053 00054 } HAL_RTCStateTypeDef; 00055 00056 /** 00057 * @brief RTC Configuration Structure definition 00058 */ 00059 typedef struct 00060 { 00061 uint32_t HourFormat; /*!< Specifies the RTC Hour Format. 00062 This parameter can be a value of @ref RTC_Hour_Formats_Definitions */ 00063 00064 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. 00065 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ 00066 00067 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. 00068 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */ 00069 00070 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. 00071 This parameter can be a value of @ref RTC_Output_selection_Definitions */ 00072 00073 uint32_t OutPutRemap; /*!< Specifies the remap for RTC output. 00074 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */ 00075 00076 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. 00077 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ 00078 00079 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. 00080 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ 00081 #if defined(RTC_CR_TAMPALRM_PU) 00082 uint32_t OutPutPullUp; /*!< Specifies the RTC Output Pull-Up mode. 00083 This parameter can be a value of @ref RTC_Output_PullUp_ALARM_OUT */ 00084 #endif /* RTC_CR_TAMPALRM_PU */ 00085 } RTC_InitTypeDef; 00086 00087 /** 00088 * @brief RTC Time structure definition 00089 */ 00090 typedef struct 00091 { 00092 uint8_t Hours; /*!< Specifies the RTC Time Hour. 00093 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. 00094 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ 00095 00096 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. 00097 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00098 00099 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. 00100 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00101 00102 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. 00103 This parameter can be a value of @ref RTC_AM_PM_Definitions */ 00104 00105 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. 00106 This parameter corresponds to a time unit range between [0-1] Second 00107 with [1 Sec / SecondFraction +1] granularity */ 00108 00109 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content 00110 corresponding to Synchronous pre-scaler factor value (PREDIV_S) 00111 This parameter corresponds to a time unit range between [0-1] Second 00112 with [1 Sec / SecondFraction +1] granularity. 00113 This field will be used only by HAL_RTC_GetTime function */ 00114 00115 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment. 00116 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */ 00117 00118 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BKP bit 00119 in CR register to store the operation. 00120 This parameter can be a value of @ref RTC_StoreOperation_Definitions */ 00121 } RTC_TimeTypeDef; 00122 00123 /** 00124 * @brief RTC Date structure definition 00125 */ 00126 typedef struct 00127 { 00128 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. 00129 This parameter can be a value of @ref RTC_WeekDay_Definitions */ 00130 00131 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). 00132 This parameter can be a value of @ref RTC_Month_Date_Definitions */ 00133 00134 uint8_t Date; /*!< Specifies the RTC Date. 00135 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ 00136 00137 uint8_t Year; /*!< Specifies the RTC Date Year. 00138 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ 00139 00140 } RTC_DateTypeDef; 00141 00142 /** 00143 * @brief RTC Alarm structure definition 00144 */ 00145 typedef struct 00146 { 00147 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ 00148 00149 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. 00150 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ 00151 00152 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. 00153 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ 00154 00155 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. 00156 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ 00157 00158 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. 00159 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. 00160 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ 00161 00162 uint32_t Alarm; /*!< Specifies the alarm . 00163 This parameter can be a value of @ref RTC_Alarms_Definitions */ 00164 } RTC_AlarmTypeDef; 00165 00166 /** 00167 * @brief RTC Handle Structure definition 00168 */ 00169 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00170 typedef struct __RTC_HandleTypeDef 00171 #else 00172 typedef struct 00173 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ 00174 { 00175 RTC_TypeDef *Instance; /*!< Register base address */ 00176 00177 RTC_InitTypeDef Init; /*!< RTC required parameters */ 00178 00179 HAL_LockTypeDef Lock; /*!< RTC locking object */ 00180 00181 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ 00182 00183 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00184 void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */ 00185 00186 void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */ 00187 00188 void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC TimeStamp Event callback */ 00189 00190 void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */ 00191 00192 void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */ 00193 00194 void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */ 00195 00196 void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */ 00197 00198 #if defined(TAMP_CR1_ITAMP1E) 00199 void (* InternalTamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 1 Event callback */ 00200 #endif /* TAMP_CR1_ITAMP1E */ 00201 00202 #if defined(TAMP_CR1_ITAMP2E) 00203 void (* InternalTamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 2 Event callback */ 00204 #endif /* TAMP_CR1_ITAMP2E */ 00205 00206 #if defined(TAMP_CR1_ITAMP3E) 00207 void (* InternalTamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 3 Event callback */ 00208 #endif /* TAMP_CR1_ITAMP3E */ 00209 00210 #if defined(TAMP_CR1_ITAMP4E) 00211 void (* InternalTamper4EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 4 Event callback */ 00212 #endif /* TAMP_CR1_ITAMP4E */ 00213 00214 #if defined(TAMP_CR1_ITAMP5E) 00215 void (* InternalTamper5EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 5 Event callback */ 00216 #endif /* TAMP_CR1_ITAMP5E */ 00217 00218 #if defined(TAMP_CR1_ITAMP6E) 00219 void (* InternalTamper6EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 6 Event callback */ 00220 #endif /* TAMP_CR1_ITAMP6E */ 00221 00222 #if defined(TAMP_CR1_ITAMP8E) 00223 void (* InternalTamper8EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Internal Tamper 8 Event callback */ 00224 #endif /* TAMP_CR1_ITAMP8E */ 00225 00226 void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */ 00227 00228 void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */ 00229 00230 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */ 00231 00232 } RTC_HandleTypeDef; 00233 00234 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00235 /** 00236 * @brief HAL RTC Callback ID enumeration definition 00237 */ 00238 typedef enum 00239 { 00240 HAL_RTC_ALARM_A_EVENT_CB_ID = 0u, /*!< RTC Alarm A Event Callback ID */ 00241 HAL_RTC_ALARM_B_EVENT_CB_ID = 1u, /*!< RTC Alarm B Event Callback ID */ 00242 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 2u, /*!< RTC TimeStamp Event Callback ID */ 00243 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 3u, /*!< RTC WakeUp Timer Event Callback ID */ 00244 HAL_RTC_TAMPER1_EVENT_CB_ID = 4u, /*!< RTC Tamper 1 Callback ID */ 00245 HAL_RTC_TAMPER2_EVENT_CB_ID = 5u, /*!< RTC Tamper 2 Callback ID */ 00246 HAL_RTC_TAMPER3_EVENT_CB_ID = 6u, /*!< RTC Tamper 3 Callback ID */ 00247 00248 #if defined(TAMP_CR1_ITAMP1E) 00249 HAL_RTC_INTERNAL_TAMPER1_EVENT_CB_ID = 12u, /*!< RTC Internal Tamper 1 Callback ID */ 00250 #endif /* TAMP_CR1_ITAMP1E */ 00251 #if defined(TAMP_CR1_ITAMP2E) 00252 HAL_RTC_INTERNAL_TAMPER2_EVENT_CB_ID = 13u, /*!< RTC Internal Tamper 2 Callback ID */ 00253 #endif /* TAMP_CR1_ITAMP2E */ 00254 #if defined(TAMP_CR1_ITAMP3E) 00255 HAL_RTC_INTERNAL_TAMPER3_EVENT_CB_ID = 14u, /*!< RTC Internal Tamper 3 Callback ID */ 00256 #endif /* TAMP_CR1_ITAMP3E */ 00257 #if defined(TAMP_CR1_ITAMP4E) 00258 HAL_RTC_INTERNAL_TAMPER4_EVENT_CB_ID = 15u, /*!< RTC Internal Tamper 4 Callback ID */ 00259 #endif /* TAMP_CR1_ITAMP4E */ 00260 #if defined(TAMP_CR1_ITAMP5E) 00261 HAL_RTC_INTERNAL_TAMPER5_EVENT_CB_ID = 16u, /*!< RTC Internal Tamper 5 Callback ID */ 00262 #endif /* TAMP_CR1_ITAMP5E */ 00263 #if defined(TAMP_CR1_ITAMP6E) 00264 HAL_RTC_INTERNAL_TAMPER6_EVENT_CB_ID = 17u, /*!< RTC Internal Tamper 6 Callback ID */ 00265 #endif /* TAMP_CR1_ITAMP6E */ 00266 #if defined(TAMP_CR1_ITAMP8E) 00267 HAL_RTC_INTERNAL_TAMPER8_EVENT_CB_ID = 19u, /*!< RTC Internal Tamper 8 Callback ID */ 00268 #endif /* TAMP_CR1_ITAMP8E */ 00269 HAL_RTC_MSPINIT_CB_ID = 20u, /*!< RTC Msp Init callback ID */ 00270 HAL_RTC_MSPDEINIT_CB_ID = 21u /*!< RTC Msp DeInit callback ID */ 00271 } HAL_RTC_CallbackIDTypeDef; 00272 00273 /** 00274 * @brief HAL RTC Callback pointer definition 00275 */ 00276 typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */ 00277 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */ 00278 00279 /** 00280 * @} 00281 */ 00282 00283 /* Exported constants --------------------------------------------------------*/ 00284 /** @defgroup RTC_Exported_Constants RTC Exported Constants 00285 * @{ 00286 */ 00287 00288 /** @defgroup RTC_Hour_Formats_Definitions RTC Hour Formats Definitions 00289 * @{ 00290 */ 00291 #define RTC_HOURFORMAT_24 0x00000000u 00292 #define RTC_HOURFORMAT_12 RTC_CR_FMT 00293 /** 00294 * @} 00295 */ 00296 00297 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions 00298 * @{ 00299 */ 00300 #define RTC_OUTPUT_DISABLE 0x00000000u 00301 #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0 00302 #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1 00303 #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL 00304 #if defined(RTC_CR_TAMPOE) 00305 #define RTC_OUTPUT_TAMPER RTC_CR_TAMPOE 00306 #endif /* RTC_CR_TAMPOE */ 00307 /** 00308 * @} 00309 */ 00310 00311 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions 00312 * @{ 00313 */ 00314 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000u 00315 #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL 00316 /** 00317 * @} 00318 */ 00319 00320 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT 00321 * @{ 00322 */ 00323 #if defined(RTC_CR_TAMPALRM_TYPE) 00324 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00000000u 00325 #define RTC_OUTPUT_TYPE_OPENDRAIN RTC_CR_TAMPALRM_TYPE 00326 #define RTC_ALARM_OUTPUT_TYPE RTC_CR_TAMPALRM_TYPE 00327 #endif /* RTC_CR_TAMPALRM_TYPE */ 00328 00329 #if defined(RTC_OR_ALARMOUTTYPE) 00330 #define RTC_OUTPUT_TYPE_PUSHPULL RTC_OR_ALARMOUTTYPE 00331 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000u 00332 #define RTC_ALARM_OUTPUT_TYPE RTC_OR_ALARMOUTTYPE 00333 #endif /* RTC_OR_ALARMOUTTYPE */ 00334 /** 00335 * @} 00336 */ 00337 00338 /** @defgroup RTC_Output_PullUp_ALARM_OUT RTC Output Pull-Up ALARM OUT 00339 * @{ 00340 */ 00341 #if defined(RTC_CR_TAMPALRM_PU) 00342 #define RTC_OUTPUT_PULLUP_NONE 0x00000000u 00343 #define RTC_OUTPUT_PULLUP_ON RTC_CR_TAMPALRM_PU 00344 #endif /* RTC_CR_TAMPALRM_PU */ 00345 /** 00346 * @} 00347 */ 00348 00349 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap 00350 * @{ 00351 */ 00352 #if defined(RTC_CR_OUT2EN) 00353 #define RTC_OUTPUT_REMAP_NONE 0x00000000u 00354 #define RTC_OUTPUT_REMAP_POS1 RTC_CR_OUT2EN 00355 #endif /* RTC_CR_OUT2EN */ 00356 00357 #if defined(RTC_OR_OUT_RMP) 00358 #define RTC_OUTPUT_REMAP_NONE 0x00000000u 00359 #define RTC_OUTPUT_REMAP_POS1 RTC_OR_OUT_RMP 00360 #endif /* RTC_OR_OUT_RMP */ 00361 /** 00362 * @} 00363 */ 00364 00365 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions 00366 * @{ 00367 */ 00368 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00) 00369 #define RTC_HOURFORMAT12_PM ((uint8_t)0x01) 00370 /** 00371 * @} 00372 */ 00373 00374 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions 00375 * @{ 00376 */ 00377 #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H 00378 #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H 00379 #define RTC_DAYLIGHTSAVING_NONE 0x00000000u 00380 /** 00381 * @} 00382 */ 00383 00384 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions 00385 * @{ 00386 */ 00387 #define RTC_STOREOPERATION_RESET 0x00000000u 00388 #define RTC_STOREOPERATION_SET RTC_CR_BKP 00389 /** 00390 * @} 00391 */ 00392 00393 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions 00394 * @{ 00395 */ 00396 #define RTC_FORMAT_BIN 0x00000000u 00397 #define RTC_FORMAT_BCD 0x00000001u 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format) 00403 * @{ 00404 */ 00405 #define RTC_MONTH_JANUARY ((uint8_t)0x01) 00406 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) 00407 #define RTC_MONTH_MARCH ((uint8_t)0x03) 00408 #define RTC_MONTH_APRIL ((uint8_t)0x04) 00409 #define RTC_MONTH_MAY ((uint8_t)0x05) 00410 #define RTC_MONTH_JUNE ((uint8_t)0x06) 00411 #define RTC_MONTH_JULY ((uint8_t)0x07) 00412 #define RTC_MONTH_AUGUST ((uint8_t)0x08) 00413 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) 00414 #define RTC_MONTH_OCTOBER ((uint8_t)0x10) 00415 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) 00416 #define RTC_MONTH_DECEMBER ((uint8_t)0x12) 00417 00418 /** 00419 * @} 00420 */ 00421 00422 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions 00423 * @{ 00424 */ 00425 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) 00426 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) 00427 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) 00428 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) 00429 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) 00430 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) 00431 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07) 00432 00433 /** 00434 * @} 00435 */ 00436 00437 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions 00438 * @{ 00439 */ 00440 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000u 00441 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL 00442 00443 /** 00444 * @} 00445 */ 00446 00447 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions 00448 * @{ 00449 */ 00450 #define RTC_ALARMMASK_NONE 0x00000000u 00451 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 00452 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 00453 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 00454 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 00455 #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \ 00456 RTC_ALARMMASK_HOURS | \ 00457 RTC_ALARMMASK_MINUTES | \ 00458 RTC_ALARMMASK_SECONDS) 00459 /** 00460 * @} 00461 */ 00462 00463 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions 00464 * @{ 00465 */ 00466 #define RTC_ALARM_A RTC_CR_ALRAE 00467 #define RTC_ALARM_B RTC_CR_ALRBE 00468 /** 00469 * @} 00470 */ 00471 00472 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions 00473 * @{ 00474 */ 00475 /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */ 00476 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000u 00477 /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */ 00478 #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 00479 /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */ 00480 #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 00481 /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */ 00482 #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1) 00483 /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */ 00484 #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 00485 /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */ 00486 #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2) 00487 /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */ 00488 #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) 00489 /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */ 00490 #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) 00491 /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */ 00492 #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 00493 /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */ 00494 #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3) 00495 /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */ 00496 #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) 00497 /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */ 00498 #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) 00499 /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */ 00500 #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) 00501 /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */ 00502 #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) 00503 /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */ 00504 #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) 00505 /*!< SS[14:0] are compared and must match to activate alarm. */ 00506 #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS 00507 00508 /** 00509 * @} 00510 */ 00511 00512 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions 00513 * @{ 00514 */ 00515 #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */ 00516 #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */ 00517 #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */ 00518 #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */ 00519 /** 00520 * @} 00521 */ 00522 00523 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions 00524 * @{ 00525 */ 00526 #if defined(RTC_ICSR_RECALPF) 00527 #define RTC_FLAG_RECALPF RTC_ICSR_RECALPF /*!< Recalibration pending Flag */ 00528 #endif /* RTC_ICSR_RECALPF */ 00529 #if defined(RTC_ICSR_INITF) 00530 #define RTC_FLAG_INITF RTC_ICSR_INITF /*!< Initialization pending flag */ 00531 #endif /* RTC_ICSR_INITF */ 00532 #if defined(RTC_ICSR_RSF) 00533 #define RTC_FLAG_RSF RTC_ICSR_RSF /*!< Registers synchronization flag */ 00534 #endif /* RTC_ICSR_RSF */ 00535 #if defined(RTC_ICSR_INITS) 00536 #define RTC_FLAG_INITS RTC_ICSR_INITS /*!< Initialization status flag */ 00537 #endif /* RTC_ICSR_INITS */ 00538 #if defined(RTC_ICSR_SHPF) 00539 #define RTC_FLAG_SHPF RTC_ICSR_SHPF /*!< Shift operation pending flag */ 00540 #endif /* RTC_ICSR_SHPF */ 00541 #if defined(RTC_ICSR_WUTWF) 00542 #define RTC_FLAG_WUTWF RTC_ICSR_WUTWF /*!< Wakeup timer write operation pending flag */ 00543 #endif /* RTC_ICSR_WUTWF */ 00544 #if defined(RTC_ICSR_ALRBWF) 00545 #define RTC_FLAG_ALRBWF RTC_ICSR_ALRBWF /*!< Alarm B write operation pending flag */ 00546 #endif /* RTC_ICSR_ALRBWF */ 00547 #if defined(RTC_ICSR_ALRAWF) 00548 #define RTC_FLAG_ALRAWF RTC_ICSR_ALRAWF /*!< Alarm A write operation pending flag */ 00549 #endif /* RTC_ICSR_ALRAWF */ 00550 #if defined(RTC_SR_ITSF) 00551 #define RTC_FLAG_ITSF RTC_SR_ITSF /*!< Internal Time-stamp flag */ 00552 #endif /* RTC_SR_ITSF */ 00553 #if defined(RTC_SR_TSOVF) 00554 #define RTC_FLAG_TSOVF RTC_SR_TSOVF /*!< Time-stamp overflow flag */ 00555 #endif /* RTC_SR_TSOVF */ 00556 #if defined(RTC_SR_TSF) 00557 #define RTC_FLAG_TSF RTC_SR_TSF /*!< Time-stamp flag */ 00558 #endif /* RTC_SR_TSF */ 00559 #if defined(RTC_SR_WUTF) 00560 #define RTC_FLAG_WUTF RTC_SR_WUTF /*!< Wakeup timer flag */ 00561 #endif /* RTC_SR_WUTF */ 00562 #if defined(RTC_SR_ALRBF) 00563 #define RTC_FLAG_ALRBF RTC_SR_ALRBF /*!< Alarm B flag */ 00564 #endif /* RTC_SR_ALRBF */ 00565 #if defined(RTC_SR_ALRAF) 00566 #define RTC_FLAG_ALRAF RTC_SR_ALRAF /*!< Alarm A flag */ 00567 #endif /* RTC_SR_ALRAF */ 00568 /** 00569 * @} 00570 */ 00571 00572 /** @defgroup RTC_Clear_Flags_Definitions RTC Clear Flags Definitions 00573 * @{ 00574 */ 00575 #if defined(RTC_SCR_CITSF) 00576 #define RTC_CLEAR_ITSF RTC_SCR_CITSF /*!< Clear Internal Time-stamp flag */ 00577 #endif /* RTC_SCR_CITSF */ 00578 #if defined(RTC_SCR_CTSOVF) 00579 #define RTC_CLEAR_TSOVF RTC_SCR_CTSOVF /*!< Clear Time-stamp overflow flag */ 00580 #endif /* RTC_SCR_CTSOVF */ 00581 #if defined(RTC_SCR_CTSF) 00582 #define RTC_CLEAR_TSF RTC_SCR_CTSF /*!< Clear Time-stamp flag */ 00583 #endif /* RTC_SCR_CTSF */ 00584 #if defined(RTC_SCR_CWUTF) 00585 #define RTC_CLEAR_WUTF RTC_SCR_CWUTF /*!< Clear Wakeup timer flag */ 00586 #endif /* RTC_SCR_CWUTF */ 00587 #if defined(RTC_SCR_CALRBF) 00588 #define RTC_CLEAR_ALRBF RTC_SCR_CALRBF /*!< Clear Alarm B flag */ 00589 #endif /* RTC_SCR_CALRBF */ 00590 #if defined(RTC_SCR_CALRAF) 00591 #define RTC_CLEAR_ALRAF RTC_SCR_CALRAF /*!< Clear Alarm A flag */ 00592 #endif /* RTC_SCR_CALRAF */ 00593 /** 00594 * @} 00595 */ 00596 00597 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions 00598 * @{ 00599 */ 00600 #if defined(RTC_ISR_RECALPF) 00601 #define RTC_FLAG_RECALPF RTC_ISR_RECALPF 00602 #endif /* RTC_ISR_RECALPF */ 00603 #if defined(RTC_ISR_TSOVF) 00604 #define RTC_FLAG_TSOVF RTC_ISR_TSOVF 00605 #endif /* RTC_ISR_TSOVF */ 00606 #if defined(RTC_ISR_TSF) 00607 #define RTC_FLAG_TSF RTC_ISR_TSF 00608 #endif /* RTC_ISR_TSF */ 00609 #if defined(RTC_ISR_ITSF) 00610 #define RTC_FLAG_ITSF RTC_ISR_ITSF 00611 #endif /* RTC_ISR_ITSF */ 00612 #if defined(RTC_ISR_WUTF) 00613 #define RTC_FLAG_WUTF RTC_ISR_WUTF 00614 #endif /* RTC_ISR_WUTF */ 00615 #if defined(RTC_ISR_ALRBF) 00616 #define RTC_FLAG_ALRBF RTC_ISR_ALRBF 00617 #endif /* RTC_ISR_ALRBF */ 00618 #if defined(RTC_ISR_ALRAF) 00619 #define RTC_FLAG_ALRAF RTC_ISR_ALRAF 00620 #endif /* RTC_ISR_ALRAF */ 00621 #if defined(RTC_ISR_INITF) 00622 #define RTC_FLAG_INITF RTC_ISR_INITF 00623 #endif /* RTC_ISR_INITF */ 00624 #if defined(RTC_ISR_RSF) 00625 #define RTC_FLAG_RSF RTC_ISR_RSF 00626 #endif /* RTC_ISR_RSF */ 00627 #if defined(RTC_ISR_INITS) 00628 #define RTC_FLAG_INITS RTC_ISR_INITS 00629 #endif /* RTC_ISR_INITS */ 00630 #if defined(RTC_ISR_SHPF) 00631 #define RTC_FLAG_SHPF RTC_ISR_SHPF 00632 #endif /* RTC_ISR_SHPF */ 00633 #if defined(RTC_ISR_WUTWF) 00634 #define RTC_FLAG_WUTWF RTC_ISR_WUTWF 00635 #endif /* RTC_ISR_WUTWF */ 00636 #if defined(RTC_ISR_ALRBWF) 00637 #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF 00638 #endif /* RTC_ISR_ALRBWF */ 00639 #if defined(RTC_ISR_ALRAWF) 00640 #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF 00641 #endif /* RTC_ISR_ALRAWF */ 00642 /** 00643 * @} 00644 */ 00645 00646 /** 00647 * @} 00648 */ 00649 00650 /* Exported macros -----------------------------------------------------------*/ 00651 /** @defgroup RTC_Exported_Macros RTC Exported Macros 00652 * @{ 00653 */ 00654 00655 /** @brief Reset RTC handle state 00656 * @param __HANDLE__ RTC handle. 00657 * @retval None 00658 */ 00659 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00660 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00661 (__HANDLE__)->State = HAL_RTC_STATE_RESET; \ 00662 (__HANDLE__)->MspInitCallback = NULL; \ 00663 (__HANDLE__)->MspDeInitCallback = NULL; \ 00664 }while(0u) 00665 #else 00666 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) 00667 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 00668 00669 /** 00670 * @brief Disable the write protection for RTC registers. 00671 * @param __HANDLE__ specifies the RTC handle. 00672 * @retval None 00673 */ 00674 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ 00675 do{ \ 00676 (__HANDLE__)->Instance->WPR = 0xCAU; \ 00677 (__HANDLE__)->Instance->WPR = 0x53U; \ 00678 } while(0u) 00679 00680 /** 00681 * @brief Enable the write protection for RTC registers. 00682 * @param __HANDLE__ specifies the RTC handle. 00683 * @retval None 00684 */ 00685 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ 00686 do{ \ 00687 (__HANDLE__)->Instance->WPR = 0xFFU; \ 00688 } while(0u) 00689 00690 /** 00691 * @brief Add 1 hour (summer time change). 00692 * @param __HANDLE__ specifies the RTC handle. 00693 * @param __BKP__ Backup 00694 * This parameter can be: 00695 * @arg @ref RTC_STOREOPERATION_RESET 00696 * @arg @ref RTC_STOREOPERATION_SET 00697 * @retval None 00698 */ 00699 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H(__HANDLE__, __BKP__) \ 00700 do { \ 00701 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ 00702 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_ADD1H); \ 00703 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \ 00704 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ 00705 } while(0u); 00706 00707 /** 00708 * @brief Subtract 1 hour (winter time change). 00709 * @param __HANDLE__ specifies the RTC handle. 00710 * @param __BKP__ Backup 00711 * This parameter can be: 00712 * @arg @ref RTC_STOREOPERATION_RESET 00713 * @arg @ref RTC_STOREOPERATION_SET 00714 * @retval None 00715 */ 00716 #define __HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H(__HANDLE__, __BKP__) \ 00717 do { \ 00718 __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__); \ 00719 SET_BIT((__HANDLE__)->Instance->CR, RTC_CR_SUB1H); \ 00720 MODIFY_REG((__HANDLE__)->Instance->CR, RTC_CR_BKP , (__BKP__)); \ 00721 __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__); \ 00722 } while(0u); 00723 00724 /** 00725 * @brief Enable the RTC ALARMA peripheral. 00726 * @param __HANDLE__ specifies the RTC handle. 00727 * @retval None 00728 */ 00729 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) 00730 00731 /** 00732 * @brief Disable the RTC ALARMA peripheral. 00733 * @param __HANDLE__ specifies the RTC handle. 00734 * @retval None 00735 */ 00736 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) 00737 00738 /** 00739 * @brief Enable the RTC ALARMB peripheral. 00740 * @param __HANDLE__ specifies the RTC handle. 00741 * @retval None 00742 */ 00743 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) 00744 00745 /** 00746 * @brief Disable the RTC ALARMB peripheral. 00747 * @param __HANDLE__ specifies the RTC handle. 00748 * @retval None 00749 */ 00750 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) 00751 00752 /** 00753 * @brief Enable the RTC Alarm interrupt. 00754 * @param __HANDLE__ specifies the RTC handle. 00755 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 00756 * This parameter can be any combination of the following values: 00757 * @arg @ref RTC_IT_ALRA Alarm A interrupt 00758 * @arg @ref RTC_IT_ALRB Alarm B interrupt 00759 * @retval None 00760 */ 00761 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 00762 00763 /** 00764 * @brief Disable the RTC Alarm interrupt. 00765 * @param __HANDLE__ specifies the RTC handle. 00766 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 00767 * This parameter can be any combination of the following values: 00768 * @arg @ref RTC_IT_ALRA Alarm A interrupt 00769 * @arg @ref RTC_IT_ALRB Alarm B interrupt 00770 * @retval None 00771 */ 00772 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 00773 00774 /** 00775 * @brief Check whether the specified RTC Alarm interrupt has occurred or not. 00776 * @param __HANDLE__ specifies the RTC handle. 00777 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. 00778 * This parameter can be: 00779 * @arg @ref RTC_IT_ALRA Alarm A interrupt 00780 * @arg @ref RTC_IT_ALRB Alarm B interrupt 00781 * @retval None 00782 */ 00783 #if defined(RTC_MISR_ALRAMF) 00784 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->MISR)& (__INTERRUPT__ >> 12)) != 0U)? 1U : 0U) 00785 #endif /* RTC_MISR_ALRAMF */ 00786 #if defined(RTC_ISR_ALRAF) 00787 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& (__INTERRUPT__ >> 4)) != 0U)? 1U : 0U) 00788 #endif /* RTC_ISR_ALRAF */ 00789 00790 /** 00791 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. 00792 * @param __HANDLE__ specifies the RTC handle. 00793 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. 00794 * This parameter can be: 00795 * @arg @ref RTC_IT_ALRA Alarm A interrupt 00796 * @arg @ref RTC_IT_ALRB Alarm B interrupt 00797 * @retval None 00798 */ 00799 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) 00800 00801 #if defined(RTC_SR_ALRAF) 00802 /** 00803 * @brief Get the selected RTC Alarm's flag status. 00804 * @param __HANDLE__ specifies the RTC handle. 00805 * @param __FLAG__ specifies the RTC Alarm Flag sources to check. 00806 * This parameter can be: 00807 * @arg @ref RTC_FLAG_ALRAF 00808 * @arg @ref RTC_FLAG_ALRBF 00809 * @retval None 00810 */ 00811 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) != 0U) ? 1U : 0U) 00812 #endif /* RTC_SR_ALRAF */ 00813 #if defined(RTC_ISR_ALRAF) 00814 /** 00815 * @brief Get the selected RTC Alarm's flag status. 00816 * @param __HANDLE__ specifies the RTC handle. 00817 * @param __FLAG__ specifies the RTC Alarm Flag sources to check. 00818 * This parameter can be: 00819 * @arg @ref RTC_FLAG_ALRAF 00820 * @arg @ref RTC_FLAG_ALRBF 00821 * @arg @ref RTC_FLAG_ALRAWF 00822 * @arg @ref RTC_FLAG_ALRBWF 00823 * @retval None 00824 */ 00825 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U) 00826 #endif /* RTC_ISR_ALRAF */ 00827 00828 /** 00829 * @brief Clear the RTC Alarm's pending flags. 00830 * @param __HANDLE__ specifies the RTC handle. 00831 * @param __FLAG__ specifies the RTC Alarm Flag sources to clear. 00832 * This parameter can be: 00833 * @arg @ref RTC_FLAG_ALRAF 00834 * @arg @ref RTC_FLAG_ALRBF 00835 * @retval None 00836 */ 00837 #if defined(RTC_SCR_CALRAF) 00838 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SCR |= __FLAG__) 00839 #endif /* RTC_SCR_CALRAF */ 00840 #if defined(RTC_ISR_ALRAF) 00841 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))) 00842 #endif /* RTC_ISR_ALRAF */ 00843 00844 00845 /** 00846 * @brief Enable interrupt on the RTC Alarm associated Exti line. 00847 * @retval None 00848 */ 00849 #if defined(EXTI_D1) 00850 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI_D1->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00851 #else /* EXTI */ 00852 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00853 #endif /* EXTI_D1 */ 00854 00855 /** 00856 * @brief Disable interrupt on the RTC Alarm associated Exti line. 00857 * @retval None 00858 */ 00859 #if defined(EXTI_D1) 00860 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI_D1->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00861 #else /* EXTI */ 00862 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00863 #endif /* EXTI_D1 */ 00864 00865 /** 00866 * @brief Enable event on the RTC Alarm associated Exti line. 00867 * @retval None. 00868 */ 00869 #if defined(EXTI_D1) 00870 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI_D1->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00871 #else /* EXTI */ 00872 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00873 #endif /* EXTI_D1 */ 00874 00875 /** 00876 * @brief Disable event on the RTC Alarm associated Exti line. 00877 * @retval None. 00878 */ 00879 #if defined(EXTI_D1) 00880 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI_D1->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00881 #else /* EXTI */ 00882 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00883 #endif /* EXTI_D1 */ 00884 00885 #if defined(DUAL_CORE) 00886 /** 00887 * @brief Enable interrupt on the RTC Alarm associated D2 Exti line. 00888 * @retval None 00889 */ 00890 #define __HAL_RTC_ALARM_EXTID2_ENABLE_IT() (EXTI_D2->IMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00891 00892 /** 00893 * @brief Disable interrupt on the RTC Alarm associated D2 Exti line. 00894 * @retval None 00895 */ 00896 #define __HAL_RTC_ALARM_EXTID2_DISABLE_IT() (EXTI_D2->IMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00897 00898 /** 00899 * @brief Enable event on the RTC Alarm associated D2 Exti line. 00900 * @retval None 00901 */ 00902 #define __HAL_RTC_ALARM_EXTID2_ENABLE_EVENT() (EXTI_D2->EMR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00903 00904 /** 00905 * @brief Disable event on the RTC Alarm associated D2 Exti line. 00906 * @retval None 00907 */ 00908 #define __HAL_RTC_ALARM_EXTID2_DISABLE_EVENT() (EXTI_D2->EMR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00909 00910 #endif /* DUAL_CORE */ 00911 /** 00912 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line. 00913 * @retval None 00914 */ 00915 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00916 00917 /** 00918 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line. 00919 * @retval None 00920 */ 00921 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00922 00923 /** 00924 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line. 00925 * @retval None 00926 */ 00927 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR1 |= RTC_EXTI_LINE_ALARM_EVENT) 00928 00929 /** 00930 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line. 00931 * @retval None 00932 */ 00933 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR1 &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00934 00935 /** 00936 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line. 00937 * @retval None 00938 */ 00939 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 00940 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ 00941 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \ 00942 } while(0u) 00943 00944 /** 00945 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line. 00946 * @retval None 00947 */ 00948 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 00949 __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \ 00950 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \ 00951 } while(0u) 00952 00953 /** 00954 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not. 00955 * @retval Line Status. 00956 */ 00957 #if defined(EXTI_D1) 00958 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI_D1->PR1 & RTC_EXTI_LINE_ALARM_EVENT) 00959 #else /* EXTI */ 00960 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR1 & RTC_EXTI_LINE_ALARM_EVENT) 00961 #endif /* EXTI_D1 */ 00962 00963 /** 00964 * @brief Clear the RTC Alarm associated Exti line flag. 00965 * @retval None. 00966 */ 00967 #if defined(EXTI_D1) 00968 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI_D1->PR1 = (RTC_EXTI_LINE_ALARM_EVENT)) 00969 #else /* EXTI */ 00970 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR1 = (RTC_EXTI_LINE_ALARM_EVENT)) 00971 #endif /* EXTI_D1 */ 00972 00973 #if defined(DUAL_CORE) 00974 /** 00975 * @brief Check whether the RTC Alarm associated D2 Exti line interrupt flag is set or not. 00976 * @retval Line Status 00977 */ 00978 #define __HAL_RTC_ALARM_EXTID2_GET_FLAG() (EXTI_D2->PR1 & RTC_EXTI_LINE_ALARM_EVENT) 00979 00980 /** 00981 * @brief Clear the RTC Alarm associated D2 Exti line flag. 00982 * @retval None 00983 */ 00984 #define __HAL_RTC_ALARM_EXTID2_CLEAR_FLAG() (EXTI_D2->PR1 = (RTC_EXTI_LINE_ALARM_EVENT)) 00985 #endif /* DUAL_CORE */ 00986 /** 00987 * @brief Generate a Software interrupt on RTC Alarm associated Exti line. 00988 * @retval None 00989 */ 00990 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER1 |= RTC_EXTI_LINE_ALARM_EVENT) 00991 00992 /** 00993 * @} 00994 */ 00995 00996 /* Include RTC HAL Extended module */ 00997 #include "stm32h7xx_hal_rtc_ex.h" 00998 00999 /* Exported functions --------------------------------------------------------*/ 01000 /** @defgroup RTC_Exported_Functions RTC Exported Functions 01001 * @{ 01002 */ 01003 01004 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions 01005 * @{ 01006 */ 01007 /* Initialization and de-initialization functions ****************************/ 01008 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); 01009 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); 01010 01011 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); 01012 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); 01013 01014 /* Callbacks Register/UnRegister functions ***********************************/ 01015 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 01016 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); 01017 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); 01018 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS == 1) */ 01019 /** 01020 * @} 01021 */ 01022 01023 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions 01024 * @{ 01025 */ 01026 /* RTC Time and Date functions ************************************************/ 01027 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 01028 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 01029 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 01030 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 01031 /** 01032 * @} 01033 */ 01034 01035 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions 01036 * @{ 01037 */ 01038 /* RTC Alarm functions ********************************************************/ 01039 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 01040 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 01041 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); 01042 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); 01043 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); 01044 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); 01045 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 01046 /** 01047 * @} 01048 */ 01049 01050 /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions 01051 * @{ 01052 */ 01053 /* Peripheral Control functions ***********************************************/ 01054 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc); 01055 /** 01056 * @} 01057 */ 01058 01059 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions 01060 * @{ 01061 */ 01062 /* Peripheral State functions *************************************************/ 01063 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); 01064 /** 01065 * @} 01066 */ 01067 01068 /** 01069 * @} 01070 */ 01071 01072 /* Private types -------------------------------------------------------------*/ 01073 /* Private variables ---------------------------------------------------------*/ 01074 /* Private constants ---------------------------------------------------------*/ 01075 /** @defgroup RTC_Private_Constants RTC Private Constants 01076 * @{ 01077 */ 01078 /* Masks Definition */ 01079 #define RTC_TR_RESERVED_MASK (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \ 01080 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \ 01081 RTC_TR_SU) 01082 01083 #define RTC_DR_RESERVED_MASK (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \ 01084 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \ 01085 RTC_DR_DU) 01086 01087 #define RTC_INIT_MASK 0xFFFFFFFFu 01088 01089 #if defined(RTC_ICSR_INIT) && defined(RTC_ICSR_RSF) 01090 #define RTC_RSF_MASK (~(RTC_ICSR_INIT | RTC_ICSR_RSF)) 01091 #endif /* RTC_ICSR_INIT && RTC_ICSR_RSF */ 01092 01093 #if defined(RTC_ISR_INIT) && defined(RTC_ISR_RSF) 01094 #define RTC_RSF_MASK (~(RTC_ISR_INIT | RTC_ISR_RSF)) 01095 #endif /* RTC_ISR_INIT && RTC_ISR_RSF */ 01096 01097 #define RTC_TIMEOUT_VALUE 1000u 01098 01099 #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR1_IM17 /*!< External interrupt line 17 Connected to the RTC Alarm event */ 01100 01101 /** 01102 * @} 01103 */ 01104 01105 /* Private macros ------------------------------------------------------------*/ 01106 /** @defgroup RTC_Private_Macros RTC Private Macros 01107 * @{ 01108 */ 01109 01110 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters 01111 * @{ 01112 */ 01113 01114 #if defined(RTC_CR_TAMPOE) 01115 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ 01116 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ 01117 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ 01118 ((OUTPUT) == RTC_OUTPUT_WAKEUP) || \ 01119 ((OUTPUT) == RTC_OUTPUT_TAMPER)) 01120 #else /* RTC_CR_TAMPOE not defined */ 01121 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ 01122 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ 01123 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ 01124 ((OUTPUT) == RTC_OUTPUT_WAKEUP)) 01125 #endif /* RTC_CR_TAMPOE */ 01126 01127 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ 01128 ((FORMAT) == RTC_HOURFORMAT_24)) 01129 01130 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ 01131 ((POL) == RTC_OUTPUT_POLARITY_LOW)) 01132 01133 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ 01134 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) 01135 01136 #if defined(RTC_CR_TAMPALRM_PU) 01137 #define IS_RTC_OUTPUT_PULLUP(TYPE) (((TYPE) == RTC_OUTPUT_PULLUP_NONE) || \ 01138 ((TYPE) == RTC_OUTPUT_PULLUP_ON)) 01139 #endif /* RTC_CR_TAMPALRM_PU */ 01140 01141 #define IS_RTC_OUTPUT_REMAP(REMAP) (((REMAP) == RTC_OUTPUT_REMAP_NONE) || \ 01142 ((REMAP) == RTC_OUTPUT_REMAP_POS1)) 01143 01144 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \ 01145 ((PM) == RTC_HOURFORMAT12_PM)) 01146 01147 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ 01148 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ 01149 ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) 01150 01151 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ 01152 ((OPERATION) == RTC_STOREOPERATION_SET)) 01153 01154 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || \ 01155 ((FORMAT) == RTC_FORMAT_BCD)) 01156 01157 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99u) 01158 01159 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1u) && ((MONTH) <= 12u)) 01160 01161 #define IS_RTC_DATE(DATE) (((DATE) >= 1u) && ((DATE) <= 31u)) 01162 01163 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 01164 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 01165 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 01166 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 01167 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 01168 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 01169 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 01170 01171 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0u) && ((DATE) <= 31u)) 01172 01173 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 01174 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 01175 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 01176 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 01177 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 01178 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 01179 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 01180 01181 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ 01182 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) 01183 01184 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ~(RTC_ALARMMASK_ALL)) == 0u) 01185 01186 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || \ 01187 ((ALARM) == RTC_ALARM_B)) 01188 01189 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS) 01190 01191 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == 0u) || \ 01192 (((MASK) >= RTC_ALARMSUBSECONDMASK_SS14_1) && ((MASK) <= RTC_ALARMSUBSECONDMASK_NONE))) 01193 01194 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_A >> RTC_PRER_PREDIV_A_Pos)) 01195 01196 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= (RTC_PRER_PREDIV_S >> RTC_PRER_PREDIV_S_Pos)) 01197 01198 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0u) && ((HOUR) <= 12u)) 01199 01200 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23u) 01201 01202 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59u) 01203 01204 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59u) 01205 01206 /** 01207 * @} 01208 */ 01209 01210 /** 01211 * @} 01212 */ 01213 01214 /* Private functions -------------------------------------------------------------*/ 01215 /** @defgroup RTC_Private_Functions RTC Private Functions 01216 * @{ 01217 */ 01218 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc); 01219 HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc); 01220 uint8_t RTC_ByteToBcd2(uint8_t Value); 01221 uint8_t RTC_Bcd2ToByte(uint8_t Value); 01222 01223 /** 01224 * @} 01225 */ 01226 01227 /** 01228 * @} 01229 */ 01230 01231 /** 01232 * @} 01233 */ 01234 01235 #ifdef __cplusplus 01236 } 01237 #endif 01238 01239 #endif /* STM32H7xx_HAL_RTC_H */ 01240