@@ -546,7 +546,7 @@ void RTC_GetDate(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *wday)
546
546
* @param period: AM or PM if in 12 hours mode else ignored.
547
547
* @retval None
548
548
*/
549
- void RTC_StartAlarm (uint8_t day , uint8_t hours , uint8_t minutes , uint8_t seconds , uint32_t subSeconds , hourAM_PM_t period )
549
+ void RTC_StartAlarm (uint8_t day , uint8_t hours , uint8_t minutes , uint8_t seconds , uint32_t subSeconds , hourAM_PM_t period , uint8_t mask )
550
550
{
551
551
RTC_AlarmTypeDef RTC_AlarmStructure ;
552
552
@@ -578,11 +578,29 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
578
578
RTC_AlarmStructure .AlarmTime .StoreOperation = RTC_STOREOPERATION_RESET ;
579
579
RTC_AlarmStructure .AlarmDateWeekDay = day ;
580
580
RTC_AlarmStructure .AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE ;
581
- RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_NONE ;
581
+ /* configure AlarmMask (M_MSK and Y_MSK ignored) */
582
+ if (mask == OFF_MSK ) {
583
+ RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_ALL ;
584
+ } else {
585
+ RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_NONE ;
586
+ if ( !(mask & SS_MSK )) {
587
+ RTC_AlarmStructure .AlarmMask |= RTC_ALARMMASK_SECONDS ;
588
+ }
589
+ if ( !(mask & MM_MSK )) {
590
+ RTC_AlarmStructure .AlarmMask |= RTC_ALARMMASK_MINUTES ;
591
+ }
592
+ if ( !(mask & HH_MSK )) {
593
+ RTC_AlarmStructure .AlarmMask |= RTC_ALARMMASK_HOURS ;
594
+ }
595
+ if ( !(mask & D_MSK )) {
596
+ RTC_AlarmStructure .AlarmMask |= RTC_ALARMMASK_DATEWEEKDAY ;
597
+ }
598
+ }
582
599
#else
583
600
UNUSED (subSeconds );
584
601
UNUSED (period );
585
602
UNUSED (day );
603
+ UNUSED (mask );
586
604
#endif // !defined(STM32F1xx)
587
605
588
606
/* Set RTC_Alarm */
@@ -614,16 +632,17 @@ void RTC_StopAlarm(void)
614
632
* @param period: AM or PM
615
633
* @retval None
616
634
*/
617
- void RTC_GetAlarm (uint8_t * day , uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period )
635
+ void RTC_GetAlarm (uint8_t * day , uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period , uint8_t * mask )
618
636
{
619
637
RTC_AlarmTypeDef RTC_AlarmStructure ;
620
638
621
- if ((day != NULL ) && (hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && (subSeconds != NULL ) && (period != NULL )) {
639
+ if ((day != NULL ) && (hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && (subSeconds != NULL ) && (period != NULL ) && ( mask != NULL ) ) {
622
640
HAL_RTC_GetAlarm (& RtcHandle , & RTC_AlarmStructure , RTC_ALARM_A , RTC_FORMAT_BIN );
623
641
624
642
* seconds = RTC_AlarmStructure .AlarmTime .Seconds ;
625
643
* minutes = RTC_AlarmStructure .AlarmTime .Minutes ;
626
644
* hours = RTC_AlarmStructure .AlarmTime .Hours ;
645
+
627
646
#if !defined(STM32F1xx )
628
647
* day = RTC_AlarmStructure .AlarmDateWeekDay ;
629
648
if (RTC_AlarmStructure .AlarmTime .TimeFormat == RTC_HOURFORMAT12_PM ) {
@@ -634,6 +653,19 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
634
653
#if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
635
654
* subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
636
655
#endif
656
+ * mask = OFF_MSK ;
657
+ if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
658
+ * mask |= SS_MSK ;
659
+ }
660
+ if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_MINUTES )) {
661
+ * mask |= MM_MSK ;
662
+ }
663
+ if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_HOURS )) {
664
+ * mask |= HH_MSK ;
665
+ }
666
+ if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_DATEWEEKDAY )) {
667
+ * mask |= D_MSK ;
668
+ }
637
669
#endif // !defined(STM32F1xx)
638
670
}
639
671
}
0 commit comments