1 /* 2 ****************************************************************************** 3 * @file HAL_RTC.h 4 * @version V1.0.0 5 * @date 2020 6 * @brief Header file of RTC HAL module. 7 ****************************************************************************** 8 */ 9 10 #ifndef __HAL_RTC_H__ 11 #define __HAL_RTC_H__ 12 13 #include "ACM32Fxx_HAL.h" 14 15 /************************************************************************************/ 16 /* Registers Bits Definition */ 17 /************************************************************************************/ 18 19 /**************** Bit definition for RTC IE Register ***********************/ 20 #define RTC_IE_STP2RIE (BIT16) 21 #define RTC_IE_STP2FIE (BIT15) 22 #define RTC_IE_STP1RIE (BIT14) 23 #define RTC_IE_STP1FIE (BIT13) 24 #define RTC_IE_ADJ32 (BIT12) 25 #define RTC_IE_ALM (BIT11) 26 #define RTC_IE_1KHZ (BIT10) 27 #define RTC_IE_256HZ (BIT9) 28 #define RTC_IE_64HZ (BIT8) 29 #define RTC_IE_16HZ (BIT7) 30 #define RTC_IE_8HZ (BIT6) 31 #define RTC_IE_4HZ (BIT5) 32 #define RTC_IE_2HZ (BIT4) 33 #define RTC_IE_SEC (BIT3) 34 #define RTC_IE_MIN (BIT2) 35 #define RTC_IE_HOUR (BIT1) 36 #define RTC_IE_DATE (BIT0) 37 38 /**************** Bit definition for RTC SR Register ***********************/ 39 #define RTC_SR_STP2RIE (BIT16) 40 #define RTC_SR_STP2FIE (BIT15) 41 #define RTC_SR_STP1RIE (BIT14) 42 #define RTC_SR_STP1FIE (BIT13) 43 #define RTC_SR_ADJ32 (BIT12) 44 #define RTC_SR_ALM (BIT11) 45 #define RTC_SR_1KHZ (BIT10) 46 #define RTC_SR_256HZ (BIT9) 47 #define RTC_SR_64HZ (BIT8) 48 #define RTC_SR_16HZ (BIT7) 49 #define RTC_SR_8HZ (BIT6) 50 #define RTC_SR_4HZ (BIT5) 51 #define RTC_SR_2HZ (BIT4) 52 #define RTC_SR_SEC (BIT3) 53 #define RTC_SR_MIN (BIT2) 54 #define RTC_SR_HOUR (BIT1) 55 #define RTC_SR_DATE (BIT0) 56 57 /**************** Bit definition for RTC CR Register ***********************/ 58 #define RTC_CR_TAMPFLTCLK (BIT22) 59 #define RTC_CR_TS2EDGE (BIT21) 60 #define RTC_CR_TAMP2FLT (BIT19|BIT20) 61 #define RTC_CR_TAMP2FLTEN (BIT18) 62 #define RTC_CR_TAMP2FCLR (BIT17) 63 #define RTC_CR_TAMP2RCLR (BIT16) 64 #define RTC_CR_TS1EDGE (BIT15) 65 #define RTC_CR_TAMP1FLT (BIT13|BIT14) 66 #define RTC_CR_TAMP1FLTEN (BIT12) 67 #define RTC_CR_ALM_MKSD (BIT11) 68 #define RTC_CR_ALM_MSKH (BIT10) 69 #define RTC_CR_ALM_MSKM (BIT9) 70 #define RTC_CR_TAMP1FCLR (BIT8) 71 #define RTC_CR_TAMP1RCLR (BIT7) 72 #define RTC_CR_TAMP2EN (BIT6) 73 #define RTC_CR_TAMP1EN (BIT5) 74 #define RTC_CR_ALM_EN (BIT4) 75 #define RTC_CR_FSEL (BIT0|BIT1|BIT2|BIT3) 76 77 /**************** Bit definition for RTC_PMU CR Register ***********************/ 78 #define RPMU_CR_WU6FILEN BIT29 79 #define RPMU_CR_WU5FILEN BIT28 80 #define RPMU_CR_WU4FILEN BIT27 81 #define RPMU_CR_WU3FILEN BIT26 82 #define RPMU_CR_WU2FILEN BIT25 83 #define RPMU_CR_WU1FILEN BIT24 84 #define RPMU_CR_EWUP6 BIT21 85 #define RPMU_CR_EWUP5 BIT20 86 #define RPMU_CR_EWUP4 BIT19 87 #define RPMU_CR_EWUP3 BIT18 88 #define RPMU_CR_EWUP2 BIT17 89 #define RPMU_CR_EWUP1 BIT16 90 #define RPMU_CR_BORRST_EN BIT12 91 #define RPMU_CR_WK_TIME (BIT9|BIT10|BIT11) 92 #define RPMU_CR_STB_EN BIT8 93 #define RPMU_CR_BDRST BIT6 94 #define RPMU_CR_RTCEN BIT5 95 #define RPMU_CR_RTCSEL (BIT2|BIT3) 96 #define RPMU_CR_CWUF BIT1 97 #define RPMU_CR_CSBF BIT0 98 99 /**************** Bit definition for RTC_PMU ANACR Register ***********************/ 100 #define RPMU_SR_BORWUF BIT13 101 #define RPMU_SR_IWDTWUF BIT12 102 #define RPMU_SR_RSTWUF BIT11 103 #define RPMU_SR_RTCWUF BIT10 104 #define RPMU_SR_WUP6F BIT6 105 #define RPMU_SR_WUP5F BIT5 106 #define RPMU_SR_WUP4F BIT4 107 #define RPMU_SR_WUP3F BIT3 108 #define RPMU_SR_WUP2F BIT2 109 #define RPMU_SR_WUP1F BIT1 110 #define RPMU_SR_SBF BIT0 111 112 /**************** Bit definition for RTC_PMU ANACR Register ***********************/ 113 #define RPMU_ANACR_BOR_CFG (BIT24|BIT25) 114 #define RPMU_ANACR_BOR_EN BIT23 115 #define RPMU_ANACR_LPBGR_TRIM (BIT20|BIT21|BIT22) 116 #define RPMU_ANACR_RC32K_TRIM (BIT10|BIT11|BIT12|BIT13|BIT14|BIT15) 117 #define RPMU_ANACR_RC32K_RDY BIT9 118 #define RPMU_ANACR_RC32K_EN BIT8 119 #define RPMU_ANACR_XTLDRV_2 BIT5 120 #define RPMU_ANACR_XTLDRV_1 BIT4 121 #define RPMU_ANACR_XTLDRV_0 BIT3 122 #define RPMU_ANACR_XTLDRV (BIT3|BIT4|BIT5) 123 #define RPMU_ANACR_XTLBYO BIT2 124 #define RPMU_ANACR_XTLRDY BIT1 125 #define RPMU_ANACR_XTLEN BIT0 126 127 128 /** @defgroup ClockSource 129 * @{ 130 */ 131 #define RTC_CLOCK_RC32K (0x00000000) 132 #define RTC_CLOCK_XTL (0x00000004) 133 /** 134 * @} 135 */ 136 137 138 /** @defgroup Clock_Compensation 139 * @{ 140 */ 141 #define COMPENSATION_INCREASE (0x00000000) 142 #define COMPENSATION_DECREASE (0x00000400) 143 /** 144 * @} 145 */ 146 147 148 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions 149 * @{ 150 */ 151 152 /* Coded in BCD format */ 153 #define RTC_MONTH_JANUARY (0x01) 154 #define RTC_MONTH_FEBRUARY (0x02) 155 #define RTC_MONTH_MARCH (0x03) 156 #define RTC_MONTH_APRIL (0x04) 157 #define RTC_MONTH_MAY (0x05) 158 #define RTC_MONTH_JUNE (0x06) 159 #define RTC_MONTH_JULY (0x07) 160 #define RTC_MONTH_AUGUST (0x08) 161 #define RTC_MONTH_SEPTEMBER (0x09) 162 #define RTC_MONTH_OCTOBER (0x10) 163 #define RTC_MONTH_NOVEMBER (0x11) 164 #define RTC_MONTH_DECEMBER (0x12) 165 /** 166 * @} 167 */ 168 169 170 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions 171 * @{ 172 */ 173 #define RTC_WEEKDAY_MONDAY (0x01) 174 #define RTC_WEEKDAY_TUESDAY (0x02) 175 #define RTC_WEEKDAY_WEDNESDAY (0x03) 176 #define RTC_WEEKDAY_THURSDAY (0x04) 177 #define RTC_WEEKDAY_FRIDAY (0x05) 178 #define RTC_WEEKDAY_SATURDAY (0x06) 179 #define RTC_WEEKDAY_SUNDAY (0x07) 180 /** 181 * @} 182 */ 183 184 185 /** @defgroup RTC_Alarm_Mode Definitions 186 * @{ 187 */ 188 #define RTC_ALARM_WEEK_MODE (0x00000000) 189 #define RTC_ALARM_DAY_MODE (0x80000000) 190 /** 191 * @} 192 */ 193 194 195 /** @defgroup RTC_AlarmInterrupt Definitions 196 * @{ 197 */ 198 #define RTC_ALARM_INT_ENABLE (0x00000000) 199 #define RTC_ALARM_INT_DISABLE (0x00000001) 200 /** 201 * @} 202 */ 203 204 205 /** @defgroup RTC_DayMask Definitions 206 * @{ 207 */ 208 #define RTC_ALARM_DAY_MASK_ENABLE RTC_CR_ALM_MKSD 209 #define RTC_ALARM_DAY_MASK_DISABLE (0x00000000) 210 /** 211 * @} 212 */ 213 214 215 /** @defgroup RTC_HourMask Definitions 216 * @{ 217 */ 218 #define RTC_ALARM_HOUR_MASK_ENABLE RTC_CR_ALM_MSKH 219 #define RTC_ALARM_HOUR_MASK_DISABLE (0x00000000) 220 /** 221 * @} 222 */ 223 224 225 /** @defgroup RTC_MinMask Definitions 226 * @{ 227 */ 228 #define RTC_ALARM_MIN_MASK_ENABLE RTC_CR_ALM_MSKM 229 #define RTC_ALARM_MIN_MASK_DISABLE (0x00000000) 230 /** 231 * @} 232 */ 233 234 235 /** @defgroup RTC_Alarm_WeekSelect Definitions 236 * @{ 237 */ 238 #define RTC_ALARM_WEEK_SUNDAY (0x01000000) 239 #define RTC_ALARM_WEEK_MONDAY (0x02000000) 240 #define RTC_ALARM_WEEK_TUESDAY (0x04000000) 241 #define RTC_ALARM_WEEK_WEDNESDAY (0x08000000) 242 #define RTC_ALARM_WEEK_THURSDAY (0x10000000) 243 #define RTC_ALARM_WEEK_FRIDAY (0x20000000) 244 #define RTC_ALARM_WEEK_SATURDAY (0x40000000) 245 /** 246 * @} 247 */ 248 249 250 /** @defgroup RTC_Temper_edge Definitions 251 * @{ 252 */ 253 #define RTC_TEMP_EDGE_RISING (0x00000000) 254 #define RTC_TEMP_EDGE_FALLING (0x00000001) 255 /** 256 * @} 257 */ 258 259 260 /** @defgroup RTC_TemperInterrupt Definitions 261 * @{ 262 */ 263 #define RTC_TEMP_INT_DISABLE (0x00000000) 264 #define RTC_TEMP_INT_ENABLE (0x00000001) 265 /** 266 * @} 267 */ 268 269 270 /** @defgroup RTC_ClearBackup Definitions 271 * @{ 272 */ 273 #define RTC_TEMP_CLEAR_DISABLE (0x00000000) 274 #define RTC_TEMP_CLEAR_ENABLE (0x00000001) 275 /** 276 * @} 277 */ 278 279 280 /** @defgroup RTC_TemperFilter Definitions 281 * @{ 282 */ 283 #define RTC_TEMP_FILTER_DISABLE (0x00000000) 284 #define RTC_TEMP_FILTER_512_RTCCLK (0x00000001) 285 #define RTC_TEMP_FILTER_1_RTCCLK (0x00000002) 286 #define RTC_TEMP_FILTER_2_RTCCLK (0x00000003) 287 #define RTC_TEMP_FILTER_4_RTCCLK (0x00000004) 288 #define RTC_TEMP_FILTER_8_RTCCLK (0x00000005) 289 /** 290 * @} 291 */ 292 293 294 /** 295 * @brief RTC Temper index definition 296 */ 297 typedef enum 298 { 299 RTC_TEMPER_1, 300 RTC_TEMPER_2, 301 }enum_Temper_t; 302 /** 303 * @} 304 */ 305 306 307 /** 308 * @brief RTC wakeup source form standby 309 */ 310 typedef enum 311 { 312 RTC_WAKEUP_RTC_INT = 0, 313 RTC_WAKEUP_WKUP1 = 0x00010000, // PA0 314 RTC_WAKEUP_WKUP2 = 0x00020000, // PC13 315 RTC_WAKEUP_WKUP3 = 0x00040000, // PA2 316 RTC_WAKEUP_WKUP4 = 0x00080000, // PC5 317 RTC_WAKEUP_WKUP5 = 0x00100000, // PB5 318 RTC_WAKEUP_WKUP6 = 0x00200000, // PB15 319 RTC_WAKEUP_STAMP2 = (RTC_IE_STP2RIE | RTC_IE_STP2FIE), 320 RTC_WAKEUP_STAMP1 = (RTC_IE_STP1RIE | RTC_IE_STP1FIE), 321 RTC_WAKEUP_32S = RTC_IE_ADJ32, 322 RTC_WAKEUP_ALARM = RTC_IE_ALM, 323 RTC_WAKEUP_SEC = RTC_IE_SEC, 324 RTC_WAKEUP_MIN = RTC_IE_MIN, 325 RTC_WAKEUP_HOUR = RTC_IE_HOUR, 326 RTC_WAKEUP_DATE = RTC_IE_DATE, 327 }enum_WKUP_t; 328 329 #define STANDBY_WAKEUP_RISING 0 330 #define STANDBY_WAKEUP_FALLING 1 331 332 /** 333 * @} 334 */ 335 336 /** 337 * @brief Check RTC wakeup source form standby 338 */ 339 #define RTC_WAKEUP_SOURCE_BORWUF (0x00002000) 340 #define RTC_WAKEUP_SOURCE_IWDTWUF (0x00001000) 341 #define RTC_WAKEUP_SOURCE_RSTWUF (0x00000800) 342 #define RTC_WAKEUP_SOURCE_RTCWUF (0x00000400) 343 #define RTC_WAKEUP_SOURCE_WKUP6 (0x00000040) 344 #define RTC_WAKEUP_SOURCE_WKUP5 (0x00000020) 345 #define RTC_WAKEUP_SOURCE_WKUP4 (0x00000010) 346 #define RTC_WAKEUP_SOURCE_WKUP3 (0x00000008) 347 #define RTC_WAKEUP_SOURCE_WKUP2 (0x00000004) 348 #define RTC_WAKEUP_SOURCE_WKUP1 (0x00000002) 349 /** 350 * @} 351 */ 352 353 /** 354 * @brief RTC Configuration Structure definition 355 */ 356 typedef struct 357 { 358 uint32_t u32_ClockSource; /*!< The RTC Clock Source to be configured. 359 This parameter can be a value of @ref ClockSource */ 360 361 uint32_t u32_Compensation; /*!< The RTC Clock Compensation to be configured. 362 This parameter can be a value of @ref Clock_Compensation */ 363 364 uint32_t u32_CompensationValue; /*!< The RTC Clock Compensation Value to be configured. 365 This parameter must be a number between Min_Data = 0x000 and Max_Data = 0x1FF */ 366 }RTC_ConfigTypeDef; 367 368 369 /** 370 * @brief RTC Date structure definition 371 */ 372 typedef struct 373 { 374 uint8_t u8_Year; /*!< Specifies the RTC Date Year. 375 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x99 */ 376 377 uint8_t u8_Month; /*!< Specifies the RTC Date Month (in BCD format). 378 This parameter can be a value of @ref RTC_Month_Date_Definitions */ 379 380 uint8_t u8_Date; /*!< Specifies the RTC Date. 381 This parameter must be a number between Min_Data = 0x01 and Max_Data = 0x31 */ 382 383 uint8_t u8_WeekDay; /*!< Specifies the RTC Date WeekDay. 384 This parameter can be a value of @ref RTC_WeekDay_Definitions */ 385 }RTC_DateTypeDef; 386 /* Attention: Year、Month、Date、Week use BCD code */ 387 388 389 /** 390 * @brief RTC Time structure definition 391 */ 392 typedef struct 393 { 394 uint8_t u8_Hours; /*!< Specifies the RTC Time Hour. 395 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x23 */ 396 397 uint8_t u8_Minutes; /*!< Specifies the RTC Time Minutes. 398 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 399 400 uint8_t u8_Seconds; /*!< Specifies the RTC Time Seconds. 401 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 402 }RTC_TimeTypeDef; 403 /* Attention: Hour、Minute、Second use BCD code */ 404 405 406 /** 407 * @brief RTC Time structure definition 408 */ 409 typedef struct 410 { 411 uint32_t u32_AlarmMode; /*!< Specifies the RTC alarm Mode. 412 This parameter can be a value of @ref RTC_Alarm_Mode */ 413 414 uint32_t u32_AlarmInterrupt; /*!< Specifies the RTC alarm interrupt Enable or Disable. 415 This parameter can be a value of @ref RTC_AlarmInterrupt */ 416 417 uint32_t u32_DayMask; /*!< Specifies the RTC alarm Day/Week Mask. 418 This parameter can be a value of @ref RTC_DayMask */ 419 420 uint32_t u32_HourMask; /*!< Specifies the RTC alarm Hour Mask. 421 This parameter can be a value of @ref RTC_HourMask */ 422 423 uint32_t u32_MinMask; /*!< Specifies the RTC alarm Min Mask. 424 This parameter can be a value of @ref RTC_MinMask */ 425 426 uint32_t u32_AlarmWeek; /*!< Specifies the RTC alarm week select(Select WeekMode this parameter is valid). 427 This parameter can be a value of @ref RTC_Alarm_WeekSelect */ 428 429 uint32_t u32_AlarmDay; /*!< Specifies the RTC alarm day select(Select DayMode this parameter is valid). 430 This parameter must be a number between Min_Data = 0x01 and Max_Data = 0x31 */ 431 432 uint32_t u32_Hours; /*!< Specifies the RTC alarm Hour. 433 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x23 */ 434 435 uint32_t u32_Minutes; /*!< Specifies the RTC alarm Minutes. 436 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 437 438 uint32_t u32_Seconds; /*!< Specifies the RTC alarm Seconds. 439 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 440 }RTC_AlarmTypeDef; 441 442 443 /** 444 * @brief RTC Temper structure definition 445 */ 446 typedef struct 447 { 448 uint32_t u32_TemperEdge; /*!< Specifies the RTC Temper edge select. 449 This parameter can be a value of @ref RTC_Temper_edge */ 450 451 uint32_t u32_InterruptEN; /*!< Specifies the RTC Temper interrupt enable. 452 This parameter can be a value of @ref RTC_TemperInterrupt */ 453 454 uint32_t u32_ClearBackup; /*!< Specifies the RTC Temper clear backup register. 455 This parameter can be a value of @ref RTC_ClearBackup */ 456 457 uint32_t u32_Filter; /*!< Specifies the RTC Temper Filter select. 458 This parameter can be a value of @ref RTC_TemperFilter */ 459 }RTC_TemperTypeDef; 460 461 462 /** @brief PC13 function select 463 * @param __FUNC__: PC13 function select. 464 * This parameter can be 0: GPIO,1:RTC Fout,2:RTC tamper 3:PC13 Value 465 */ 466 #define __HAL_RTC_PC13_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3)) | (__FUNC__)) 467 468 /** @brief PC14 function select 469 * @param __FUNC__: PC14 function select. 470 * This parameter can be 0: GPIO,1:PC14 Value 471 */ 472 #define __HAL_RTC_PC14_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3 << 3)) | (__FUNC__ << 3)) 473 474 /** @brief PC15 function select 475 * @param __FUNC__: PC15 function select. 476 * This parameter can be 0: GPIO,1:PC15 Value 477 */ 478 #define __HAL_RTC_PC15_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3 << 5)) | (__FUNC__ << 5)) 479 480 /** @brief PC13 Value set 481 * @param __FUNC__: PC13 Value set. 482 * This parameter can be 0: set,1:claer 483 */ 484 #define __HAL_RTC_PC13_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 8)) | (__VALUE__ << 8)) 485 486 /** @brief PC14 Value set 487 * @param __FUNC__: PC14 Value set. 488 * This parameter can be 0: set,1:claer 489 */ 490 #define __HAL_RTC_PC14_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 9)) | (__VALUE__ << 9)) 491 492 /** @brief PC15 Value set 493 * @param __FUNC__: PC15 Value set. 494 * This parameter can be 0: set,1:claer 495 */ 496 #define __HAL_RTC_PC15_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 10)) | (__VALUE__ << 10)) 497 498 /* @brief PC13、PC14、PC15 pull up or pull down */ 499 #define __HAL_RTC_PC13_PULL_UP_ENABLE() (PMU->IOCR |= BIT0) 500 #define __HAL_RTC_PC13_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT0) 501 #define __HAL_RTC_PC13_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT1) 502 #define __HAL_RTC_PC13_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT1) 503 504 #define __HAL_RTC_PC14_PULL_UP_ENABLE() (PMU->IOCR |= BIT8) 505 #define __HAL_RTC_PC14_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT8) 506 #define __HAL_RTC_PC14_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT9) 507 #define __HAL_RTC_PC14_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT9) 508 509 #define __HAL_RTC_PC15_PULL_UP_ENABLE() (PMU->IOCR |= BIT16) 510 #define __HAL_RTC_PC15_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT16) 511 #define __HAL_RTC_PC15_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT17) 512 #define __HAL_RTC_PC15_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT17) 513 514 /* @brief PC13、PC14、PC15 digit or analog */ 515 #define __HAL_RTC_PC13_ANALOG() (PMU->IOCR |= BIT6) 516 #define __HAL_RTC_PC13_DIGIT() (PMU->IOCR &= ~BIT6) 517 518 #define __HAL_RTC_PC14_ANALOG() (PMU->IOCR |= BIT14) 519 #define __HAL_RTC_PC14_DIGIT() (PMU->IOCR &= ~BIT14) 520 521 #define __HAL_RTC_PC15_ANALOG() (PMU->IOCR |= BIT22) 522 #define __HAL_RTC_PC15_DIGIT() (PMU->IOCR &= ~BIT22) 523 524 525 /** @defgroup RTC Private Macros 526 * @{ 527 */ 528 #define IS_RTC_CLOCKSRC(__CLOCKSRC__) (((__CLOCKSRC__) == RTC_CLOCK_RC32K) || \ 529 ((__CLOCKSRC__) == RTC_CLOCK_XTL)) 530 531 #define IS_RTC_COMPENSATION(__COMPENSATION__) (((__COMPENSATION__) == COMPENSATION_INCREASE) || \ 532 ((__COMPENSATION__) == COMPENSATION_DECREASE)) 533 534 #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) <= 0x99) 535 536 #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) == RTC_MONTH_JANUARY) || \ 537 ((__MONTH__) == RTC_MONTH_FEBRUARY) || \ 538 ((__MONTH__) == RTC_MONTH_MARCH) || \ 539 ((__MONTH__) == RTC_MONTH_APRIL) || \ 540 ((__MONTH__) == RTC_MONTH_MAY) || \ 541 ((__MONTH__) == RTC_MONTH_JUNE) || \ 542 ((__MONTH__) == RTC_MONTH_JULY) || \ 543 ((__MONTH__) == RTC_MONTH_AUGUST) || \ 544 ((__MONTH__) == RTC_MONTH_SEPTEMBER) || \ 545 ((__MONTH__) == RTC_MONTH_OCTOBER) || \ 546 ((__MONTH__) == RTC_MONTH_NOVEMBER) || \ 547 ((__MONTH__) == RTC_MONTH_DECEMBER)) 548 549 #define IS_RTC_DAY(__DAY__) ((__DAY__) >= 0x01 && (__DAY__) <= 0x31) 550 551 #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \ 552 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \ 553 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \ 554 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \ 555 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \ 556 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \ 557 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY)) 558 559 #define IS_RTC_HOUR(__HOUR__) ((__HOUR__) <= 0x23) 560 561 #define IS_RTC_MIN(__MIN__) ((__MIN__) <= 0x59) 562 563 #define IS_RTC_SEC(__SEC__) ((__SEC__) <= 0x60) 564 565 566 #define IS_RTC_ALARM_MODE(__MODE__) (((__MODE__) == RTC_ALARM_WEEK_MODE) || \ 567 ((__MODE__) == RTC_ALARM_DAY_MODE)) 568 569 #define IS_RTC_ALARM_INT(__INT__) (((__INT__) == RTC_ALARM_INT_ENABLE) || \ 570 ((__INT__) == RTC_ALARM_INT_DISABLE)) 571 572 #define IS_RTC_ALARM_DAY_MASK(__MASKD__) (((__MASKD__) == RTC_ALARM_DAY_MASK_ENABLE) || \ 573 ((__MASKD__) == RTC_ALARM_DAY_MASK_DISABLE)) 574 575 #define IS_RTC_ALARM_HOUR_MASK(__MASKH__) (((__MASKH__) == RTC_ALARM_HOUR_MASK_ENABLE) || \ 576 ((__MASKH__) == RTC_ALARM_HOUR_MASK_DISABLE)) 577 578 #define IS_RTC_ALARM_MIN_MASK(__MASKM__) (((__MASKM__) == RTC_ALARM_MIN_MASK_ENABLE) || \ 579 ((__MASKM__) == RTC_ALARM_MIN_MASK_DISABLE)) 580 581 #define IS_RTC_ALARM_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_ALARM_WEEK_SUNDAY) || \ 582 ((__WEEKDAY__) == RTC_ALARM_WEEK_MONDAY) || \ 583 ((__WEEKDAY__) == RTC_ALARM_WEEK_TUESDAY) || \ 584 ((__WEEKDAY__) == RTC_ALARM_WEEK_WEDNESDAY) || \ 585 ((__WEEKDAY__) == RTC_ALARM_WEEK_THURSDAY) || \ 586 ((__WEEKDAY__) == RTC_ALARM_WEEK_FRIDAY) || \ 587 ((__WEEKDAY__) == RTC_ALARM_WEEK_SATURDAY) || \ 588 ((__WEEKDAY__) >= 0x01000000 && (__WEEKDAY__) <= 0x7F000000)) 589 590 591 #define IS_RTC_TEMP_EDGE(__EDGE__) (((__EDGE__) == RTC_TEMP_EDGE_RISING) || \ 592 ((__EDGE__) == RTC_TEMP_EDGE_FALLING)) 593 594 #define IS_RTC_TEMP_INT(__INT__) (((__INT__) == RTC_TEMP_INT_ENABLE) || \ 595 ((__INT__) == RTC_TEMP_INT_DISABLE)) 596 597 #define IS_RTC_TEMP_CLEAR_BACKUP(__CLEAR__) (((__CLEAR__) == RTC_TEMP_CLEAR_DISABLE) || \ 598 ((__CLEAR__) == RTC_TEMP_CLEAR_ENABLE)) 599 600 #define IS_RTC_TEMP_FILTER(__FILTER__) (((__FILTER__) == RTC_TEMP_FILTER_DISABLE) || \ 601 ((__FILTER__) == RTC_TEMP_FILTER_512_RTCCLK) || \ 602 ((__FILTER__) == RTC_TEMP_FILTER_1_RTCCLK) || \ 603 ((__FILTER__) == RTC_TEMP_FILTER_2_RTCCLK) || \ 604 ((__FILTER__) == RTC_TEMP_FILTER_4_RTCCLK) || \ 605 ((__FILTER__) == RTC_TEMP_FILTER_8_RTCCLK)) 606 /** 607 * @} 608 */ 609 610 /* RTC stamp1 interrupt enable、disable */ 611 #define __HAL_RTC_ENABLE_STAMP1_IT (RTC->IE |= (RTC_IE_STP1RIE | RTC_IE_STP1FIE)) 612 #define __HAL_RTC_DISABLE_STAMP1_IT (RTC->IE &= ~(RTC_IE_STP1RIE | RTC_IE_STP1FIE)) 613 614 /* RTC stamp2 interrupt enable、disable */ 615 #define __HAL_RTC_ENABLE_STAMP2_IT (RTC->IE |= (RTC_IE_STP2RIE | RTC_IE_STP2FIE)) 616 #define __HAL_RTC_DISABLE_STAMP2_IT (RTC->IE &= ~(RTC_IE_STP2RIE | RTC_IE_STP2FIE)) 617 618 /* RTC 32S interrupt enable、disable */ 619 #define __HAL_RTC_ENABLE_32S_IT (RTC->IE |= RTC_IE_ADJ32) 620 #define __HAL_RTC_DISABLE_32S_IT (RTC->IE &= ~RTC_IE_ADJ32) 621 622 /* RTC alarm interrupt enable、disable */ 623 #define __HAL_RTC_ENABLE_ALM_IT (RTC->IE |= RTC_IE_ALM) 624 #define __HAL_RTC_DISABLE_ALM_IT (RTC->IE &= RTC_IE_ALM) 625 626 /* RTC sec interrupt enable、disable */ 627 #define __HAL_RTC_ENABLE_SEC_IT (RTC->IE |= RTC_IE_SEC) 628 #define __HAL_RTC_DISABLE_SEC_IT (RTC->IE &= ~RTC_IE_SEC) 629 630 /* RTC Minutes interrupt enable、disable */ 631 #define __HAL_RTC_ENABLE_MIN_IT (RTC->IE |= RTC_IE_MIN) 632 #define __HAL_RTC_DISABLE_MIN_IT (RTC->IE &= ~RTC_IE_MIN) 633 634 /* RTC Hour interrupt enable、disable */ 635 #define __HAL_RTC_ENABLE_HOUR_IT (RTC->IE |= RTC_IE_HOUR) 636 #define __HAL_RTC_DISABLE_HOUR_IT (RTC->IE &= ~RTC_IE_HOUR) 637 638 /* RTC Date interrupt enable、disable */ 639 #define __HAL_RTC_ENABLE_DATE_IT (RTC->IE |= RTC_IE_DATE) 640 #define __HAL_RTC_DISABLE_DATE_IT (RTC->IE &= ~RTC_IE_DATE) 641 642 /* HAL_RTC_Config */ 643 HAL_StatusTypeDef HAL_RTC_Config(RTC_ConfigTypeDef *hrtc); 644 645 /* HAL_RTC_SetTime */ 646 void HAL_RTC_SetTime(RTC_TimeTypeDef *fp_Time); 647 648 /* HAL_RTC_GetTime */ 649 void HAL_RTC_GetTime(RTC_TimeTypeDef *fp_Time); 650 651 /* HAL_RTC_SetDate */ 652 void HAL_RTC_SetDate(RTC_DateTypeDef *fp_Date); 653 654 /* HAL_RTC_GetDate */ 655 void HAL_RTC_GetDate(RTC_DateTypeDef *fp_Date); 656 657 658 /* HAL_RTC_AlarmConfig */ 659 void HAL_RTC_AlarmConfig(RTC_AlarmTypeDef *fp_Alarm); 660 661 /* HAL_RTC_AlarmEnable */ 662 void HAL_RTC_AlarmEnable(void); 663 664 /* HAL_RTC_AlarmDisable */ 665 void HAL_RTC_AlarmDisable(void); 666 667 /* HAL_RTC_Tamper */ 668 void HAL_RTC_Tamper(enum_Temper_t fe_Temper, RTC_TemperTypeDef *fp_Temper); 669 670 /* HAL_RTC_TamperEnable */ 671 void HAL_RTC_TamperEnable(enum_Temper_t fe_Temper); 672 673 /* HAL_RTC_TamperDisable */ 674 void HAL_RTC_TamperDisable(enum_Temper_t fe_Temper); 675 676 /* HAL_RTC_Standby_Wakeup */ 677 void HAL_RTC_Standby_Wakeup(enum_WKUP_t fe_Wakeup, uint32_t fu32_Edge); 678 679 /* HAL_RTC_Get_StandbyStatus */ 680 bool HAL_RTC_Get_StandbyStatus(void); 681 682 /* HAL_RTC_Get_StandbyWakeupSource */ 683 uint32_t HAL_RTC_Get_StandbyWakeupSource(void); 684 685 #endif 686