@@ -701,11 +701,12 @@ void RTC_StartAlarm(alarm_t name, uint8_t day, uint8_t hours, uint8_t minutes, u
701
701
period = HOUR_AM ;
702
702
}
703
703
704
+ /* Use alarm A by default because it is common to all STM32 HAL */
705
+ RTC_AlarmStructure .Alarm = name ;
706
+
704
707
if ((((initFormat == HOUR_FORMAT_24 ) && IS_RTC_HOUR24 (hours )) || IS_RTC_HOUR12 (hours ))
705
708
&& IS_RTC_DATE (day ) && IS_RTC_MINUTES (minutes ) && IS_RTC_SECONDS (seconds )) {
706
709
/* Set RTC_AlarmStructure with calculated values*/
707
- /* Use alarm A by default because it is common to all STM32 HAL */
708
- RTC_AlarmStructure .Alarm = name ;
709
710
RTC_AlarmStructure .AlarmTime .Seconds = seconds ;
710
711
RTC_AlarmStructure .AlarmTime .Minutes = minutes ;
711
712
RTC_AlarmStructure .AlarmTime .Hours = hours ;
@@ -761,6 +762,38 @@ void RTC_StartAlarm(alarm_t name, uint8_t day, uint8_t hours, uint8_t minutes, u
761
762
UNUSED (mask );
762
763
#endif /* !STM32F1xx */
763
764
765
+ /* Set RTC_Alarm */
766
+ HAL_RTC_SetAlarm_IT (& RtcHandle , & RTC_AlarmStructure , RTC_FORMAT_BIN );
767
+ HAL_NVIC_SetPriority (RTC_Alarm_IRQn , RTC_IRQ_PRIO , RTC_IRQ_SUBPRIO );
768
+ HAL_NVIC_EnableIRQ (RTC_Alarm_IRQn );
769
+ } else {
770
+ /* We have an SubSecond alarm to set in RTC_BINARY_MIX mode */
771
+ #if defined(RTC_SSR_SS )
772
+ {
773
+ #if defined(RTC_ALRMASSR_SSCLR )
774
+ RTC_AlarmStructure .BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO ;
775
+ #endif /* RTC_ALRMASSR_SSCLR */
776
+ RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_NONE ;
777
+
778
+ #ifdef RTC_ALARM_B
779
+ if (name == ALARM_B ) {
780
+ /* Expecting RTC_ALARMSUBSECONDBINMASK_NONE for the subsecond mask on ALARM B */
781
+ RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_ALL ;
782
+ RTC_AlarmStructure .AlarmSubSecondMask = mask << RTC_ALRMBSSR_MASKSS_Pos ;
783
+ } else
784
+ #endif
785
+ {
786
+ /* Expecting RTC_ALARMSUBSECONDBINMASK_NONE for the subsecond mask on ALARM A */
787
+ RTC_AlarmStructure .AlarmMask = RTC_ALARMMASK_ALL ;
788
+ RTC_AlarmStructure .AlarmSubSecondMask = mask << RTC_ALRMASSR_MASKSS_Pos ;
789
+ }
790
+ /* Special case for ALARM B configuration for stm32WL Lorawan */
791
+ RTC_AlarmStructure .AlarmTime .SubSeconds = subSeconds ;
792
+ }
793
+
794
+ #else
795
+ UNUSED (subSeconds );
796
+ #endif /* RTC_SSR_SS */
764
797
/* Set RTC_Alarm */
765
798
HAL_RTC_SetAlarm_IT (& RtcHandle , & RTC_AlarmStructure , RTC_FORMAT_BIN );
766
799
HAL_NVIC_SetPriority (RTC_Alarm_IRQn , RTC_IRQ_PRIO , RTC_IRQ_SUBPRIO );
0 commit comments