STM32F479xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_rtc.h 00004 * @author MCD Application Team 00005 * @brief Header file of RTC HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef __STM32F4xx_HAL_RTC_H 00022 #define __STM32F4xx_HAL_RTC_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm32f4xx_hal_def.h" 00030 00031 /** @addtogroup STM32F4xx_HAL_Driver 00032 * @{ 00033 */ 00034 00035 /** @addtogroup RTC 00036 * @{ 00037 */ 00038 00039 /* Exported types ------------------------------------------------------------*/ 00040 /** @defgroup RTC_Exported_Types RTC Exported Types 00041 * @{ 00042 */ 00043 00044 /** 00045 * @brief HAL State structures definition 00046 */ 00047 typedef enum 00048 { 00049 HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ 00050 HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ 00051 HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ 00052 HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ 00053 HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ 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 */ 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 = 0x7FFFU */ 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 OutPutPolarity; /*!< Specifies the polarity of the output signal. 00074 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ 00075 00076 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. 00077 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ 00078 }RTC_InitTypeDef; 00079 00080 /** 00081 * @brief RTC Time structure definition 00082 */ 00083 typedef struct 00084 { 00085 uint8_t Hours; /*!< Specifies the RTC Time Hour. 00086 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected. 00087 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ 00088 00089 uint8_t Minutes; /*!< Specifies the RTC Time Minutes. 00090 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00091 00092 uint8_t Seconds; /*!< Specifies the RTC Time Seconds. 00093 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ 00094 00095 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. 00096 This parameter can be a value of @ref RTC_AM_PM_Definitions */ 00097 00098 uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. 00099 This parameter corresponds to a time unit range between [0-1] Second 00100 with [1 Sec / SecondFraction +1] granularity */ 00101 00102 uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content 00103 corresponding to Synchronous pre-scaler factor value (PREDIV_S) 00104 This parameter corresponds to a time unit range between [0-1] Second 00105 with [1 Sec / SecondFraction +1] granularity. 00106 This field will be used only by HAL_RTC_GetTime function */ 00107 00108 uint32_t DayLightSaving; /*!< This interface is deprecated. To manage Daylight Saving Time, 00109 please use HAL_RTC_DST_xxx functions */ 00110 00111 uint32_t StoreOperation; /*!< This interface is deprecated. To manage Daylight Saving Time, 00112 please use HAL_RTC_DST_xxx functions */ 00113 }RTC_TimeTypeDef; 00114 00115 /** 00116 * @brief RTC Date structure definition 00117 */ 00118 typedef struct 00119 { 00120 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. 00121 This parameter can be a value of @ref RTC_WeekDay_Definitions */ 00122 00123 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). 00124 This parameter can be a value of @ref RTC_Month_Date_Definitions */ 00125 00126 uint8_t Date; /*!< Specifies the RTC Date. 00127 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ 00128 00129 uint8_t Year; /*!< Specifies the RTC Date Year. 00130 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ 00131 00132 }RTC_DateTypeDef; 00133 00134 /** 00135 * @brief RTC Alarm structure definition 00136 */ 00137 typedef struct 00138 { 00139 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ 00140 00141 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. 00142 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ 00143 00144 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. 00145 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ 00146 00147 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. 00148 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ 00149 00150 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. 00151 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. 00152 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ 00153 00154 uint32_t Alarm; /*!< Specifies the alarm . 00155 This parameter can be a value of @ref RTC_Alarms_Definitions */ 00156 }RTC_AlarmTypeDef; 00157 00158 /** 00159 * @brief RTC Handle Structure definition 00160 */ 00161 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00162 typedef struct __RTC_HandleTypeDef 00163 #else 00164 typedef struct 00165 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ 00166 { 00167 RTC_TypeDef *Instance; /*!< Register base address */ 00168 00169 RTC_InitTypeDef Init; /*!< RTC required parameters */ 00170 00171 HAL_LockTypeDef Lock; /*!< RTC locking object */ 00172 00173 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ 00174 00175 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00176 void (* AlarmAEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Alarm A Event callback */ 00177 00178 void (* AlarmBEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Alarm B Event callback */ 00179 00180 void (* TimeStampEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC TimeStamp Event callback */ 00181 00182 void (* WakeUpTimerEventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC WakeUpTimer Event callback */ 00183 00184 void (* Tamper1EventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Tamper 1 Event callback */ 00185 00186 void (* Tamper2EventCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Tamper 2 Event callback */ 00187 00188 void (* MspInitCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Msp Init callback */ 00189 00190 void (* MspDeInitCallback) ( struct __RTC_HandleTypeDef * hrtc); /*!< RTC Msp DeInit callback */ 00191 00192 #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ 00193 00194 }RTC_HandleTypeDef; 00195 00196 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00197 /** 00198 * @brief HAL RTC Callback ID enumeration definition 00199 */ 00200 typedef enum 00201 { 00202 HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u, /*!< RTC Alarm A Event Callback ID */ 00203 HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01u, /*!< RTC Alarm B Event Callback ID */ 00204 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02u, /*!< RTC TimeStamp Event Callback ID */ 00205 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03u, /*!< RTC Wake-Up Timer Event Callback ID */ 00206 HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u, /*!< RTC Tamper 1 Callback ID */ 00207 HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05u, /*!< RTC Tamper 2 Callback ID */ 00208 HAL_RTC_MSPINIT_CB_ID = 0x0Eu, /*!< RTC Msp Init callback ID */ 00209 HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu /*!< RTC Msp DeInit callback ID */ 00210 }HAL_RTC_CallbackIDTypeDef; 00211 00212 /** 00213 * @brief HAL RTC Callback pointer definition 00214 */ 00215 typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef * hrtc); /*!< pointer to an RTC callback function */ 00216 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 00217 00218 /** 00219 * @} 00220 */ 00221 00222 /* Exported constants --------------------------------------------------------*/ 00223 /** @defgroup RTC_Exported_Constants RTC Exported Constants 00224 * @{ 00225 */ 00226 00227 /** @defgroup RTC_Hour_Formats RTC Hour Formats 00228 * @{ 00229 */ 00230 #define RTC_HOURFORMAT_24 0x00000000U 00231 #define RTC_HOURFORMAT_12 0x00000040U 00232 /** 00233 * @} 00234 */ 00235 00236 /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions 00237 * @{ 00238 */ 00239 #define RTC_OUTPUT_DISABLE 0x00000000U 00240 #define RTC_OUTPUT_ALARMA 0x00200000U 00241 #define RTC_OUTPUT_ALARMB 0x00400000U 00242 #define RTC_OUTPUT_WAKEUP 0x00600000U 00243 /** 00244 * @} 00245 */ 00246 00247 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions 00248 * @{ 00249 */ 00250 #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U 00251 #define RTC_OUTPUT_POLARITY_LOW 0x00100000U 00252 /** 00253 * @} 00254 */ 00255 00256 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT 00257 * @{ 00258 */ 00259 #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U 00260 #define RTC_OUTPUT_TYPE_PUSHPULL 0x00040000U 00261 /** 00262 * @} 00263 */ 00264 00265 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions 00266 * @{ 00267 */ 00268 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00) 00269 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40) 00270 /** 00271 * @} 00272 */ 00273 00274 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions 00275 * @{ 00276 */ 00277 #define RTC_DAYLIGHTSAVING_SUB1H 0x00020000U 00278 #define RTC_DAYLIGHTSAVING_ADD1H 0x00010000U 00279 #define RTC_DAYLIGHTSAVING_NONE 0x00000000U 00280 /** 00281 * @} 00282 */ 00283 00284 /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions 00285 * @{ 00286 */ 00287 #define RTC_STOREOPERATION_RESET 0x00000000U 00288 #define RTC_STOREOPERATION_SET 0x00040000U 00289 /** 00290 * @} 00291 */ 00292 00293 /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions 00294 * @{ 00295 */ 00296 #define RTC_FORMAT_BIN 0x00000000U 00297 #define RTC_FORMAT_BCD 0x00000001U 00298 /** 00299 * @} 00300 */ 00301 00302 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions 00303 * @{ 00304 */ 00305 /* Coded in BCD format */ 00306 #define RTC_MONTH_JANUARY ((uint8_t)0x01) 00307 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) 00308 #define RTC_MONTH_MARCH ((uint8_t)0x03) 00309 #define RTC_MONTH_APRIL ((uint8_t)0x04) 00310 #define RTC_MONTH_MAY ((uint8_t)0x05) 00311 #define RTC_MONTH_JUNE ((uint8_t)0x06) 00312 #define RTC_MONTH_JULY ((uint8_t)0x07) 00313 #define RTC_MONTH_AUGUST ((uint8_t)0x08) 00314 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) 00315 #define RTC_MONTH_OCTOBER ((uint8_t)0x10) 00316 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) 00317 #define RTC_MONTH_DECEMBER ((uint8_t)0x12) 00318 /** 00319 * @} 00320 */ 00321 00322 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions 00323 * @{ 00324 */ 00325 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) 00326 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) 00327 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) 00328 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) 00329 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) 00330 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) 00331 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07) 00332 /** 00333 * @} 00334 */ 00335 00336 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions 00337 * @{ 00338 */ 00339 #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U 00340 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY 0x40000000U 00341 /** 00342 * @} 00343 */ 00344 00345 /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions 00346 * @{ 00347 */ 00348 #define RTC_ALARMMASK_NONE 0x00000000U 00349 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 00350 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 00351 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 00352 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 00353 #define RTC_ALARMMASK_ALL 0x80808080U 00354 /** 00355 * @} 00356 */ 00357 00358 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions 00359 * @{ 00360 */ 00361 #define RTC_ALARM_A RTC_CR_ALRAE 00362 #define RTC_ALARM_B RTC_CR_ALRBE 00363 /** 00364 * @} 00365 */ 00366 00367 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions 00368 * @{ 00369 */ 00370 #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U /*!< All Alarm SS fields are masked. 00371 There is no comparison on sub seconds 00372 for Alarm */ 00373 #define RTC_ALARMSUBSECONDMASK_SS14_1 0x01000000U /*!< SS[14:1] are don't care in Alarm 00374 comparison. Only SS[0] is compared. */ 00375 #define RTC_ALARMSUBSECONDMASK_SS14_2 0x02000000U /*!< SS[14:2] are don't care in Alarm 00376 comparison. Only SS[1:0] are compared */ 00377 #define RTC_ALARMSUBSECONDMASK_SS14_3 0x03000000U /*!< SS[14:3] are don't care in Alarm 00378 comparison. Only SS[2:0] are compared */ 00379 #define RTC_ALARMSUBSECONDMASK_SS14_4 0x04000000U /*!< SS[14:4] are don't care in Alarm 00380 comparison. Only SS[3:0] are compared */ 00381 #define RTC_ALARMSUBSECONDMASK_SS14_5 0x05000000U /*!< SS[14:5] are don't care in Alarm 00382 comparison. Only SS[4:0] are compared */ 00383 #define RTC_ALARMSUBSECONDMASK_SS14_6 0x06000000U /*!< SS[14:6] are don't care in Alarm 00384 comparison. Only SS[5:0] are compared */ 00385 #define RTC_ALARMSUBSECONDMASK_SS14_7 0x07000000U /*!< SS[14:7] are don't care in Alarm 00386 comparison. Only SS[6:0] are compared */ 00387 #define RTC_ALARMSUBSECONDMASK_SS14_8 0x08000000U /*!< SS[14:8] are don't care in Alarm 00388 comparison. Only SS[7:0] are compared */ 00389 #define RTC_ALARMSUBSECONDMASK_SS14_9 0x09000000U /*!< SS[14:9] are don't care in Alarm 00390 comparison. Only SS[8:0] are compared */ 00391 #define RTC_ALARMSUBSECONDMASK_SS14_10 0x0A000000U /*!< SS[14:10] are don't care in Alarm 00392 comparison. Only SS[9:0] are compared */ 00393 #define RTC_ALARMSUBSECONDMASK_SS14_11 0x0B000000U /*!< SS[14:11] are don't care in Alarm 00394 comparison. Only SS[10:0] are compared */ 00395 #define RTC_ALARMSUBSECONDMASK_SS14_12 0x0C000000U /*!< SS[14:12] are don't care in Alarm 00396 comparison.Only SS[11:0] are compared */ 00397 #define RTC_ALARMSUBSECONDMASK_SS14_13 0x0D000000U /*!< SS[14:13] are don't care in Alarm 00398 comparison. Only SS[12:0] are compared */ 00399 #define RTC_ALARMSUBSECONDMASK_SS14 0x0E000000U /*!< SS[14] is don't care in Alarm 00400 comparison.Only SS[13:0] are compared */ 00401 #define RTC_ALARMSUBSECONDMASK_NONE 0x0F000000U /*!< SS[14:0] are compared and must match 00402 to activate alarm. */ 00403 /** 00404 * @} 00405 */ 00406 00407 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions 00408 * @{ 00409 */ 00410 #define RTC_IT_TS 0x00008000U 00411 #define RTC_IT_WUT 0x00004000U 00412 #define RTC_IT_ALRB 0x00002000U 00413 #define RTC_IT_ALRA 0x00001000U 00414 #define RTC_IT_TAMP 0x00000004U /* Used only to Enable the Tamper Interrupt */ 00415 #define RTC_IT_TAMP1 0x00020000U 00416 #define RTC_IT_TAMP2 0x00040000U 00417 /** 00418 * @} 00419 */ 00420 00421 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions 00422 * @{ 00423 */ 00424 #define RTC_FLAG_RECALPF 0x00010000U 00425 #define RTC_FLAG_TAMP2F 0x00004000U 00426 #define RTC_FLAG_TAMP1F 0x00002000U 00427 #define RTC_FLAG_TSOVF 0x00001000U 00428 #define RTC_FLAG_TSF 0x00000800U 00429 #define RTC_FLAG_WUTF 0x00000400U 00430 #define RTC_FLAG_ALRBF 0x00000200U 00431 #define RTC_FLAG_ALRAF 0x00000100U 00432 #define RTC_FLAG_INITF 0x00000040U 00433 #define RTC_FLAG_RSF 0x00000020U 00434 #define RTC_FLAG_INITS 0x00000010U 00435 #define RTC_FLAG_SHPF 0x00000008U 00436 #define RTC_FLAG_WUTWF 0x00000004U 00437 #define RTC_FLAG_ALRBWF 0x00000002U 00438 #define RTC_FLAG_ALRAWF 0x00000001U 00439 /** 00440 * @} 00441 */ 00442 00443 /** 00444 * @} 00445 */ 00446 00447 /* Exported macro ------------------------------------------------------------*/ 00448 /** @defgroup RTC_Exported_Macros RTC Exported Macros 00449 * @{ 00450 */ 00451 00452 /** @brief Reset RTC handle state 00453 * @param __HANDLE__ specifies the RTC handle. 00454 * @retval None 00455 */ 00456 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00457 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\ 00458 (__HANDLE__)->State = HAL_RTC_STATE_RESET;\ 00459 (__HANDLE__)->MspInitCallback = NULL;\ 00460 (__HANDLE__)->MspDeInitCallback = NULL;\ 00461 }while(0u) 00462 #else 00463 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) 00464 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 00465 00466 /** 00467 * @brief Disable the write protection for RTC registers. 00468 * @param __HANDLE__ specifies the RTC handle. 00469 * @retval None 00470 */ 00471 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \ 00472 do{ \ 00473 (__HANDLE__)->Instance->WPR = 0xCAU; \ 00474 (__HANDLE__)->Instance->WPR = 0x53U; \ 00475 } while(0U) 00476 00477 /** 00478 * @brief Enable the write protection for RTC registers. 00479 * @param __HANDLE__ specifies the RTC handle. 00480 * @retval None 00481 */ 00482 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \ 00483 do{ \ 00484 (__HANDLE__)->Instance->WPR = 0xFFU; \ 00485 } while(0U) 00486 00487 /** 00488 * @brief Enable the RTC ALARMA peripheral. 00489 * @param __HANDLE__ specifies the RTC handle. 00490 * @retval None 00491 */ 00492 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) 00493 00494 /** 00495 * @brief Disable the RTC ALARMA peripheral. 00496 * @param __HANDLE__ specifies the RTC handle. 00497 * @retval None 00498 */ 00499 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) 00500 00501 /** 00502 * @brief Enable the RTC ALARMB peripheral. 00503 * @param __HANDLE__ specifies the RTC handle. 00504 * @retval None 00505 */ 00506 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) 00507 00508 /** 00509 * @brief Disable the RTC ALARMB peripheral. 00510 * @param __HANDLE__ specifies the RTC handle. 00511 * @retval None 00512 */ 00513 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) 00514 00515 /** 00516 * @brief Enable the RTC Alarm interrupt. 00517 * @param __HANDLE__ specifies the RTC handle. 00518 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 00519 * This parameter can be any combination of the following values: 00520 * @arg RTC_IT_ALRA: Alarm A interrupt 00521 * @arg RTC_IT_ALRB: Alarm B interrupt 00522 * @retval None 00523 */ 00524 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) 00525 00526 /** 00527 * @brief Disable the RTC Alarm interrupt. 00528 * @param __HANDLE__ specifies the RTC handle. 00529 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. 00530 * This parameter can be any combination of the following values: 00531 * @arg RTC_IT_ALRA: Alarm A interrupt 00532 * @arg RTC_IT_ALRB: Alarm B interrupt 00533 * @retval None 00534 */ 00535 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) 00536 00537 /** 00538 * @brief Check whether the specified RTC Alarm interrupt has occurred or not. 00539 * @param __HANDLE__ specifies the RTC handle. 00540 * @param __INTERRUPT__ specifies the RTC Alarm interrupt to check. 00541 * This parameter can be: 00542 * @arg RTC_IT_ALRA: Alarm A interrupt 00543 * @arg RTC_IT_ALRB: Alarm B interrupt 00544 * @retval None 00545 */ 00546 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) != RESET)? SET : RESET) 00547 00548 /** 00549 * @brief Get the selected RTC Alarm's flag status. 00550 * @param __HANDLE__ specifies the RTC handle. 00551 * @param __FLAG__ specifies the RTC Alarm Flag to check. 00552 * This parameter can be: 00553 * @arg RTC_FLAG_ALRAF 00554 * @arg RTC_FLAG_ALRBF 00555 * @arg RTC_FLAG_ALRAWF 00556 * @arg RTC_FLAG_ALRBWF 00557 * @retval None 00558 */ 00559 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET) 00560 00561 /** 00562 * @brief Clear the RTC Alarm's pending flags. 00563 * @param __HANDLE__ specifies the RTC handle. 00564 * @param __FLAG__ specifies the RTC Alarm Flag sources to be enabled or disabled. 00565 * This parameter can be: 00566 * @arg RTC_FLAG_ALRAF 00567 * @arg RTC_FLAG_ALRBF 00568 * @retval None 00569 */ 00570 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) 00571 00572 00573 /** 00574 * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. 00575 * @param __HANDLE__ specifies the RTC handle. 00576 * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. 00577 * This parameter can be: 00578 * @arg RTC_IT_ALRA: Alarm A interrupt 00579 * @arg RTC_IT_ALRB: Alarm B interrupt 00580 * @retval None 00581 */ 00582 #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != RESET) ? SET : RESET) 00583 00584 /** 00585 * @brief Enable interrupt on the RTC Alarm associated Exti line. 00586 * @retval None 00587 */ 00588 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT) 00589 00590 /** 00591 * @brief Disable interrupt on the RTC Alarm associated Exti line. 00592 * @retval None 00593 */ 00594 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00595 00596 /** 00597 * @brief Enable event on the RTC Alarm associated Exti line. 00598 * @retval None. 00599 */ 00600 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT) 00601 00602 /** 00603 * @brief Disable event on the RTC Alarm associated Exti line. 00604 * @retval None. 00605 */ 00606 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00607 00608 /** 00609 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line. 00610 * @retval None. 00611 */ 00612 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT) 00613 00614 /** 00615 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line. 00616 * @retval None. 00617 */ 00618 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00619 00620 /** 00621 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line. 00622 * @retval None. 00623 */ 00624 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT) 00625 00626 /** 00627 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line. 00628 * @retval None. 00629 */ 00630 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT)) 00631 00632 /** 00633 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line. 00634 * @retval None. 00635 */ 00636 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ 00637 __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();\ 00638 } while(0U) 00639 00640 /** 00641 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line. 00642 * @retval None. 00643 */ 00644 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();\ 00645 __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();\ 00646 } while(0U) 00647 00648 /** 00649 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not. 00650 * @retval Line Status. 00651 */ 00652 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT) 00653 00654 /** 00655 * @brief Clear the RTC Alarm associated Exti line flag. 00656 * @retval None. 00657 */ 00658 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT) 00659 00660 /** 00661 * @brief Generate a Software interrupt on RTC Alarm associated Exti line. 00662 * @retval None. 00663 */ 00664 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT) 00665 /** 00666 * @} 00667 */ 00668 00669 /* Include RTC HAL Extension module */ 00670 #include "stm32f4xx_hal_rtc_ex.h" 00671 00672 /* Exported functions --------------------------------------------------------*/ 00673 /** @addtogroup RTC_Exported_Functions 00674 * @{ 00675 */ 00676 00677 /** @addtogroup RTC_Exported_Functions_Group1 00678 * @{ 00679 */ 00680 /* Initialization and de-initialization functions ****************************/ 00681 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); 00682 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); 00683 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); 00684 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); 00685 00686 /* Callbacks Register/UnRegister functions ***********************************/ 00687 #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) 00688 HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); 00689 HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); 00690 #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ 00691 /** 00692 * @} 00693 */ 00694 00695 /** @addtogroup RTC_Exported_Functions_Group2 00696 * @{ 00697 */ 00698 /* RTC Time and Date functions ************************************************/ 00699 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 00700 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); 00701 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 00702 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); 00703 void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc); 00704 void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc); 00705 void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc); 00706 void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc); 00707 uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc); 00708 /** 00709 * @} 00710 */ 00711 00712 /** @addtogroup RTC_Exported_Functions_Group3 00713 * @{ 00714 */ 00715 /* RTC Alarm functions ********************************************************/ 00716 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 00717 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); 00718 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); 00719 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); 00720 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); 00721 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); 00722 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); 00723 /** 00724 * @} 00725 */ 00726 00727 /** @addtogroup RTC_Exported_Functions_Group4 00728 * @{ 00729 */ 00730 /* Peripheral Control functions ***********************************************/ 00731 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc); 00732 /** 00733 * @} 00734 */ 00735 00736 /** @addtogroup RTC_Exported_Functions_Group5 00737 * @{ 00738 */ 00739 /* Peripheral State functions *************************************************/ 00740 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); 00741 /** 00742 * @} 00743 */ 00744 00745 /** 00746 * @} 00747 */ 00748 00749 /* Private types -------------------------------------------------------------*/ 00750 /* Private variables ---------------------------------------------------------*/ 00751 /* Private constants ---------------------------------------------------------*/ 00752 /** @defgroup RTC_Private_Constants RTC Private Constants 00753 * @{ 00754 */ 00755 /* Masks Definition */ 00756 #define RTC_TR_RESERVED_MASK 0x007F7F7FU 00757 #define RTC_DR_RESERVED_MASK 0x00FFFF3FU 00758 #define RTC_INIT_MASK 0xFFFFFFFFU 00759 #define RTC_RSF_MASK 0xFFFFFF5FU 00760 #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_TSOVF | RTC_FLAG_TSF | RTC_FLAG_WUTF | \ 00761 RTC_FLAG_ALRBF | RTC_FLAG_ALRAF | RTC_FLAG_INITF | \ 00762 RTC_FLAG_RSF | RTC_FLAG_INITS | RTC_FLAG_WUTWF | \ 00763 RTC_FLAG_ALRBWF | RTC_FLAG_ALRAWF | RTC_FLAG_TAMP1F | \ 00764 RTC_FLAG_RECALPF | RTC_FLAG_SHPF)) 00765 00766 #define RTC_TIMEOUT_VALUE 1000 00767 00768 #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */ 00769 /** 00770 * @} 00771 */ 00772 00773 /* Private macros ------------------------------------------------------------*/ 00774 /** @defgroup RTC_Private_Macros RTC Private Macros 00775 * @{ 00776 */ 00777 00778 /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters 00779 * @{ 00780 */ 00781 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ 00782 ((FORMAT) == RTC_HOURFORMAT_24)) 00783 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ 00784 ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ 00785 ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ 00786 ((OUTPUT) == RTC_OUTPUT_WAKEUP)) 00787 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ 00788 ((POL) == RTC_OUTPUT_POLARITY_LOW)) 00789 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ 00790 ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) 00791 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U)) 00792 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U) 00793 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU) 00794 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU) 00795 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U) 00796 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U) 00797 00798 #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM)) 00799 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ 00800 ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ 00801 ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) 00802 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ 00803 ((OPERATION) == RTC_STOREOPERATION_SET)) 00804 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD)) 00805 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U) 00806 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U)) 00807 #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U)) 00808 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 00809 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 00810 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 00811 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 00812 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 00813 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 00814 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 00815 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U)) 00816 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ 00817 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ 00818 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ 00819 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ 00820 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ 00821 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ 00822 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) 00823 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ 00824 ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) 00825 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7FU) == (uint32_t)RESET) 00826 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B)) 00827 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFFU) 00828 00829 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ 00830 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ 00831 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ 00832 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ 00833 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ 00834 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ 00835 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ 00836 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ 00837 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ 00838 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ 00839 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ 00840 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ 00841 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ 00842 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ 00843 ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ 00844 ((MASK) == RTC_ALARMSUBSECONDMASK_NONE)) 00845 /** 00846 * @} 00847 */ 00848 00849 /** 00850 * @} 00851 */ 00852 00853 /* Private functions ---------------------------------------------------------*/ 00854 /** @defgroup RTC_Private_Functions RTC Private Functions 00855 * @{ 00856 */ 00857 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc); 00858 uint8_t RTC_ByteToBcd2(uint8_t Value); 00859 uint8_t RTC_Bcd2ToByte(uint8_t Value); 00860 /** 00861 * @} 00862 */ 00863 00864 /** 00865 * @} 00866 */ 00867 00868 /** 00869 * @} 00870 */ 00871 00872 #ifdef __cplusplus 00873 } 00874 #endif 00875 00876 #endif /* __STM32F4xx_HAL_RTC_H */ 00877 00878 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/