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 * @brief RTC Time structure definition 407 */ 408 typedef struct 409 { 410 uint32_t u32_AlarmMode; /*!< Specifies the RTC alarm Mode. 411 This parameter can be a value of @ref RTC_Alarm_Mode */ 412 413 uint32_t u32_AlarmInterrupt; /*!< Specifies the RTC alarm interrupt Enable or Disable. 414 This parameter can be a value of @ref RTC_AlarmInterrupt */ 415 416 uint32_t u32_DayMask; /*!< Specifies the RTC alarm Day/Week Mask. 417 This parameter can be a value of @ref RTC_DayMask */ 418 419 uint32_t u32_HourMask; /*!< Specifies the RTC alarm Hour Mask. 420 This parameter can be a value of @ref RTC_HourMask */ 421 422 uint32_t u32_MinMask; /*!< Specifies the RTC alarm Min Mask. 423 This parameter can be a value of @ref RTC_MinMask */ 424 425 uint32_t u32_AlarmWeek; /*!< Specifies the RTC alarm week select(Select WeekMode this parameter is valid). 426 This parameter can be a value of @ref RTC_Alarm_WeekSelect */ 427 428 uint32_t u32_AlarmDay; /*!< Specifies the RTC alarm day select(Select DayMode this parameter is valid). 429 This parameter must be a number between Min_Data = 0x01 and Max_Data = 0x31 */ 430 431 uint32_t u32_Hours; /*!< Specifies the RTC alarm Hour. 432 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x23 */ 433 434 uint32_t u32_Minutes; /*!< Specifies the RTC alarm Minutes. 435 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 436 437 uint32_t u32_Seconds; /*!< Specifies the RTC alarm Seconds. 438 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x59 */ 439 }RTC_AlarmTypeDef; 440 441 442 /** 443 * @brief RTC Temper structure definition 444 */ 445 typedef struct 446 { 447 uint32_t u32_TemperEdge; /*!< Specifies the RTC Temper edge select. 448 This parameter can be a value of @ref RTC_Temper_edge */ 449 450 uint32_t u32_InterruptEN; /*!< Specifies the RTC Temper interrupt enable. 451 This parameter can be a value of @ref RTC_TemperInterrupt */ 452 453 uint32_t u32_ClearBackup; /*!< Specifies the RTC Temper clear backup register. 454 This parameter can be a value of @ref RTC_ClearBackup */ 455 456 uint32_t u32_Filter; /*!< Specifies the RTC Temper Filter select. 457 This parameter can be a value of @ref RTC_TemperFilter */ 458 }RTC_TemperTypeDef; 459 460 461 /** @brief PC13 function select 462 * @param __FUNC__: PC13 function select. 463 * This parameter can be 0: GPIO0/1/RTC Fout/2/RTC tamper/3/PC13 Value 464 */ 465 #define __HAL_RTC_PC13_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3)) | (__FUNC__)) 466 467 /** @brief PC14 function select 468 * @param __FUNC__: PC14 function select. 469 * This parameter can be 0: GPIO_1_PC14 Value */ 470 #define __HAL_RTC_PC14_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3 << 3)) | (__FUNC__ << 3)) 471 472 /** @brief PC15 function select 473 * @param __FUNC__: PC15 function select. 474 * This parameter can be 0: GPIO_1_PC15 Value 475 */ 476 #define __HAL_RTC_PC15_SEL(__FUNC__) (PMU->IOSEL |= (PMU->IOSEL & ~(0x3 << 5)) | (__FUNC__ << 5)) 477 478 /** @brief PC13 Value set 479 * @param __FUNC__: PC13 Value set. 480 * This parameter can be 0: set to 1 to clear 481 */ 482 #define __HAL_RTC_PC13_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 8)) | (__VALUE__ << 8)) 483 484 /** @brief PC14 Value set 485 * @param __FUNC__: PC14 Value set. 486 * This parameter can be 0: set to 1 to clear 487 */ 488 #define __HAL_RTC_PC14_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 9)) | (__VALUE__ << 9)) 489 490 /** @brief PC15 Value set 491 * @param __FUNC__: PC15 Value set. 492 * This parameter can be 0: set to 1 to clear 493 */ 494 #define __HAL_RTC_PC15_VALUE(__VALUE__) (PMU->IOSEL |= (PMU->IOSEL & ~(1 << 10)) | (__VALUE__ << 10)) 495 496 /* @brief PC13、PC14、PC15 pull up or pull down */ 497 #define __HAL_RTC_PC13_PULL_UP_ENABLE() (PMU->IOCR |= BIT0) 498 #define __HAL_RTC_PC13_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT0) 499 #define __HAL_RTC_PC13_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT1) 500 #define __HAL_RTC_PC13_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT1) 501 502 #define __HAL_RTC_PC14_PULL_UP_ENABLE() (PMU->IOCR |= BIT8) 503 #define __HAL_RTC_PC14_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT8) 504 #define __HAL_RTC_PC14_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT9) 505 #define __HAL_RTC_PC14_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT9) 506 507 #define __HAL_RTC_PC15_PULL_UP_ENABLE() (PMU->IOCR |= BIT16) 508 #define __HAL_RTC_PC15_PULL_UP_DISABLE() (PMU->IOCR &= ~BIT16) 509 #define __HAL_RTC_PC15_PULL_DOWN_ENABLE() (PMU->IOCR |= BIT17) 510 #define __HAL_RTC_PC15_PULL_DOWN_DISABLE() (PMU->IOCR &= ~BIT17) 511 512 /* @brief PC13、PC14、PC15 digit or analog */ 513 #define __HAL_RTC_PC13_ANALOG() (PMU->IOCR |= BIT6) 514 #define __HAL_RTC_PC13_DIGIT() (PMU->IOCR &= ~BIT6) 515 516 #define __HAL_RTC_PC14_ANALOG() (PMU->IOCR |= BIT14) 517 #define __HAL_RTC_PC14_DIGIT() (PMU->IOCR &= ~BIT14) 518 519 #define __HAL_RTC_PC15_ANALOG() (PMU->IOCR |= BIT22) 520 #define __HAL_RTC_PC15_DIGIT() (PMU->IOCR &= ~BIT22) 521 522 523 /** @defgroup RTC Private Macros 524 * @{ 525 */ 526 #define IS_RTC_CLOCKSRC(__CLOCKSRC__) (((__CLOCKSRC__) == RTC_CLOCK_RC32K) || \ 527 ((__CLOCKSRC__) == RTC_CLOCK_XTL)) 528 529 #define IS_RTC_COMPENSATION(__COMPENSATION__) (((__COMPENSATION__) == COMPENSATION_INCREASE) || \ 530 ((__COMPENSATION__) == COMPENSATION_DECREASE)) 531 532 #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) >= 0x00 && (__YEAR__) <= 0x99) 533 534 #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) == RTC_MONTH_JANUARY) || \ 535 ((__MONTH__) == RTC_MONTH_FEBRUARY) || \ 536 ((__MONTH__) == RTC_MONTH_MARCH) || \ 537 ((__MONTH__) == RTC_MONTH_APRIL) || \ 538 ((__MONTH__) == RTC_MONTH_MAY) || \ 539 ((__MONTH__) == RTC_MONTH_JUNE) || \ 540 ((__MONTH__) == RTC_MONTH_JULY) || \ 541 ((__MONTH__) == RTC_MONTH_AUGUST) || \ 542 ((__MONTH__) == RTC_MONTH_SEPTEMBER) || \ 543 ((__MONTH__) == RTC_MONTH_OCTOBER) || \ 544 ((__MONTH__) == RTC_MONTH_NOVEMBER) || \ 545 ((__MONTH__) == RTC_MONTH_DECEMBER)) 546 547 #define IS_RTC_DAY(__DAY__) ((__DAY__) >= 0x01 && (__DAY__) <= 0x31) 548 549 #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \ 550 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \ 551 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \ 552 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \ 553 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \ 554 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \ 555 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY)) 556 557 #define IS_RTC_HOUR(__HOUR__) ((__HOUR__) >= 0x00 && (__HOUR__) <= 0x23) 558 559 #define IS_RTC_MIN(__MIN__) ((__MIN__) >= 0x00 && (__MIN__) <= 0x59) 560 561 #define IS_RTC_SEC(__SEC__) ((__SEC__) >= 0x00 && (__SEC__) <= 0x59) 562 563 564 #define IS_RTC_ALARM_MODE(__MODE__) (((__MODE__) == RTC_ALARM_WEEK_MODE) || \ 565 ((__MODE__) == RTC_ALARM_DAY_MODE)) 566 567 #define IS_RTC_ALARM_INT(__INT__) (((__INT__) == RTC_ALARM_INT_ENABLE) || \ 568 ((__INT__) == RTC_ALARM_INT_DISABLE)) 569 570 #define IS_RTC_ALARM_DAY_MASK(__MASKD__) (((__MASKD__) == RTC_ALARM_DAY_MASK_ENABLE) || \ 571 ((__MASKD__) == RTC_ALARM_DAY_MASK_DISABLE)) 572 573 #define IS_RTC_ALARM_HOUR_MASK(__MASKH__) (((__MASKH__) == RTC_ALARM_HOUR_MASK_ENABLE) || \ 574 ((__MASKH__) == RTC_ALARM_HOUR_MASK_DISABLE)) 575 576 #define IS_RTC_ALARM_MIN_MASK(__MASKM__) (((__MASKM__) == RTC_ALARM_MIN_MASK_ENABLE) || \ 577 ((__MASKM__) == RTC_ALARM_MIN_MASK_DISABLE)) 578 579 #define IS_RTC_ALARM_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_ALARM_WEEK_SUNDAY) || \ 580 ((__WEEKDAY__) == RTC_ALARM_WEEK_MONDAY) || \ 581 ((__WEEKDAY__) == RTC_ALARM_WEEK_TUESDAY) || \ 582 ((__WEEKDAY__) == RTC_ALARM_WEEK_WEDNESDAY) || \ 583 ((__WEEKDAY__) == RTC_ALARM_WEEK_THURSDAY) || \ 584 ((__WEEKDAY__) == RTC_ALARM_WEEK_FRIDAY) || \ 585 ((__WEEKDAY__) == RTC_ALARM_WEEK_SATURDAY) || \ 586 ((__WEEKDAY__) >= 0x01000000 && (__WEEKDAY__) <= 0x7F000000)) 587 588 589 #define IS_RTC_TEMP_EDGE(__EDGE__) (((__EDGE__) == RTC_TEMP_EDGE_RISING) || \ 590 ((__EDGE__) == RTC_TEMP_EDGE_FALLING)) 591 592 #define IS_RTC_TEMP_INT(__INT__) (((__INT__) == RTC_TEMP_INT_ENABLE) || \ 593 ((__INT__) == RTC_TEMP_INT_DISABLE)) 594 595 #define IS_RTC_TEMP_CLEAR_BACKUP(__CLEAR__) (((__CLEAR__) == RTC_TEMP_CLEAR_DISABLE) || \ 596 ((__CLEAR__) == RTC_TEMP_CLEAR_ENABLE)) 597 598 #define IS_RTC_TEMP_FILTER(__FILTER__) (((__FILTER__) == RTC_TEMP_FILTER_DISABLE) || \ 599 ((__FILTER__) == RTC_TEMP_FILTER_512_RTCCLK) || \ 600 ((__FILTER__) == RTC_TEMP_FILTER_1_RTCCLK) || \ 601 ((__FILTER__) == RTC_TEMP_FILTER_2_RTCCLK) || \ 602 ((__FILTER__) == RTC_TEMP_FILTER_4_RTCCLK) || \ 603 ((__FILTER__) == RTC_TEMP_FILTER_8_RTCCLK)) 604 /** 605 * @} 606 */ 607 608 /* RTC stamp1 interrupt enable/disable */ 609 #define __HAL_RTC_ENABLE_STAMP1_IT (RTC->IE |= (RTC_IE_STP1RIE | RTC_IE_STP1FIE)) 610 #define __HAL_RTC_DISABLE_STAMP1_IT (RTC->IE &= ~(RTC_IE_STP1RIE | RTC_IE_STP1FIE)) 611 612 /* RTC stamp2 interrupt enable/disable */ 613 #define __HAL_RTC_ENABLE_STAMP2_IT (RTC->IE |= (RTC_IE_STP2RIE | RTC_IE_STP2FIE)) 614 #define __HAL_RTC_DISABLE_STAMP2_IT (RTC->IE &= ~(RTC_IE_STP2RIE | RTC_IE_STP2FIE)) 615 616 /* RTC 32S interrupt enable/disable */ 617 #define __HAL_RTC_ENABLE_32S_IT (RTC->IE |= RTC_IE_ADJ32) 618 #define __HAL_RTC_DISABLE_32S_IT (RTC->IE &= ~RTC_IE_ADJ32) 619 620 /* RTC alarm interrupt enable/disable */ 621 #define __HAL_RTC_ENABLE_ALM_IT (RTC->IE |= RTC_IE_ALM) 622 #define __HAL_RTC_DISABLE_ALM_IT (RTC->IE &= RTC_IE_ALM) 623 624 /* RTC sec interrupt enable/disable */ 625 #define __HAL_RTC_ENABLE_SEC_IT (RTC->IE |= RTC_IE_SEC) 626 #define __HAL_RTC_DISABLE_SEC_IT (RTC->IE &= ~RTC_IE_SEC) 627 628 /* RTC Minutes interrupt enable/disable */ 629 #define __HAL_RTC_ENABLE_MIN_IT (RTC->IE |= RTC_IE_MIN) 630 #define __HAL_RTC_DISABLE_MIN_IT (RTC->IE &= ~RTC_IE_MIN) 631 632 /* RTC Hour interrupt enable/disable */ 633 #define __HAL_RTC_ENABLE_HOUR_IT (RTC->IE |= RTC_IE_HOUR) 634 #define __HAL_RTC_DISABLE_HOUR_IT (RTC->IE &= ~RTC_IE_HOUR) 635 636 /* RTC Date interrupt enable/disable */ 637 #define __HAL_RTC_ENABLE_DATE_IT (RTC->IE |= RTC_IE_DATE) 638 #define __HAL_RTC_DISABLE_DATE_IT (RTC->IE &= ~RTC_IE_DATE) 639 640 /* HAL_RTC_Config */ 641 HAL_StatusTypeDef HAL_RTC_Config(RTC_ConfigTypeDef *hrtc); 642 643 /* HAL_RTC_SetTime */ 644 void HAL_RTC_SetTime(RTC_TimeTypeDef *fp_Time); 645 646 /* HAL_RTC_GetTime */ 647 void HAL_RTC_GetTime(RTC_TimeTypeDef *fp_Time); 648 649 /* HAL_RTC_SetDate */ 650 void HAL_RTC_SetDate(RTC_DateTypeDef *fp_Date); 651 652 /* HAL_RTC_GetDate */ 653 void HAL_RTC_GetDate(RTC_DateTypeDef *fp_Date); 654 655 656 /* HAL_RTC_AlarmConfig */ 657 void HAL_RTC_AlarmConfig(RTC_AlarmTypeDef *fp_Alarm); 658 659 /* HAL_RTC_AlarmEnable */ 660 void HAL_RTC_AlarmEnable(void); 661 662 /* HAL_RTC_AlarmDisable */ 663 void HAL_RTC_AlarmDisable(void); 664 665 /* HAL_RTC_Tamper */ 666 void HAL_RTC_Tamper(enum_Temper_t fe_Temper, RTC_TemperTypeDef *fp_Temper); 667 668 /* HAL_RTC_TamperEnable */ 669 void HAL_RTC_TamperEnable(enum_Temper_t fe_Temper); 670 671 /* HAL_RTC_TamperDisable */ 672 void HAL_RTC_TamperDisable(enum_Temper_t fe_Temper); 673 674 /* HAL_RTC_Standby_Wakeup */ 675 void HAL_RTC_Standby_Wakeup(enum_WKUP_t fe_Wakeup, uint32_t fu32_Edge); 676 677 /* HAL_RTC_Get_StandbyStatus */ 678 bool HAL_RTC_Get_StandbyStatus(void); 679 680 /* HAL_RTC_Get_StandbyWakeupSource */ 681 uint32_t HAL_RTC_Get_StandbyWakeupSource(void); 682 683 #endif 684