@@ -237,13 +237,27 @@ void STM32RTC::enableAlarm(Alarm_Match match, Alarm name)
237
237
RTC_StopAlarm (::ALARM_A);
238
238
}
239
239
break ;
240
+ case MATCH_SUBSEC:
241
+ /* force _alarmday to 0 to go to the right alarm config in MIX mode */
242
+ #ifdef RTC_ALARM_B
243
+ if (name == ALARM_B) {
244
+ RTC_StartAlarm (::ALARM_B, 0 , 0 , 0 , 0 ,
245
+ (UINT32_MAX - _alarmBSubSeconds), (_alarmBPeriod == AM) ? HOUR_AM : HOUR_PM,
246
+ static_cast <uint8_t >(31UL ));
247
+ } else
248
+ #endif
249
+ {
250
+ RTC_StartAlarm (::ALARM_A, 0 , 0 , 0 , 0 ,
251
+ (UINT32_MAX - _alarmSubSeconds), (_alarmPeriod == AM) ? HOUR_AM : HOUR_PM,
252
+ static_cast <uint8_t >(31UL ));
253
+ }
254
+ break ;
240
255
case MATCH_YYMMDDHHMMSS:// kept for compatibility
241
256
case MATCH_MMDDHHMMSS: // kept for compatibility
242
257
case MATCH_DHHMMSS:
243
258
case MATCH_HHMMSS:
244
259
case MATCH_MMSS:
245
260
case MATCH_SS:
246
- case MATCH_SUBSEC:
247
261
#ifdef RTC_ALARM_B
248
262
if (name == ALARM_B) {
249
263
RTC_StartAlarm (::ALARM_B, _alarmBDay, _alarmBHours, _alarmBMinutes, _alarmBSeconds,
@@ -845,7 +859,8 @@ void STM32RTC::setDate(uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year
845
859
*/
846
860
void STM32RTC::setAlarmSubSeconds (uint32_t subSeconds, Alarm name)
847
861
{
848
- if (subSeconds < 1000 ) {
862
+
863
+ if (getBinaryMode () == MODE_MIX) {
849
864
#ifdef RTC_ALARM_B
850
865
if (name == ALARM_B) {
851
866
_alarmBSubSeconds = subSeconds;
@@ -856,6 +871,19 @@ void STM32RTC::setAlarmSubSeconds(uint32_t subSeconds, Alarm name)
856
871
{
857
872
_alarmSubSeconds = subSeconds;
858
873
}
874
+ } else {
875
+ if (subSeconds < 1000 ) {
876
+ #ifdef RTC_ALARM_B
877
+ if (name == ALARM_B) {
878
+ _alarmBSubSeconds = subSeconds;
879
+ }
880
+ #else
881
+ UNUSED (name);
882
+ #endif
883
+ {
884
+ _alarmSubSeconds = subSeconds;
885
+ }
886
+ }
859
887
}
860
888
}
861
889
@@ -1268,6 +1296,7 @@ bool STM32RTC::isAlarmEnabled(Alarm name)
1268
1296
void STM32RTC::syncTime (void )
1269
1297
{
1270
1298
hourAM_PM_t p = HOUR_AM;
1299
+
1271
1300
RTC_GetTime (&_hours, &_minutes, &_seconds, &_subSeconds, &p);
1272
1301
_hoursPeriod = (p == HOUR_AM) ? AM : PM;
1273
1302
}
0 commit comments