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