@@ -127,29 +127,21 @@ void STM32RTC::setClockSource(RTC_Source_Clock source)
127
127
*/
128
128
void STM32RTC::enableAlarm (Alarm_Match match)
129
129
{
130
- hourAM_PM_t period;
131
- uint8_t day, hours, minutes, seconds;
132
- uint32_t subSeconds;
133
-
134
130
if (_configured) {
135
- RTC_GetTime (&hours, &minutes, &seconds, &subSeconds, &period);
136
- day = getDay ();
131
+ _alarmMatch = match;
137
132
switch (match) {
138
133
case MATCH_OFF:
139
134
RTC_StopAlarm ();
140
135
break ;
141
136
case MATCH_YYMMDDHHMMSS:// kept for compatibility
142
137
case MATCH_MMDDHHMMSS: // kept for compatibility
143
138
case MATCH_DHHMMSS:
144
- day = _alarmDay;
145
139
case MATCH_HHMMSS:
146
- hours = _alarmHours;
147
- period = (_alarmPeriod == RTC_AM)? AM: PM;
148
140
case MATCH_MMSS:
149
- minutes = _alarmMinutes;
150
141
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));
153
145
break ;
154
146
default :
155
147
break ;
@@ -757,7 +749,7 @@ uint32_t STM32RTC::getY2kEpoch(void)
757
749
* @brief set RTC alarm from epoch time
758
750
* @param epoch time in seconds
759
751
*/
760
- void STM32RTC::setAlarmEpoch (uint32_t ts)
752
+ void STM32RTC::setAlarmEpoch (uint32_t ts, Alarm_Match match )
761
753
{
762
754
if (_configured) {
763
755
if (ts < EPOCH_TIME_OFF) {
@@ -771,7 +763,7 @@ void STM32RTC::setAlarmEpoch(uint32_t ts)
771
763
setAlarmHours (tmp->tm_hour );
772
764
setAlarmMinutes (tmp->tm_min );
773
765
setAlarmSeconds (tmp->tm_sec );
774
- enableAlarm (MATCH_DHHMMSS );
766
+ enableAlarm (match );
775
767
}
776
768
}
777
769
@@ -845,7 +837,23 @@ void STM32RTC::syncAlarmTime(void)
845
837
{
846
838
if (_configured) {
847
839
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);
849
843
_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
+ }
850
858
}
851
859
}
0 commit comments