Rev 61 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 77 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32l1xx_hal_rtc.h |
||
| 4 | * @author MCD Application Team |
||
| 5 | * @brief Header file of RTC HAL module. |
||
| 6 | ****************************************************************************** |
||
| 7 | * @attention |
||
| 8 | * |
||
| 9 | * Copyright (c) 2016 STMicroelectronics. |
||
| 10 | * All rights reserved. |
||
| 11 | * |
||
| 12 | * This software is licensed under terms that can be found in the LICENSE file |
||
| 13 | * in the root directory of this software component. |
||
| 14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
||
| 15 | * |
||
| 16 | ****************************************************************************** |
||
| 17 | */ |
||
| 18 | |||
| 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
| 20 | #ifndef STM32L1xx_HAL_RTC_H |
||
| 21 | #define STM32L1xx_HAL_RTC_H |
||
| 22 | |||
| 23 | #ifdef __cplusplus |
||
| 24 | extern "C" { |
||
| 25 | #endif |
||
| 26 | |||
| 27 | /* Includes ------------------------------------------------------------------*/ |
||
| 28 | |||
| 29 | #include "stm32l1xx_hal_def.h" |
||
| 30 | |||
| 31 | /** @addtogroup STM32L1xx_HAL_Driver |
||
| 32 | * @{ |
||
| 33 | */ |
||
| 34 | |||
| 35 | /** @addtogroup RTC |
||
| 36 | * @{ |
||
| 37 | */ |
||
| 38 | |||
| 39 | /* Exported types ------------------------------------------------------------*/ |
||
| 40 | |||
| 41 | /** @defgroup RTC_Exported_Types RTC Exported Types |
||
| 42 | * @{ |
||
| 43 | */ |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @brief HAL State structures definition |
||
| 47 | */ |
||
| 48 | typedef enum |
||
| 49 | { |
||
| 50 | HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ |
||
| 51 | HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ |
||
| 52 | HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ |
||
| 53 | HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ |
||
| 54 | HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ |
||
| 55 | } HAL_RTCStateTypeDef; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @brief RTC Configuration Structure definition |
||
| 59 | */ |
||
| 60 | typedef struct |
||
| 61 | { |
||
| 62 | uint32_t HourFormat; /*!< Specifies the RTC Hour Format. |
||
| 63 | This parameter can be a value of @ref RTC_Hour_Formats */ |
||
| 64 | |||
| 65 | uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. |
||
| 66 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */ |
||
| 67 | |||
| 68 | uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. |
||
| 69 | This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x7FFF */ |
||
| 70 | |||
| 71 | uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output. |
||
| 72 | This parameter can be a value of @ref RTC_Output_selection_Definitions */ |
||
| 73 | |||
| 74 | uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal. |
||
| 75 | This parameter can be a value of @ref RTC_Output_Polarity_Definitions */ |
||
| 76 | |||
| 77 | uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode. |
||
| 78 | This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */ |
||
| 79 | } RTC_InitTypeDef; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @brief RTC Time structure definition |
||
| 83 | */ |
||
| 84 | typedef struct |
||
| 85 | { |
||
| 86 | uint8_t Hours; /*!< Specifies the RTC Time Hour. |
||
| 87 | This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected |
||
| 88 | This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */ |
||
| 89 | |||
| 90 | uint8_t Minutes; /*!< Specifies the RTC Time Minutes. |
||
| 91 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 92 | |||
| 93 | uint8_t Seconds; /*!< Specifies the RTC Time Seconds. |
||
| 94 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 95 | |||
| 96 | uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time. |
||
| 97 | This parameter can be a value of @ref RTC_AM_PM_Definitions */ |
||
| 98 | |||
| 99 | #if defined(RTC_SUBSECOND_SUPPORT) |
||
| 100 | uint32_t SubSeconds; /*!< Specifies the RTC_SSR RTC Sub Second register content. |
||
| 101 | This parameter corresponds to a time unit range between [0-1] Second |
||
| 102 | with [1 Sec / SecondFraction +1] granularity */ |
||
| 103 | |||
| 104 | uint32_t SecondFraction; /*!< Specifies the range or granularity of Sub Second register content |
||
| 105 | corresponding to Synchronous prescaler factor value (PREDIV_S) |
||
| 106 | This parameter corresponds to a time unit range between [0-1] Second |
||
| 107 | with [1 Sec / SecondFraction +1] granularity. |
||
| 108 | This field will be used only by HAL_RTC_GetTime function */ |
||
| 109 | #endif /* RTC_SUBSECOND_SUPPORT */ |
||
| 110 | |||
| 111 | uint32_t DayLightSaving; /*!< This interface is deprecated. To manage Daylight |
||
| 112 | Saving Time, please use HAL_RTC_DST_xxx functions */ |
||
| 113 | |||
| 114 | uint32_t StoreOperation; /*!< This interface is deprecated. To manage Daylight |
||
| 115 | Saving Time, please use HAL_RTC_DST_xxx functions */ |
||
| 116 | } RTC_TimeTypeDef; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @brief RTC Date structure definition |
||
| 120 | */ |
||
| 121 | typedef struct |
||
| 122 | { |
||
| 123 | uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay. |
||
| 124 | This parameter can be a value of @ref RTC_WeekDay_Definitions */ |
||
| 125 | |||
| 126 | uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). |
||
| 127 | This parameter can be a value of @ref RTC_Month_Date_Definitions */ |
||
| 128 | |||
| 129 | uint8_t Date; /*!< Specifies the RTC Date. |
||
| 130 | This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ |
||
| 131 | |||
| 132 | uint8_t Year; /*!< Specifies the RTC Date Year. |
||
| 133 | This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ |
||
| 134 | |||
| 135 | } RTC_DateTypeDef; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @brief RTC Alarm structure definition |
||
| 139 | */ |
||
| 140 | typedef struct |
||
| 141 | { |
||
| 142 | RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ |
||
| 143 | |||
| 144 | uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks. |
||
| 145 | This parameter can be a value of @ref RTC_AlarmMask_Definitions */ |
||
| 146 | |||
| 147 | #if defined(RTC_SUBSECOND_SUPPORT) |
||
| 148 | uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks. |
||
| 149 | This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */ |
||
| 150 | #endif /* RTC_SUBSECOND_SUPPORT */ |
||
| 151 | |||
| 152 | uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. |
||
| 153 | This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ |
||
| 154 | |||
| 155 | uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. |
||
| 156 | If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range. |
||
| 157 | If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */ |
||
| 158 | |||
| 159 | uint32_t Alarm; /*!< Specifies the alarm . |
||
| 160 | This parameter can be a value of @ref RTC_Alarms_Definitions */ |
||
| 161 | } RTC_AlarmTypeDef; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @brief RTC Handle Structure definition |
||
| 165 | */ |
||
| 166 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 167 | typedef struct __RTC_HandleTypeDef |
||
| 168 | #else |
||
| 169 | typedef struct |
||
| 170 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 171 | { |
||
| 172 | RTC_TypeDef *Instance; /*!< Register base address */ |
||
| 173 | |||
| 174 | RTC_InitTypeDef Init; /*!< RTC required parameters */ |
||
| 175 | |||
| 176 | HAL_LockTypeDef Lock; /*!< RTC locking object */ |
||
| 177 | |||
| 178 | __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ |
||
| 179 | |||
| 180 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 181 | void (* AlarmAEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */ |
||
| 182 | |||
| 183 | void (* AlarmBEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm B Event callback */ |
||
| 184 | |||
| 185 | void (* TimeStampEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Timestamp Event callback */ |
||
| 186 | |||
| 187 | void (* WakeUpTimerEventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC WakeUpTimer Event callback */ |
||
| 188 | |||
| 189 | void (* Tamper1EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */ |
||
| 190 | |||
| 191 | #if defined(RTC_TAMPER2_SUPPORT) |
||
| 192 | void (* Tamper2EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 2 Event callback */ |
||
| 193 | #endif /* RTC_TAMPER2_SUPPORT */ |
||
| 194 | |||
| 195 | #if defined(RTC_TAMPER3_SUPPORT) |
||
| 196 | void (* Tamper3EventCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 3 Event callback */ |
||
| 197 | #endif /* RTC_TAMPER3_SUPPORT */ |
||
| 198 | |||
| 199 | void (* MspInitCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */ |
||
| 200 | |||
| 201 | void (* MspDeInitCallback) (struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */ |
||
| 202 | |||
| 203 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 204 | |||
| 205 | } RTC_HandleTypeDef; |
||
| 206 | |||
| 207 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 208 | /** |
||
| 209 | * @brief HAL RTC Callback ID enumeration definition |
||
| 210 | */ |
||
| 211 | typedef enum |
||
| 212 | { |
||
| 213 | HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00U, /*!< RTC Alarm A Event Callback ID */ |
||
| 214 | HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01U, /*!< RTC Alarm B Event Callback ID */ |
||
| 215 | HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02U, /*!< RTC Timestamp Event Callback ID */ |
||
| 216 | HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03U, /*!< RTC Wakeup Timer Event Callback ID */ |
||
| 217 | HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04U, /*!< RTC Tamper 1 Callback ID */ |
||
| 218 | #if defined(RTC_TAMPER2_SUPPORT) |
||
| 219 | HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05U, /*!< RTC Tamper 2 Callback ID */ |
||
| 220 | #endif /* RTC_TAMPER2_SUPPORT */ |
||
| 221 | #if defined(RTC_TAMPER3_SUPPORT) |
||
| 222 | HAL_RTC_TAMPER3_EVENT_CB_ID = 0x06U, /*!< RTC Tamper 3 Callback ID */ |
||
| 223 | #endif /* RTC_TAMPER3_SUPPORT */ |
||
| 224 | HAL_RTC_MSPINIT_CB_ID = 0x0EU, /*!< RTC Msp Init callback ID */ |
||
| 225 | HAL_RTC_MSPDEINIT_CB_ID = 0x0FU /*!< RTC Msp DeInit callback ID */ |
||
| 226 | } HAL_RTC_CallbackIDTypeDef; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @brief HAL RTC Callback pointer definition |
||
| 230 | */ |
||
| 231 | typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */ |
||
| 232 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @} |
||
| 236 | */ |
||
| 237 | |||
| 238 | /* Exported constants --------------------------------------------------------*/ |
||
| 239 | |||
| 240 | /** @defgroup RTC_Exported_Constants RTC Exported Constants |
||
| 241 | * @{ |
||
| 242 | */ |
||
| 243 | |||
| 244 | /** @defgroup RTC_Hour_Formats RTC Hour Formats |
||
| 245 | * @{ |
||
| 246 | */ |
||
| 247 | #define RTC_HOURFORMAT_24 0x00000000U |
||
| 248 | #define RTC_HOURFORMAT_12 RTC_CR_FMT |
||
| 249 | /** |
||
| 250 | * @} |
||
| 251 | */ |
||
| 252 | |||
| 253 | /** @defgroup RTC_Output_selection_Definitions RTC Output Selection Definitions |
||
| 254 | * @{ |
||
| 255 | */ |
||
| 256 | #define RTC_OUTPUT_DISABLE 0x00000000U |
||
| 257 | #define RTC_OUTPUT_ALARMA RTC_CR_OSEL_0 |
||
| 258 | #define RTC_OUTPUT_ALARMB RTC_CR_OSEL_1 |
||
| 259 | #define RTC_OUTPUT_WAKEUP RTC_CR_OSEL |
||
| 260 | /** |
||
| 261 | * @} |
||
| 262 | */ |
||
| 263 | |||
| 264 | /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions |
||
| 265 | * @{ |
||
| 266 | */ |
||
| 267 | #define RTC_OUTPUT_POLARITY_HIGH 0x00000000U |
||
| 268 | #define RTC_OUTPUT_POLARITY_LOW RTC_CR_POL |
||
| 269 | /** |
||
| 270 | * @} |
||
| 271 | */ |
||
| 272 | |||
| 273 | /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT |
||
| 274 | * @{ |
||
| 275 | */ |
||
| 276 | #define RTC_OUTPUT_TYPE_OPENDRAIN 0x00000000U |
||
| 277 | #define RTC_OUTPUT_TYPE_PUSHPULL RTC_TAFCR_ALARMOUTTYPE |
||
| 278 | /** |
||
| 279 | * @} |
||
| 280 | */ |
||
| 281 | |||
| 282 | /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions |
||
| 283 | * @{ |
||
| 284 | */ |
||
| 285 | #define RTC_HOURFORMAT12_AM ((uint8_t)0x00) |
||
| 286 | #define RTC_HOURFORMAT12_PM ((uint8_t)0x01) |
||
| 287 | /** |
||
| 288 | * @} |
||
| 289 | */ |
||
| 290 | |||
| 291 | /** @defgroup RTC_DayLightSaving_Definitions RTC DayLight Saving Definitions |
||
| 292 | * @{ |
||
| 293 | */ |
||
| 294 | #define RTC_DAYLIGHTSAVING_SUB1H RTC_CR_SUB1H |
||
| 295 | #define RTC_DAYLIGHTSAVING_ADD1H RTC_CR_ADD1H |
||
| 296 | #define RTC_DAYLIGHTSAVING_NONE 0x00000000U |
||
| 297 | /** |
||
| 298 | * @} |
||
| 299 | */ |
||
| 300 | |||
| 301 | /** @defgroup RTC_StoreOperation_Definitions RTC Store Operation Definitions |
||
| 302 | * @{ |
||
| 303 | */ |
||
| 304 | #define RTC_STOREOPERATION_RESET 0x00000000U |
||
| 305 | #define RTC_STOREOPERATION_SET RTC_CR_BKP |
||
| 306 | /** |
||
| 307 | * @} |
||
| 308 | */ |
||
| 309 | |||
| 310 | /** @defgroup RTC_Input_parameter_format_definitions RTC Input Parameter Format Definitions |
||
| 311 | * @{ |
||
| 312 | */ |
||
| 313 | #define RTC_FORMAT_BIN 0x00000000U |
||
| 314 | #define RTC_FORMAT_BCD 0x00000001U |
||
| 315 | /** |
||
| 316 | * @} |
||
| 317 | */ |
||
| 318 | |||
| 319 | /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions (in BCD format) |
||
| 320 | * @{ |
||
| 321 | */ |
||
| 322 | #define RTC_MONTH_JANUARY ((uint8_t)0x01) |
||
| 323 | #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) |
||
| 324 | #define RTC_MONTH_MARCH ((uint8_t)0x03) |
||
| 325 | #define RTC_MONTH_APRIL ((uint8_t)0x04) |
||
| 326 | #define RTC_MONTH_MAY ((uint8_t)0x05) |
||
| 327 | #define RTC_MONTH_JUNE ((uint8_t)0x06) |
||
| 328 | #define RTC_MONTH_JULY ((uint8_t)0x07) |
||
| 329 | #define RTC_MONTH_AUGUST ((uint8_t)0x08) |
||
| 330 | #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) |
||
| 331 | #define RTC_MONTH_OCTOBER ((uint8_t)0x10) |
||
| 332 | #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) |
||
| 333 | #define RTC_MONTH_DECEMBER ((uint8_t)0x12) |
||
| 334 | /** |
||
| 335 | * @} |
||
| 336 | */ |
||
| 337 | |||
| 338 | /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions |
||
| 339 | * @{ |
||
| 340 | */ |
||
| 341 | #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) |
||
| 342 | #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) |
||
| 343 | #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) |
||
| 344 | #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) |
||
| 345 | #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) |
||
| 346 | #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) |
||
| 347 | #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07) |
||
| 348 | /** |
||
| 349 | * @} |
||
| 350 | */ |
||
| 351 | |||
| 352 | /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC Alarm Date WeekDay Definitions |
||
| 353 | * @{ |
||
| 354 | */ |
||
| 355 | #define RTC_ALARMDATEWEEKDAYSEL_DATE 0x00000000U |
||
| 356 | #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL |
||
| 357 | /** |
||
| 358 | * @} |
||
| 359 | */ |
||
| 360 | |||
| 361 | /** @defgroup RTC_AlarmMask_Definitions RTC Alarm Mask Definitions |
||
| 362 | * @{ |
||
| 363 | */ |
||
| 364 | #define RTC_ALARMMASK_NONE 0x00000000U |
||
| 365 | #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4 |
||
| 366 | #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3 |
||
| 367 | #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2 |
||
| 368 | #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1 |
||
| 369 | #define RTC_ALARMMASK_ALL (RTC_ALARMMASK_DATEWEEKDAY | \ |
||
| 370 | RTC_ALARMMASK_HOURS | \ |
||
| 371 | RTC_ALARMMASK_MINUTES | \ |
||
| 372 | RTC_ALARMMASK_SECONDS) |
||
| 373 | /** |
||
| 374 | * @} |
||
| 375 | */ |
||
| 376 | |||
| 377 | /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions |
||
| 378 | * @{ |
||
| 379 | */ |
||
| 380 | #define RTC_ALARM_A RTC_CR_ALRAE |
||
| 381 | #define RTC_ALARM_B RTC_CR_ALRBE |
||
| 382 | /** |
||
| 383 | * @} |
||
| 384 | */ |
||
| 385 | |||
| 386 | #if defined(RTC_SUBSECOND_SUPPORT) |
||
| 387 | /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions |
||
| 388 | * @{ |
||
| 389 | */ |
||
| 390 | /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */ |
||
| 391 | #define RTC_ALARMSUBSECONDMASK_ALL 0x00000000U |
||
| 392 | /*!< SS[14:1] are don't care in Alarm comparison. Only SS[0] is compared. */ |
||
| 393 | #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 |
||
| 394 | /*!< SS[14:2] are don't care in Alarm comparison. Only SS[1:0] are compared. */ |
||
| 395 | #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 |
||
| 396 | /*!< SS[14:3] are don't care in Alarm comparison. Only SS[2:0] are compared. */ |
||
| 397 | #define RTC_ALARMSUBSECONDMASK_SS14_3 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1) |
||
| 398 | /*!< SS[14:4] are don't care in Alarm comparison. Only SS[3:0] are compared. */ |
||
| 399 | #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 |
||
| 400 | /*!< SS[14:5] are don't care in Alarm comparison. Only SS[4:0] are compared. */ |
||
| 401 | #define RTC_ALARMSUBSECONDMASK_SS14_5 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2) |
||
| 402 | /*!< SS[14:6] are don't care in Alarm comparison. Only SS[5:0] are compared. */ |
||
| 403 | #define RTC_ALARMSUBSECONDMASK_SS14_6 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) |
||
| 404 | /*!< SS[14:7] are don't care in Alarm comparison. Only SS[6:0] are compared. */ |
||
| 405 | #define RTC_ALARMSUBSECONDMASK_SS14_7 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2) |
||
| 406 | /*!< SS[14:8] are don't care in Alarm comparison. Only SS[7:0] are compared. */ |
||
| 407 | #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 |
||
| 408 | /*!< SS[14:9] are don't care in Alarm comparison. Only SS[8:0] are compared. */ |
||
| 409 | #define RTC_ALARMSUBSECONDMASK_SS14_9 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3) |
||
| 410 | /*!< SS[14:10] are don't care in Alarm comparison. Only SS[9:0] are compared. */ |
||
| 411 | #define RTC_ALARMSUBSECONDMASK_SS14_10 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) |
||
| 412 | /*!< SS[14:11] are don't care in Alarm comparison. Only SS[10:0] are compared. */ |
||
| 413 | #define RTC_ALARMSUBSECONDMASK_SS14_11 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3) |
||
| 414 | /*!< SS[14:12] are don't care in Alarm comparison. Only SS[11:0] are compared. */ |
||
| 415 | #define RTC_ALARMSUBSECONDMASK_SS14_12 (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) |
||
| 416 | /*!< SS[14:13] are don't care in Alarm comparison. Only SS[12:0] are compared. */ |
||
| 417 | #define RTC_ALARMSUBSECONDMASK_SS14_13 (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) |
||
| 418 | /*!< SS[14] is don't care in Alarm comparison. Only SS[13:0] are compared. */ |
||
| 419 | #define RTC_ALARMSUBSECONDMASK_SS14 (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3) |
||
| 420 | /*!< SS[14:0] are compared and must match to activate alarm. */ |
||
| 421 | #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS |
||
| 422 | /** |
||
| 423 | * @} |
||
| 424 | */ |
||
| 425 | #endif /* RTC_SUBSECOND_SUPPORT */ |
||
| 426 | |||
| 427 | /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions |
||
| 428 | * @{ |
||
| 429 | */ |
||
| 430 | #define RTC_IT_TS RTC_CR_TSIE /*!< Enable Timestamp Interrupt */ |
||
| 431 | #define RTC_IT_WUT RTC_CR_WUTIE /*!< Enable Wakeup timer Interrupt */ |
||
| 432 | #define RTC_IT_ALRB RTC_CR_ALRBIE /*!< Enable Alarm B Interrupt */ |
||
| 433 | #define RTC_IT_ALRA RTC_CR_ALRAIE /*!< Enable Alarm A Interrupt */ |
||
| 434 | /** |
||
| 435 | * @} |
||
| 436 | */ |
||
| 437 | |||
| 438 | /** @defgroup RTC_Flags_Definitions RTC Flags Definitions |
||
| 439 | * @{ |
||
| 440 | */ |
||
| 441 | #if defined(RTC_SMOOTHCALIB_SUPPORT) |
||
| 442 | #define RTC_FLAG_RECALPF RTC_ISR_RECALPF /*!< Recalibration pending flag */ |
||
| 443 | #endif /* RTC_SMOOTHCALIB_SUPPORT */ |
||
| 444 | #if defined(RTC_TAMPER3_SUPPORT) |
||
| 445 | #define RTC_FLAG_TAMP3F RTC_ISR_TAMP3F /*!< Tamper 3 event flag */ |
||
| 446 | #endif /* RTC_TAMPER3_SUPPORT */ |
||
| 447 | #if defined(RTC_TAMPER2_SUPPORT) |
||
| 448 | #define RTC_FLAG_TAMP2F RTC_ISR_TAMP2F /*!< Tamper 2 event flag */ |
||
| 449 | #endif /* RTC_TAMPER2_SUPPORT */ |
||
| 450 | #define RTC_FLAG_TAMP1F RTC_ISR_TAMP1F /*!< Tamper 1 event flag */ |
||
| 451 | #define RTC_FLAG_TSOVF RTC_ISR_TSOVF /*!< Timestamp overflow flag */ |
||
| 452 | #define RTC_FLAG_TSF RTC_ISR_TSF /*!< Timestamp event flag */ |
||
| 453 | #define RTC_FLAG_WUTF RTC_ISR_WUTF /*!< Wakeup timer event flag */ |
||
| 454 | #define RTC_FLAG_ALRBF RTC_ISR_ALRBF /*!< Alarm B event flag */ |
||
| 455 | #define RTC_FLAG_ALRAF RTC_ISR_ALRAF /*!< Alarm A event flag */ |
||
| 456 | #define RTC_FLAG_INITF RTC_ISR_INITF /*!< RTC in initialization mode flag */ |
||
| 457 | #define RTC_FLAG_RSF RTC_ISR_RSF /*!< Register synchronization flag */ |
||
| 458 | #define RTC_FLAG_INITS RTC_ISR_INITS /*!< RTC initialization status flag */ |
||
| 459 | #if defined(RTC_SUBSECOND_SUPPORT) |
||
| 460 | #define RTC_FLAG_SHPF RTC_ISR_SHPF /*!< Shift operation pending flag */ |
||
| 461 | #endif /* RTC_SUBSECOND_SUPPORT */ |
||
| 462 | #define RTC_FLAG_WUTWF RTC_ISR_WUTWF /*!< WUTR register write allowance flag */ |
||
| 463 | #define RTC_FLAG_ALRBWF RTC_ISR_ALRBWF /*!< ALRMBR register write allowance flag */ |
||
| 464 | #define RTC_FLAG_ALRAWF RTC_ISR_ALRAWF /*!< ALRMAR register write allowance flag */ |
||
| 465 | /** |
||
| 466 | * @} |
||
| 467 | */ |
||
| 468 | |||
| 469 | /** |
||
| 470 | * @} |
||
| 471 | */ |
||
| 472 | |||
| 473 | /* Exported macros -----------------------------------------------------------*/ |
||
| 474 | |||
| 475 | /** @defgroup RTC_Exported_Macros RTC Exported Macros |
||
| 476 | * @{ |
||
| 477 | */ |
||
| 478 | |||
| 479 | /** @brief Reset RTC handle state |
||
| 480 | * @param __HANDLE__ specifies the RTC handle. |
||
| 481 | * @retval None |
||
| 482 | */ |
||
| 483 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 484 | #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do { \ |
||
| 485 | (__HANDLE__)->State = HAL_RTC_STATE_RESET; \ |
||
| 486 | (__HANDLE__)->MspInitCallback = NULL; \ |
||
| 487 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
||
| 488 | } while(0U) |
||
| 489 | #else |
||
| 490 | #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) |
||
| 491 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 492 | |||
| 493 | /** |
||
| 494 | * @brief Disable the write protection for RTC registers. |
||
| 495 | * @param __HANDLE__ specifies the RTC handle. |
||
| 496 | * @retval None |
||
| 497 | */ |
||
| 498 | #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) do { \ |
||
| 499 | (__HANDLE__)->Instance->WPR = 0xCAU; \ |
||
| 500 | (__HANDLE__)->Instance->WPR = 0x53U; \ |
||
| 501 | } while(0U) |
||
| 502 | |||
| 503 | /** |
||
| 504 | * @brief Enable the write protection for RTC registers. |
||
| 505 | * @param __HANDLE__ specifies the RTC handle. |
||
| 506 | * @retval None |
||
| 507 | */ |
||
| 508 | #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) do { \ |
||
| 509 | (__HANDLE__)->Instance->WPR = 0xFFU; \ |
||
| 510 | } while(0U) |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @brief Check whether the RTC Calendar is initialized. |
||
| 514 | * @param __HANDLE__ specifies the RTC handle. |
||
| 515 | * @retval None |
||
| 516 | */ |
||
| 517 | #define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_FLAG_INITS)) == RTC_FLAG_INITS) ? 1U : 0U) |
||
| 518 | |||
| 519 | /** |
||
| 520 | * @brief Enable the RTC ALARMA peripheral. |
||
| 521 | * @param __HANDLE__ specifies the RTC handle. |
||
| 522 | * @retval None |
||
| 523 | */ |
||
| 524 | #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE)) |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @brief Disable the RTC ALARMA peripheral. |
||
| 528 | * @param __HANDLE__ specifies the RTC handle. |
||
| 529 | * @retval None |
||
| 530 | */ |
||
| 531 | #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE)) |
||
| 532 | |||
| 533 | /** |
||
| 534 | * @brief Enable the RTC ALARMB peripheral. |
||
| 535 | * @param __HANDLE__ specifies the RTC handle. |
||
| 536 | * @retval None |
||
| 537 | */ |
||
| 538 | #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE)) |
||
| 539 | |||
| 540 | /** |
||
| 541 | * @brief Disable the RTC ALARMB peripheral. |
||
| 542 | * @param __HANDLE__ specifies the RTC handle. |
||
| 543 | * @retval None |
||
| 544 | */ |
||
| 545 | #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE)) |
||
| 546 | |||
| 547 | /** |
||
| 548 | * @brief Enable the RTC Alarm interrupt. |
||
| 549 | * @param __HANDLE__ specifies the RTC handle. |
||
| 550 | * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. |
||
| 551 | * This parameter can be any combination of the following values: |
||
| 552 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 553 | * @arg RTC_IT_ALRB: Alarm B interrupt |
||
| 554 | * @retval None |
||
| 555 | */ |
||
| 556 | #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__)) |
||
| 557 | |||
| 558 | /** |
||
| 559 | * @brief Disable the RTC Alarm interrupt. |
||
| 560 | * @param __HANDLE__ specifies the RTC handle. |
||
| 561 | * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled. |
||
| 562 | * This parameter can be any combination of the following values: |
||
| 563 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 564 | * @arg RTC_IT_ALRB: Alarm B interrupt |
||
| 565 | * @retval None |
||
| 566 | */ |
||
| 567 | #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__)) |
||
| 568 | |||
| 569 | /** |
||
| 570 | * @brief Check whether the specified RTC Alarm interrupt has occurred or not. |
||
| 571 | * @param __HANDLE__ specifies the RTC handle. |
||
| 572 | * @param __INTERRUPT__ specifies the RTC Alarm interrupt to check. |
||
| 573 | * This parameter can be: |
||
| 574 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 575 | * @arg RTC_IT_ALRB: Alarm B interrupt |
||
| 576 | * @retval None |
||
| 577 | */ |
||
| 578 | #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->ISR) & ((__INTERRUPT__) >> 4U)) != 0U) ? 1U : 0U) |
||
| 579 | |||
| 580 | /** |
||
| 581 | * @brief Get the selected RTC Alarm's flag status. |
||
| 582 | * @param __HANDLE__ specifies the RTC handle. |
||
| 583 | * @param __FLAG__ specifies the RTC Alarm Flag to check. |
||
| 584 | * This parameter can be: |
||
| 585 | * @arg RTC_FLAG_ALRAF: Alarm A interrupt flag |
||
| 586 | * @arg RTC_FLAG_ALRAWF: Alarm A 'write allowed' flag |
||
| 587 | * @arg RTC_FLAG_ALRBF: Alarm B interrupt flag |
||
| 588 | * @arg RTC_FLAG_ALRBWF: Alarm B 'write allowed' flag |
||
| 589 | * @retval None |
||
| 590 | */ |
||
| 591 | #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U) ? 1U : 0U) |
||
| 592 | |||
| 593 | /** |
||
| 594 | * @brief Clear the RTC Alarm's pending flags. |
||
| 595 | * @param __HANDLE__ specifies the RTC handle. |
||
| 596 | * @param __FLAG__ specifies the RTC Alarm flag to be cleared. |
||
| 597 | * This parameter can be: |
||
| 598 | * @arg RTC_FLAG_ALRAF |
||
| 599 | * @arg RTC_FLAG_ALRBF |
||
| 600 | * @retval None |
||
| 601 | */ |
||
| 602 | #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT)|((__HANDLE__)->Instance->ISR & RTC_ISR_INIT)) |
||
| 603 | |||
| 604 | /** |
||
| 605 | * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. |
||
| 606 | * @param __HANDLE__ specifies the RTC handle. |
||
| 607 | * @param __INTERRUPT__ specifies the RTC Alarm interrupt sources to check. |
||
| 608 | * This parameter can be: |
||
| 609 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 610 | * @arg RTC_IT_ALRB: Alarm B interrupt |
||
| 611 | * @retval None |
||
| 612 | */ |
||
| 613 | #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U) |
||
| 614 | |||
| 615 | /** |
||
| 616 | * @brief Enable interrupt on the RTC Alarm associated EXTI line. |
||
| 617 | * @retval None |
||
| 618 | */ |
||
| 619 | #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT) |
||
| 620 | |||
| 621 | /** |
||
| 622 | * @brief Disable interrupt on the RTC Alarm associated EXTI line. |
||
| 623 | * @retval None |
||
| 624 | */ |
||
| 625 | #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~RTC_EXTI_LINE_ALARM_EVENT) |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @brief Enable event on the RTC Alarm associated EXTI line. |
||
| 629 | * @retval None. |
||
| 630 | */ |
||
| 631 | #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT) |
||
| 632 | |||
| 633 | /** |
||
| 634 | * @brief Disable event on the RTC Alarm associated EXTI line. |
||
| 635 | * @retval None. |
||
| 636 | */ |
||
| 637 | #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~RTC_EXTI_LINE_ALARM_EVENT) |
||
| 638 | |||
| 639 | /** |
||
| 640 | * @brief Enable falling edge trigger on the RTC Alarm associated EXTI line. |
||
| 641 | * @retval None. |
||
| 642 | */ |
||
| 643 | #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT) |
||
| 644 | |||
| 645 | /** |
||
| 646 | * @brief Disable falling edge trigger on the RTC Alarm associated EXTI line. |
||
| 647 | * @retval None. |
||
| 648 | */ |
||
| 649 | #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~RTC_EXTI_LINE_ALARM_EVENT) |
||
| 650 | |||
| 651 | /** |
||
| 652 | * @brief Enable rising edge trigger on the RTC Alarm associated EXTI line. |
||
| 653 | * @retval None. |
||
| 654 | */ |
||
| 655 | #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT) |
||
| 656 | |||
| 657 | /** |
||
| 658 | * @brief Disable rising edge trigger on the RTC Alarm associated EXTI line. |
||
| 659 | * @retval None. |
||
| 660 | */ |
||
| 661 | #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~RTC_EXTI_LINE_ALARM_EVENT) |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @brief Enable rising & falling edge trigger on the RTC Alarm associated EXTI line. |
||
| 665 | * @retval None. |
||
| 666 | */ |
||
| 667 | #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ |
||
| 668 | __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ |
||
| 669 | __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \ |
||
| 670 | } while(0U) |
||
| 671 | |||
| 672 | /** |
||
| 673 | * @brief Disable rising & falling edge trigger on the RTC Alarm associated EXTI line. |
||
| 674 | * @retval None. |
||
| 675 | */ |
||
| 676 | #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ |
||
| 677 | __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \ |
||
| 678 | __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \ |
||
| 679 | } while(0U) |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @brief Check whether the RTC Alarm associated EXTI line interrupt flag is set or not. |
||
| 683 | * @retval Line Status. |
||
| 684 | */ |
||
| 685 | #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT) |
||
| 686 | |||
| 687 | /** |
||
| 688 | * @brief Clear the RTC Alarm associated EXTI line flag. |
||
| 689 | * @retval None. |
||
| 690 | */ |
||
| 691 | #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT) |
||
| 692 | |||
| 693 | /** |
||
| 694 | * @brief Generate a Software interrupt on RTC Alarm associated EXTI line. |
||
| 695 | * @retval None. |
||
| 696 | */ |
||
| 697 | #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT) |
||
| 698 | /** |
||
| 699 | * @} |
||
| 700 | */ |
||
| 701 | |||
| 702 | /* Include RTC HAL Extended module */ |
||
| 703 | #include "stm32l1xx_hal_rtc_ex.h" |
||
| 704 | |||
| 705 | /* Exported functions --------------------------------------------------------*/ |
||
| 706 | |||
| 707 | /** @addtogroup RTC_Exported_Functions |
||
| 708 | * @{ |
||
| 709 | */ |
||
| 710 | |||
| 711 | /** @addtogroup RTC_Exported_Functions_Group1 |
||
| 712 | * @{ |
||
| 713 | */ |
||
| 714 | /* Initialization and de-initialization functions ****************************/ |
||
| 715 | HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); |
||
| 716 | HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); |
||
| 717 | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); |
||
| 718 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); |
||
| 719 | |||
| 720 | /* Callbacks Register/UnRegister functions ***********************************/ |
||
| 721 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 722 | HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); |
||
| 723 | HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); |
||
| 724 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 725 | /** |
||
| 726 | * @} |
||
| 727 | */ |
||
| 728 | |||
| 729 | /** @addtogroup RTC_Exported_Functions_Group2 |
||
| 730 | * @{ |
||
| 731 | */ |
||
| 732 | /* RTC Time and Date functions ************************************************/ |
||
| 733 | HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); |
||
| 734 | HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); |
||
| 735 | HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); |
||
| 736 | HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); |
||
| 737 | /** |
||
| 738 | * @} |
||
| 739 | */ |
||
| 740 | |||
| 741 | /** @addtogroup RTC_Exported_Functions_Group3 |
||
| 742 | * @{ |
||
| 743 | */ |
||
| 744 | /* RTC Alarm functions ********************************************************/ |
||
| 745 | HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); |
||
| 746 | HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); |
||
| 747 | HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); |
||
| 748 | HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); |
||
| 749 | void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); |
||
| 750 | HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); |
||
| 751 | void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); |
||
| 752 | /** |
||
| 753 | * @} |
||
| 754 | */ |
||
| 755 | |||
| 756 | /** @addtogroup RTC_Exported_Functions_Group4 |
||
| 757 | * @{ |
||
| 758 | */ |
||
| 759 | /* Peripheral Control functions ***********************************************/ |
||
| 760 | HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc); |
||
| 761 | |||
| 762 | /* RTC Daylight Saving Time functions *****************************************/ |
||
| 763 | void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc); |
||
| 764 | void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc); |
||
| 765 | void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc); |
||
| 766 | void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc); |
||
| 767 | uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc); |
||
| 768 | /** |
||
| 769 | * @} |
||
| 770 | */ |
||
| 771 | |||
| 772 | /** @addtogroup RTC_Exported_Functions_Group5 |
||
| 773 | * @{ |
||
| 774 | */ |
||
| 775 | /* Peripheral State functions *************************************************/ |
||
| 776 | HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); |
||
| 777 | /** |
||
| 778 | * @} |
||
| 779 | */ |
||
| 780 | |||
| 781 | /** |
||
| 782 | * @} |
||
| 783 | */ |
||
| 784 | |||
| 785 | /* Private types -------------------------------------------------------------*/ |
||
| 786 | /* Private variables ---------------------------------------------------------*/ |
||
| 787 | /* Private constants ---------------------------------------------------------*/ |
||
| 788 | |||
| 789 | /** @defgroup RTC_Private_Constants RTC Private Constants |
||
| 790 | * @{ |
||
| 791 | */ |
||
| 792 | /* Masks Definition */ |
||
| 793 | #define RTC_TR_RESERVED_MASK ((uint32_t)(RTC_TR_HT | RTC_TR_HU | \ |
||
| 794 | RTC_TR_MNT | RTC_TR_MNU | \ |
||
| 795 | RTC_TR_ST | RTC_TR_SU | \ |
||
| 796 | RTC_TR_PM)) |
||
| 797 | #define RTC_DR_RESERVED_MASK ((uint32_t)(RTC_DR_YT | RTC_DR_YU | \ |
||
| 798 | RTC_DR_MT | RTC_DR_MU | \ |
||
| 799 | RTC_DR_DT | RTC_DR_DU | \ |
||
| 800 | RTC_DR_WDU)) |
||
| 801 | #define RTC_ISR_RESERVED_MASK ((uint32_t)(RTC_FLAGS_MASK | RTC_ISR_INIT)) |
||
| 802 | #define RTC_INIT_MASK 0xFFFFFFFFU |
||
| 803 | #define RTC_RSF_MASK ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF)) |
||
| 804 | #define RTC_FLAGS_MASK ((uint32_t)(RTC_FLAG_INITF | RTC_FLAG_INITS | \ |
||
| 805 | RTC_FLAG_ALRAF | RTC_FLAG_ALRAWF | \ |
||
| 806 | RTC_FLAG_ALRBF | RTC_FLAG_ALRBWF | \ |
||
| 807 | RTC_FLAG_WUTF | RTC_FLAG_WUTWF | \ |
||
| 808 | RTC_FLAG_TSF | RTC_FLAG_TSOVF | \ |
||
| 809 | RTC_FLAG_RSF | RTC_TAMPER_FLAGS_MASK)) |
||
| 810 | |||
| 811 | #define RTC_TIMEOUT_VALUE 1000U |
||
| 812 | |||
| 813 | #define RTC_EXTI_LINE_ALARM_EVENT EXTI_IMR_MR17 /*!< External interrupt line 17 Connected to the RTC Alarm event */ |
||
| 814 | /** |
||
| 815 | * @} |
||
| 816 | */ |
||
| 817 | |||
| 818 | /* Private macros ------------------------------------------------------------*/ |
||
| 819 | |||
| 820 | /** @defgroup RTC_Private_Macros RTC Private Macros |
||
| 821 | * @{ |
||
| 822 | */ |
||
| 823 | |||
| 824 | /** @defgroup RTC_IS_RTC_Definitions RTC Private macros to check input parameters |
||
| 825 | * @{ |
||
| 826 | */ |
||
| 827 | #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HOURFORMAT_12) || \ |
||
| 828 | ((FORMAT) == RTC_HOURFORMAT_24)) |
||
| 829 | |||
| 830 | #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_OUTPUT_DISABLE) || \ |
||
| 831 | ((OUTPUT) == RTC_OUTPUT_ALARMA) || \ |
||
| 832 | ((OUTPUT) == RTC_OUTPUT_ALARMB) || \ |
||
| 833 | ((OUTPUT) == RTC_OUTPUT_WAKEUP)) |
||
| 834 | |||
| 835 | #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \ |
||
| 836 | ((POL) == RTC_OUTPUT_POLARITY_LOW)) |
||
| 837 | |||
| 838 | #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \ |
||
| 839 | ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL)) |
||
| 840 | |||
| 841 | #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FU) |
||
| 842 | #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFFU) |
||
| 843 | |||
| 844 | #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0U) && ((HOUR) <= 12U)) |
||
| 845 | #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U) |
||
| 846 | #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U) |
||
| 847 | #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U) |
||
| 848 | |||
| 849 | #define IS_RTC_HOURFORMAT12(PM) (((PM) == RTC_HOURFORMAT12_AM) || \ |
||
| 850 | ((PM) == RTC_HOURFORMAT12_PM)) |
||
| 851 | |||
| 852 | #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \ |
||
| 853 | ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \ |
||
| 854 | ((SAVE) == RTC_DAYLIGHTSAVING_NONE)) |
||
| 855 | |||
| 856 | #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \ |
||
| 857 | ((OPERATION) == RTC_STOREOPERATION_SET)) |
||
| 858 | |||
| 859 | #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD)) |
||
| 860 | |||
| 861 | #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U) |
||
| 862 | #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U)) |
||
| 863 | #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U)) |
||
| 864 | |||
| 865 | #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ |
||
| 866 | ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ |
||
| 867 | ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ |
||
| 868 | ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ |
||
| 869 | ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ |
||
| 870 | ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ |
||
| 871 | ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) |
||
| 872 | |||
| 873 | #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U)) |
||
| 874 | |||
| 875 | #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \ |
||
| 876 | ((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \ |
||
| 877 | ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \ |
||
| 878 | ((WEEKDAY) == RTC_WEEKDAY_THURSDAY) || \ |
||
| 879 | ((WEEKDAY) == RTC_WEEKDAY_FRIDAY) || \ |
||
| 880 | ((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \ |
||
| 881 | ((WEEKDAY) == RTC_WEEKDAY_SUNDAY)) |
||
| 882 | |||
| 883 | #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \ |
||
| 884 | ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY)) |
||
| 885 | |||
| 886 | #define IS_RTC_ALARM_MASK(MASK) (((MASK) & ((uint32_t)~RTC_ALARMMASK_ALL)) == 0U) |
||
| 887 | |||
| 888 | #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B)) |
||
| 889 | |||
| 890 | #if defined(RTC_SUBSECOND_SUPPORT) |
||
| 891 | #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= RTC_ALRMASSR_SS) |
||
| 892 | |||
| 893 | #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_ALARMSUBSECONDMASK_ALL) || \ |
||
| 894 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_1) || \ |
||
| 895 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_2) || \ |
||
| 896 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_3) || \ |
||
| 897 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_4) || \ |
||
| 898 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_5) || \ |
||
| 899 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_6) || \ |
||
| 900 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_7) || \ |
||
| 901 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_8) || \ |
||
| 902 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_9) || \ |
||
| 903 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_10) || \ |
||
| 904 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_11) || \ |
||
| 905 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_12) || \ |
||
| 906 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14_13) || \ |
||
| 907 | ((MASK) == RTC_ALARMSUBSECONDMASK_SS14) || \ |
||
| 908 | ((MASK) == RTC_ALARMSUBSECONDMASK_NONE)) |
||
| 909 | #endif /* RTC_SUBSECOND_SUPPORT */ |
||
| 910 | /** |
||
| 911 | * @} |
||
| 912 | */ |
||
| 913 | |||
| 914 | /** |
||
| 915 | * @} |
||
| 916 | */ |
||
| 917 | |||
| 918 | /* Private functions ---------------------------------------------------------*/ |
||
| 919 | |||
| 920 | /** @defgroup RTC_Private_Functions RTC Private Functions |
||
| 921 | * @{ |
||
| 922 | */ |
||
| 923 | HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc); |
||
| 924 | HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc); |
||
| 925 | uint8_t RTC_ByteToBcd2(uint8_t number); |
||
| 926 | uint8_t RTC_Bcd2ToByte(uint8_t number); |
||
| 927 | /** |
||
| 928 | * @} |
||
| 929 | */ |
||
| 930 | |||
| 931 | /** |
||
| 932 | * @} |
||
| 933 | */ |
||
| 934 | |||
| 935 | /** |
||
| 936 | * @} |
||
| 937 | */ |
||
| 938 | |||
| 939 | #ifdef __cplusplus |
||
| 940 | } |
||
| 941 | #endif |
||
| 942 | |||
| 943 | #endif /* STM32L1xx_HAL_RTC_H */ |