@@ -127,29 +127,21 @@ void STM32RTC::setClockSource(RTC_Source_Clock source)
127127 */
128128void STM32RTC::enableAlarm (Alarm_Match match)
129129{
130- hourAM_PM_t period;
131- uint8_t day, hours, minutes, seconds;
132- uint32_t subSeconds;
133-
134130 if (_configured) {
135- RTC_GetTime (&hours, &minutes, &seconds, &subSeconds, &period);
136- day = getDay ();
131+ _alarmMatch = match;
137132 switch (match) {
138133 case MATCH_OFF:
139134 RTC_StopAlarm ();
140135 break ;
141136 case MATCH_YYMMDDHHMMSS:// kept for compatibility
142137 case MATCH_MMDDHHMMSS: // kept for compatibility
143138 case MATCH_DHHMMSS:
144- day = _alarmDay;
145139 case MATCH_HHMMSS:
146- hours = _alarmHours;
147- period = (_alarmPeriod == RTC_AM)? AM: PM;
148140 case MATCH_MMSS:
149- minutes = _alarmMinutes;
150141 case MATCH_SS:
151- seconds = _alarmSeconds;
152- RTC_StartAlarm (day, hours, minutes, seconds, subSeconds, period);
142+ RTC_StartAlarm (_alarmDay, _alarmHours, _alarmMinutes, _alarmSeconds,
143+ _alarmSubSeconds, (_alarmPeriod == RTC_AM)? AM: PM,
144+ static_cast <uint8_t >(_alarmMatch));
153145 break ;
154146 default :
155147 break ;
@@ -757,7 +749,7 @@ uint32_t STM32RTC::getY2kEpoch(void)
757749 * @brief set RTC alarm from epoch time
758750 * @param epoch time in seconds
759751 */
760- void STM32RTC::setAlarmEpoch (uint32_t ts)
752+ void STM32RTC::setAlarmEpoch (uint32_t ts, Alarm_Match match )
761753{
762754 if (_configured) {
763755 if (ts < EPOCH_TIME_OFF) {
@@ -771,7 +763,7 @@ void STM32RTC::setAlarmEpoch(uint32_t ts)
771763 setAlarmHours (tmp->tm_hour );
772764 setAlarmMinutes (tmp->tm_min );
773765 setAlarmSeconds (tmp->tm_sec );
774- enableAlarm (MATCH_DHHMMSS );
766+ enableAlarm (match );
775767 }
776768}
777769
@@ -845,7 +837,23 @@ void STM32RTC::syncAlarmTime(void)
845837{
846838 if (_configured) {
847839 hourAM_PM_t p = AM;
848- RTC_GetAlarm (&_alarmDay, &_alarmHours, &_alarmMinutes, &_alarmSeconds, &_alarmSubSeconds, &p);
840+ uint8_t match;
841+ RTC_GetAlarm (&_alarmDay, &_alarmHours, &_alarmMinutes, &_alarmSeconds,
842+ &_alarmSubSeconds, &p, &match);
849843 _alarmPeriod = (p == AM)? RTC_AM : RTC_PM;
844+ switch (static_cast <Alarm_Match>(match)) {
845+ case MATCH_OFF:
846+ case MATCH_YYMMDDHHMMSS:// kept for compatibility
847+ case MATCH_MMDDHHMMSS: // kept for compatibility
848+ case MATCH_DHHMMSS:
849+ case MATCH_HHMMSS:
850+ case MATCH_MMSS:
851+ case MATCH_SS:
852+ _alarmMatch = static_cast <Alarm_Match>(match);
853+ break ;
854+ default :
855+ _alarmMatch = MATCH_OFF;
856+ break ;
857+ }
850858 }
851859}
0 commit comments