Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 3 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32f1xx_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 __STM32F1xx_HAL_RTC_H |
||
| 21 | #define __STM32F1xx_HAL_RTC_H |
||
| 22 | |||
| 23 | #ifdef __cplusplus |
||
| 24 | extern "C" { |
||
| 25 | #endif |
||
| 26 | |||
| 27 | /* Includes ------------------------------------------------------------------*/ |
||
| 28 | #include "stm32f1xx_hal_def.h" |
||
| 29 | |||
| 30 | /** @addtogroup STM32F1xx_HAL_Driver |
||
| 31 | * @{ |
||
| 32 | */ |
||
| 33 | |||
| 34 | /** @addtogroup RTC |
||
| 35 | * @{ |
||
| 36 | */ |
||
| 37 | |||
| 38 | /** @addtogroup RTC_Private_Macros |
||
| 39 | * @{ |
||
| 40 | */ |
||
| 41 | |||
| 42 | #define IS_RTC_ASYNCH_PREDIV(PREDIV) (((PREDIV) <= 0xFFFFFU) || ((PREDIV) == RTC_AUTO_1_SECOND)) |
||
| 43 | #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23U) |
||
| 44 | #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59U) |
||
| 45 | #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59U) |
||
| 46 | #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD)) |
||
| 47 | #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99U) |
||
| 48 | #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1U) && ((MONTH) <= 12U)) |
||
| 49 | #define IS_RTC_DATE(DATE) (((DATE) >= 1U) && ((DATE) <= 31U)) |
||
| 50 | #define IS_RTC_ALARM(ALARM) ((ALARM) == RTC_ALARM_A) |
||
| 51 | #define IS_RTC_CALIB_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUTSOURCE_NONE) || \ |
||
| 52 | ((__OUTPUT__) == RTC_OUTPUTSOURCE_CALIBCLOCK) || \ |
||
| 53 | ((__OUTPUT__) == RTC_OUTPUTSOURCE_ALARM) || \ |
||
| 54 | ((__OUTPUT__) == RTC_OUTPUTSOURCE_SECOND)) |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * @} |
||
| 59 | */ |
||
| 60 | |||
| 61 | /** @addtogroup RTC_Private_Constants |
||
| 62 | * @{ |
||
| 63 | */ |
||
| 64 | /** @defgroup RTC_Timeout_Value Default Timeout Value |
||
| 65 | * @{ |
||
| 66 | */ |
||
| 67 | #define RTC_TIMEOUT_VALUE 1000U |
||
| 68 | /** |
||
| 69 | * @} |
||
| 70 | */ |
||
| 71 | |||
| 72 | /** @defgroup RTC_EXTI_Line_Event RTC EXTI Line event |
||
| 73 | * @{ |
||
| 74 | */ |
||
| 75 | #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_MR17) /*!< External interrupt line 17 Connected to the RTC Alarm event */ |
||
| 76 | /** |
||
| 77 | * @} |
||
| 78 | */ |
||
| 79 | |||
| 80 | |||
| 81 | /** |
||
| 82 | * @} |
||
| 83 | */ |
||
| 84 | |||
| 85 | /* Exported types ------------------------------------------------------------*/ |
||
| 86 | /** @defgroup RTC_Exported_Types RTC Exported Types |
||
| 87 | * @{ |
||
| 88 | */ |
||
| 89 | /** |
||
| 90 | * @brief RTC Time structure definition |
||
| 91 | */ |
||
| 92 | typedef struct |
||
| 93 | { |
||
| 94 | uint8_t Hours; /*!< Specifies the RTC Time Hour. |
||
| 95 | This parameter must be a number between Min_Data = 0 and Max_Data = 23 */ |
||
| 96 | |||
| 97 | uint8_t Minutes; /*!< Specifies the RTC Time Minutes. |
||
| 98 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 99 | |||
| 100 | uint8_t Seconds; /*!< Specifies the RTC Time Seconds. |
||
| 101 | This parameter must be a number between Min_Data = 0 and Max_Data = 59 */ |
||
| 102 | |||
| 103 | } RTC_TimeTypeDef; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @brief RTC Alarm structure definition |
||
| 107 | */ |
||
| 108 | typedef struct |
||
| 109 | { |
||
| 110 | RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */ |
||
| 111 | |||
| 112 | uint32_t Alarm; /*!< Specifies the alarm ID (only 1 alarm ID for STM32F1). |
||
| 113 | This parameter can be a value of @ref RTC_Alarms_Definitions */ |
||
| 114 | } RTC_AlarmTypeDef; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @brief HAL State structures definition |
||
| 118 | */ |
||
| 119 | typedef enum |
||
| 120 | { |
||
| 121 | HAL_RTC_STATE_RESET = 0x00U, /*!< RTC not yet initialized or disabled */ |
||
| 122 | HAL_RTC_STATE_READY = 0x01U, /*!< RTC initialized and ready for use */ |
||
| 123 | HAL_RTC_STATE_BUSY = 0x02U, /*!< RTC process is ongoing */ |
||
| 124 | HAL_RTC_STATE_TIMEOUT = 0x03U, /*!< RTC timeout state */ |
||
| 125 | HAL_RTC_STATE_ERROR = 0x04U /*!< RTC error state */ |
||
| 126 | |||
| 127 | } HAL_RTCStateTypeDef; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @brief RTC Configuration Structure definition |
||
| 131 | */ |
||
| 132 | typedef struct |
||
| 133 | { |
||
| 134 | uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. |
||
| 135 | This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFFF or RTC_AUTO_1_SECOND |
||
| 136 | If RTC_AUTO_1_SECOND is selected, AsynchPrediv will be set automatically to get 1sec timebase */ |
||
| 137 | |||
| 138 | uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC Tamper pin. |
||
| 139 | This parameter can be a value of @ref RTC_output_source_to_output_on_the_Tamper_pin */ |
||
| 140 | |||
| 141 | } RTC_InitTypeDef; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @brief RTC Date structure definition |
||
| 145 | */ |
||
| 146 | typedef struct |
||
| 147 | { |
||
| 148 | uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay (not necessary for HAL_RTC_SetDate). |
||
| 149 | This parameter can be a value of @ref RTC_WeekDay_Definitions */ |
||
| 150 | |||
| 151 | uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format). |
||
| 152 | This parameter can be a value of @ref RTC_Month_Date_Definitions */ |
||
| 153 | |||
| 154 | uint8_t Date; /*!< Specifies the RTC Date. |
||
| 155 | This parameter must be a number between Min_Data = 1 and Max_Data = 31 */ |
||
| 156 | |||
| 157 | uint8_t Year; /*!< Specifies the RTC Date Year. |
||
| 158 | This parameter must be a number between Min_Data = 0 and Max_Data = 99 */ |
||
| 159 | |||
| 160 | } RTC_DateTypeDef; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @brief Time Handle Structure definition |
||
| 164 | */ |
||
| 165 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 166 | typedef struct __RTC_HandleTypeDef |
||
| 167 | #else |
||
| 168 | typedef struct |
||
| 169 | #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ |
||
| 170 | { |
||
| 171 | RTC_TypeDef *Instance; /*!< Register base address */ |
||
| 172 | |||
| 173 | RTC_InitTypeDef Init; /*!< RTC required parameters */ |
||
| 174 | |||
| 175 | RTC_DateTypeDef DateToUpdate; /*!< Current date set by user and updated automatically */ |
||
| 176 | |||
| 177 | HAL_LockTypeDef Lock; /*!< RTC locking object */ |
||
| 178 | |||
| 179 | __IO HAL_RTCStateTypeDef State; /*!< Time communication state */ |
||
| 180 | |||
| 181 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 182 | void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Alarm A Event callback */ |
||
| 183 | |||
| 184 | void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Tamper 1 Event callback */ |
||
| 185 | |||
| 186 | void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp Init callback */ |
||
| 187 | |||
| 188 | void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc); /*!< RTC Msp DeInit callback */ |
||
| 189 | |||
| 190 | #endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */ |
||
| 191 | |||
| 192 | } RTC_HandleTypeDef; |
||
| 193 | |||
| 194 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 195 | /** |
||
| 196 | * @brief HAL RTC Callback ID enumeration definition |
||
| 197 | */ |
||
| 198 | typedef enum |
||
| 199 | { |
||
| 200 | HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00u, /*!< RTC Alarm A Event Callback ID */ |
||
| 201 | HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04u, /*!< RTC Tamper 1 Callback ID */ |
||
| 202 | HAL_RTC_MSPINIT_CB_ID = 0x0Eu, /*!< RTC Msp Init callback ID */ |
||
| 203 | HAL_RTC_MSPDEINIT_CB_ID = 0x0Fu /*!< RTC Msp DeInit callback ID */ |
||
| 204 | } HAL_RTC_CallbackIDTypeDef; |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @brief HAL RTC Callback pointer definition |
||
| 208 | */ |
||
| 209 | typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc); /*!< pointer to an RTC callback function */ |
||
| 210 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @} |
||
| 214 | */ |
||
| 215 | |||
| 216 | /* Exported constants --------------------------------------------------------*/ |
||
| 217 | /** @defgroup RTC_Exported_Constants RTC Exported Constants |
||
| 218 | * @{ |
||
| 219 | */ |
||
| 220 | |||
| 221 | /** @defgroup RTC_Automatic_Prediv_1_Second Automatic calculation of prediv for 1sec timebase |
||
| 222 | * @{ |
||
| 223 | */ |
||
| 224 | #define RTC_AUTO_1_SECOND 0xFFFFFFFFU |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @} |
||
| 228 | */ |
||
| 229 | |||
| 230 | /** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format |
||
| 231 | * @{ |
||
| 232 | */ |
||
| 233 | #define RTC_FORMAT_BIN 0x000000000U |
||
| 234 | #define RTC_FORMAT_BCD 0x000000001U |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @} |
||
| 238 | */ |
||
| 239 | |||
| 240 | /** @defgroup RTC_Month_Date_Definitions Month Definitions |
||
| 241 | * @{ |
||
| 242 | */ |
||
| 243 | |||
| 244 | /* Coded in BCD format */ |
||
| 245 | #define RTC_MONTH_JANUARY ((uint8_t)0x01) |
||
| 246 | #define RTC_MONTH_FEBRUARY ((uint8_t)0x02) |
||
| 247 | #define RTC_MONTH_MARCH ((uint8_t)0x03) |
||
| 248 | #define RTC_MONTH_APRIL ((uint8_t)0x04) |
||
| 249 | #define RTC_MONTH_MAY ((uint8_t)0x05) |
||
| 250 | #define RTC_MONTH_JUNE ((uint8_t)0x06) |
||
| 251 | #define RTC_MONTH_JULY ((uint8_t)0x07) |
||
| 252 | #define RTC_MONTH_AUGUST ((uint8_t)0x08) |
||
| 253 | #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09) |
||
| 254 | #define RTC_MONTH_OCTOBER ((uint8_t)0x10) |
||
| 255 | #define RTC_MONTH_NOVEMBER ((uint8_t)0x11) |
||
| 256 | #define RTC_MONTH_DECEMBER ((uint8_t)0x12) |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @} |
||
| 260 | */ |
||
| 261 | |||
| 262 | /** @defgroup RTC_WeekDay_Definitions WeekDay Definitions |
||
| 263 | * @{ |
||
| 264 | */ |
||
| 265 | #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01) |
||
| 266 | #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02) |
||
| 267 | #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03) |
||
| 268 | #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04) |
||
| 269 | #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05) |
||
| 270 | #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06) |
||
| 271 | #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x00) |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @} |
||
| 275 | */ |
||
| 276 | |||
| 277 | /** @defgroup RTC_Alarms_Definitions Alarms Definitions |
||
| 278 | * @{ |
||
| 279 | */ |
||
| 280 | #define RTC_ALARM_A 0U /*!< Specify alarm ID (mainly for legacy purposes) */ |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @} |
||
| 284 | */ |
||
| 285 | |||
| 286 | |||
| 287 | /** @defgroup RTC_output_source_to_output_on_the_Tamper_pin Output source to output on the Tamper pin |
||
| 288 | * @{ |
||
| 289 | */ |
||
| 290 | |||
| 291 | #define RTC_OUTPUTSOURCE_NONE 0x00000000U /*!< No output on the TAMPER pin */ |
||
| 292 | #define RTC_OUTPUTSOURCE_CALIBCLOCK BKP_RTCCR_CCO /*!< RTC clock with a frequency divided by 64 on the TAMPER pin */ |
||
| 293 | #define RTC_OUTPUTSOURCE_ALARM BKP_RTCCR_ASOE /*!< Alarm pulse signal on the TAMPER pin */ |
||
| 294 | #define RTC_OUTPUTSOURCE_SECOND (BKP_RTCCR_ASOS | BKP_RTCCR_ASOE) /*!< Second pulse signal on the TAMPER pin */ |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @} |
||
| 298 | */ |
||
| 299 | |||
| 300 | /** @defgroup RTC_Interrupts_Definitions Interrupts Definitions |
||
| 301 | * @{ |
||
| 302 | */ |
||
| 303 | #define RTC_IT_OW RTC_CRH_OWIE /*!< Overflow interrupt */ |
||
| 304 | #define RTC_IT_ALRA RTC_CRH_ALRIE /*!< Alarm interrupt */ |
||
| 305 | #define RTC_IT_SEC RTC_CRH_SECIE /*!< Second interrupt */ |
||
| 306 | #define RTC_IT_TAMP1 BKP_CSR_TPIE /*!< TAMPER Pin interrupt enable */ |
||
| 307 | /** |
||
| 308 | * @} |
||
| 309 | */ |
||
| 310 | |||
| 311 | /** @defgroup RTC_Flags_Definitions Flags Definitions |
||
| 312 | * @{ |
||
| 313 | */ |
||
| 314 | #define RTC_FLAG_RTOFF RTC_CRL_RTOFF /*!< RTC Operation OFF flag */ |
||
| 315 | #define RTC_FLAG_RSF RTC_CRL_RSF /*!< Registers Synchronized flag */ |
||
| 316 | #define RTC_FLAG_OW RTC_CRL_OWF /*!< Overflow flag */ |
||
| 317 | #define RTC_FLAG_ALRAF RTC_CRL_ALRF /*!< Alarm flag */ |
||
| 318 | #define RTC_FLAG_SEC RTC_CRL_SECF /*!< Second flag */ |
||
| 319 | #define RTC_FLAG_TAMP1F BKP_CSR_TEF /*!< Tamper Interrupt Flag */ |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @} |
||
| 323 | */ |
||
| 324 | |||
| 325 | /** |
||
| 326 | * @} |
||
| 327 | */ |
||
| 328 | |||
| 329 | /* Exported macro ------------------------------------------------------------*/ |
||
| 330 | /** @defgroup RTC_Exported_macros RTC Exported Macros |
||
| 331 | * @{ |
||
| 332 | */ |
||
| 333 | |||
| 334 | /** @brief Reset RTC handle state |
||
| 335 | * @param __HANDLE__: RTC handle. |
||
| 336 | * @retval None |
||
| 337 | */ |
||
| 338 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 339 | #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\ |
||
| 340 | (__HANDLE__)->State = HAL_RTC_STATE_RESET;\ |
||
| 341 | (__HANDLE__)->MspInitCallback = NULL;\ |
||
| 342 | (__HANDLE__)->MspDeInitCallback = NULL;\ |
||
| 343 | }while(0u) |
||
| 344 | #else |
||
| 345 | #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET) |
||
| 346 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @brief Disable the write protection for RTC registers. |
||
| 350 | * @param __HANDLE__: specifies the RTC handle. |
||
| 351 | * @retval None |
||
| 352 | */ |
||
| 353 | #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF) |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @brief Enable the write protection for RTC registers. |
||
| 357 | * @param __HANDLE__: specifies the RTC handle. |
||
| 358 | * @retval None |
||
| 359 | */ |
||
| 360 | #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CRL, RTC_CRL_CNF) |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @brief Enable the RTC Alarm interrupt. |
||
| 364 | * @param __HANDLE__: specifies the RTC handle. |
||
| 365 | * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. |
||
| 366 | * This parameter can be any combination of the following values: |
||
| 367 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 368 | * @retval None |
||
| 369 | */ |
||
| 370 | #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__)) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @brief Disable the RTC Alarm interrupt. |
||
| 374 | * @param __HANDLE__: specifies the RTC handle. |
||
| 375 | * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled. |
||
| 376 | * This parameter can be any combination of the following values: |
||
| 377 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 378 | * @retval None |
||
| 379 | */ |
||
| 380 | #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CRH, (__INTERRUPT__)) |
||
| 381 | |||
| 382 | /** |
||
| 383 | * @brief Check whether the specified RTC Alarm interrupt has been enabled or not. |
||
| 384 | * @param __HANDLE__: specifies the RTC handle. |
||
| 385 | * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be checked |
||
| 386 | * This parameter can be: |
||
| 387 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 388 | * @retval None |
||
| 389 | */ |
||
| 390 | #define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->CRH)& ((__INTERRUPT__)))) != RESET)? SET : RESET) |
||
| 391 | |||
| 392 | /** |
||
| 393 | * @brief Get the selected RTC Alarm's flag status. |
||
| 394 | * @param __HANDLE__: specifies the RTC handle. |
||
| 395 | * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. |
||
| 396 | * This parameter can be: |
||
| 397 | * @arg RTC_FLAG_ALRAF |
||
| 398 | * @retval None |
||
| 399 | */ |
||
| 400 | #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->CRL) & (__FLAG__)) != RESET)? SET : RESET) |
||
| 401 | |||
| 402 | /** |
||
| 403 | * @brief Check whether the specified RTC Alarm interrupt has occurred or not. |
||
| 404 | * @param __HANDLE__: specifies the RTC handle. |
||
| 405 | * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check. |
||
| 406 | * This parameter can be: |
||
| 407 | * @arg RTC_IT_ALRA: Alarm A interrupt |
||
| 408 | * @retval None |
||
| 409 | */ |
||
| 410 | #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) (((((__HANDLE__)->Instance->CRL) & (__INTERRUPT__)) != RESET)? SET : RESET) |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @brief Clear the RTC Alarm's pending flags. |
||
| 414 | * @param __HANDLE__: specifies the RTC handle. |
||
| 415 | * @param __FLAG__: specifies the RTC Alarm Flag sources to be enabled or disabled. |
||
| 416 | * This parameter can be: |
||
| 417 | * @arg RTC_FLAG_ALRAF |
||
| 418 | * @retval None |
||
| 419 | */ |
||
| 420 | #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CRL) &= ~(__FLAG__) |
||
| 421 | |||
| 422 | /** |
||
| 423 | * @brief Enable interrupt on ALARM Exti Line 17. |
||
| 424 | * @retval None. |
||
| 425 | */ |
||
| 426 | #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 427 | |||
| 428 | /** |
||
| 429 | * @brief Disable interrupt on ALARM Exti Line 17. |
||
| 430 | * @retval None. |
||
| 431 | */ |
||
| 432 | #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @brief Enable event on ALARM Exti Line 17. |
||
| 436 | * @retval None. |
||
| 437 | */ |
||
| 438 | #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 439 | |||
| 440 | /** |
||
| 441 | * @brief Disable event on ALARM Exti Line 17. |
||
| 442 | * @retval None. |
||
| 443 | */ |
||
| 444 | #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 445 | |||
| 446 | |||
| 447 | /** |
||
| 448 | * @brief ALARM EXTI line configuration: set falling edge trigger. |
||
| 449 | * @retval None. |
||
| 450 | */ |
||
| 451 | #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 452 | |||
| 453 | |||
| 454 | /** |
||
| 455 | * @brief Disable the ALARM Extended Interrupt Falling Trigger. |
||
| 456 | * @retval None. |
||
| 457 | */ |
||
| 458 | #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 459 | |||
| 460 | |||
| 461 | /** |
||
| 462 | * @brief ALARM EXTI line configuration: set rising edge trigger. |
||
| 463 | * @retval None. |
||
| 464 | */ |
||
| 465 | #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @brief Disable the ALARM Extended Interrupt Rising Trigger. |
||
| 469 | * This parameter can be: |
||
| 470 | * @retval None. |
||
| 471 | */ |
||
| 472 | #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 473 | |||
| 474 | /** |
||
| 475 | * @brief ALARM EXTI line configuration: set rising & falling edge trigger. |
||
| 476 | * @retval None. |
||
| 477 | */ |
||
| 478 | #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() \ |
||
| 479 | do{ \ |
||
| 480 | __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE(); \ |
||
| 481 | __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \ |
||
| 482 | } while(0U) |
||
| 483 | |||
| 484 | /** |
||
| 485 | * @brief Disable the ALARM Extended Interrupt Rising & Falling Trigger. |
||
| 486 | * This parameter can be: |
||
| 487 | * @retval None. |
||
| 488 | */ |
||
| 489 | #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() \ |
||
| 490 | do{ \ |
||
| 491 | __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE(); \ |
||
| 492 | __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \ |
||
| 493 | } while(0U) |
||
| 494 | |||
| 495 | /** |
||
| 496 | * @brief Check whether the specified ALARM EXTI interrupt flag is set or not. |
||
| 497 | * @retval EXTI ALARM Line Status. |
||
| 498 | */ |
||
| 499 | #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & (RTC_EXTI_LINE_ALARM_EVENT)) |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @brief Clear the ALARM EXTI flag. |
||
| 503 | * @retval None. |
||
| 504 | */ |
||
| 505 | #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = (RTC_EXTI_LINE_ALARM_EVENT)) |
||
| 506 | |||
| 507 | /** |
||
| 508 | * @brief Generate a Software interrupt on selected EXTI line. |
||
| 509 | * @retval None. |
||
| 510 | */ |
||
| 511 | #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, RTC_EXTI_LINE_ALARM_EVENT) |
||
| 512 | /** |
||
| 513 | * @} |
||
| 514 | */ |
||
| 515 | |||
| 516 | /* Include RTC HAL Extension module */ |
||
| 517 | #include "stm32f1xx_hal_rtc_ex.h" |
||
| 518 | |||
| 519 | /* Exported functions --------------------------------------------------------*/ |
||
| 520 | /** @addtogroup RTC_Exported_Functions |
||
| 521 | * @{ |
||
| 522 | */ |
||
| 523 | |||
| 524 | |||
| 525 | /* Initialization and de-initialization functions ****************************/ |
||
| 526 | /** @addtogroup RTC_Exported_Functions_Group1 |
||
| 527 | * @{ |
||
| 528 | */ |
||
| 529 | HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc); |
||
| 530 | HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc); |
||
| 531 | void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc); |
||
| 532 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc); |
||
| 533 | |||
| 534 | /* Callbacks Register/UnRegister functions ***********************************/ |
||
| 535 | #if (USE_HAL_RTC_REGISTER_CALLBACKS == 1) |
||
| 536 | HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback); |
||
| 537 | HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID); |
||
| 538 | #endif /* USE_HAL_RTC_REGISTER_CALLBACKS */ |
||
| 539 | /** |
||
| 540 | * @} |
||
| 541 | */ |
||
| 542 | |||
| 543 | /* RTC Time and Date functions ************************************************/ |
||
| 544 | /** @addtogroup RTC_Exported_Functions_Group2 |
||
| 545 | * @{ |
||
| 546 | */ |
||
| 547 | HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); |
||
| 548 | HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format); |
||
| 549 | HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); |
||
| 550 | HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format); |
||
| 551 | /** |
||
| 552 | * @} |
||
| 553 | */ |
||
| 554 | |||
| 555 | /* RTC Alarm functions ********************************************************/ |
||
| 556 | /** @addtogroup RTC_Exported_Functions_Group3 |
||
| 557 | * @{ |
||
| 558 | */ |
||
| 559 | HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); |
||
| 560 | HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format); |
||
| 561 | HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm); |
||
| 562 | HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format); |
||
| 563 | void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc); |
||
| 564 | HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout); |
||
| 565 | void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc); |
||
| 566 | /** |
||
| 567 | * @} |
||
| 568 | */ |
||
| 569 | |||
| 570 | /* Peripheral State functions *************************************************/ |
||
| 571 | /** @addtogroup RTC_Exported_Functions_Group4 |
||
| 572 | * @{ |
||
| 573 | */ |
||
| 574 | HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc); |
||
| 575 | /** |
||
| 576 | * @} |
||
| 577 | */ |
||
| 578 | |||
| 579 | /* Peripheral Control functions ***********************************************/ |
||
| 580 | /** @addtogroup RTC_Exported_Functions_Group5 |
||
| 581 | * @{ |
||
| 582 | */ |
||
| 583 | HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc); |
||
| 584 | /** |
||
| 585 | * @} |
||
| 586 | */ |
||
| 587 | |||
| 588 | /** |
||
| 589 | * @} |
||
| 590 | */ |
||
| 591 | |||
| 592 | /** |
||
| 593 | * @} |
||
| 594 | */ |
||
| 595 | |||
| 596 | /** |
||
| 597 | * @} |
||
| 598 | */ |
||
| 599 | |||
| 600 | #ifdef __cplusplus |
||
| 601 | } |
||
| 602 | #endif |
||
| 603 | |||
| 604 | #endif /* __STM32F1xx_HAL_RTC_H */ |