@@ -154,7 +154,13 @@ STM32RTC::Binary_Mode STM32RTC::getBinaryMode(void)
154
154
*/
155
155
void STM32RTC::setBinaryMode (Binary_Mode mode)
156
156
{
157
+ #if defined(RTC_BINARY_NONE)
157
158
_mode = mode;
159
+ #else
160
+ #warning "only BCD mode is supported"
161
+ UNUSED (mode);
162
+ _mode = MODE_BCD;
163
+ #endif /* RTC_BINARY_NONE */
158
164
}
159
165
160
166
/* *
@@ -340,7 +346,7 @@ void STM32RTC::standbyMode(void)
340
346
341
347
/* *
342
348
* @brief get RTC subseconds.
343
- * @retval return the current subseconds from the RTC.
349
+ * @retval return the current milliseconds from the RTC.
344
350
*/
345
351
uint32_t STM32RTC::getSubSeconds (void )
346
352
{
@@ -388,7 +394,7 @@ uint8_t STM32RTC::getHours(AM_PM *period)
388
394
* @param hours: pointer to the current hours
389
395
* @param minutes: pointer to the current minutes
390
396
* @param seconds: pointer to the current seconds
391
- * @param subSeconds: pointer to the current subSeconds
397
+ * @param subSeconds: pointer to the current subSeconds (in milliseconds)
392
398
* @param period: optional (default: nullptr)
393
399
* pointer to the current hour period set in the RTC: AM or PM
394
400
* @retval none
@@ -835,20 +841,30 @@ void STM32RTC::setDate(uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year
835
841
836
842
/* *
837
843
* @brief set RTC alarm subseconds.
838
- * @param subseconds: 0-999 (in ms)
844
+ * @param subseconds: 0-999 (in ms) or 32bit nb of milliseconds in BIN mode
839
845
* @param name: optional (default: ALARM_A)
840
846
* ALARM_A or ALARM_B if exists
841
847
* @retval none
842
848
*/
843
849
void STM32RTC::setAlarmSubSeconds (uint32_t subSeconds, Alarm name)
844
850
{
845
- if (subSeconds < 1000 ) {
851
+ #ifndef RTC_ALARM_B
852
+ UNUSED (name);
853
+ #endif
854
+ if (_mode == MODE_BIN) {
855
+ #ifdef RTC_ALARM_B
856
+ if (name == ALARM_B) {
857
+ _alarmBSubSeconds = subSeconds;
858
+ } else
859
+ #endif
860
+ {
861
+ _alarmSubSeconds = subSeconds;
862
+ }
863
+ } else if (subSeconds < 1000 ) {
846
864
#ifdef RTC_ALARM_B
847
865
if (name == ALARM_B) {
848
866
_alarmBSubSeconds = subSeconds;
849
867
} else
850
- #else
851
- UNUSED (name);
852
868
#endif
853
869
{
854
870
_alarmSubSeconds = subSeconds;
@@ -931,7 +947,7 @@ void STM32RTC::setAlarmHours(uint8_t hours, AM_PM period, Alarm name)
931
947
if (_format == HOUR_12) {
932
948
_alarmBPeriod = period;
933
949
}
934
- }
950
+ } else
935
951
#else
936
952
UNUSED (name);
937
953
#endif
@@ -944,6 +960,18 @@ void STM32RTC::setAlarmHours(uint8_t hours, AM_PM period, Alarm name)
944
960
}
945
961
}
946
962
963
+
964
+ /* *
965
+ * @brief set RTC alarm time.
966
+ * @param subSeconds: 0-999 ms or 32bit nb of milliseconds in BIN mode
967
+ * @param name: ALARM_A or ALARM_B if exists
968
+ * @retval none
969
+ */
970
+ void STM32RTC::setAlarmTime (uint32_t subSeconds, Alarm name)
971
+ {
972
+ setAlarmTime (0 , 0 , 0 , subSeconds, AM, name);
973
+ }
974
+
947
975
/* *
948
976
* @brief set RTC alarm time.
949
977
* @param hours: 0-23
@@ -962,7 +990,7 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, Ala
962
990
* @param hours: 0-23
963
991
* @param minutes: 0-59
964
992
* @param seconds: 0-59
965
- * @param subSeconds: 0-999
993
+ * @param subSeconds: 0-999 ms or 32bit nb of milliseconds in BIN mode
966
994
* @param name: ALARM_A or ALARM_B if exists
967
995
* @retval none
968
996
*/
@@ -973,10 +1001,10 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uin
973
1001
974
1002
/* *
975
1003
* @brief set RTC alarm time.
976
- * @param hours: 0-23
977
- * @param minutes: 0-59
978
- * @param seconds: 0-59
979
- * @param subSeconds: 0-999 (optional)
1004
+ * @param hours: 0-23 (not used in BIN mode)
1005
+ * @param minutes: 0-59 (not used in BIN mode)
1006
+ * @param seconds: 0-59 (not used in BIN mode)
1007
+ * @param subSeconds: 0-999 ms (optional) or 32bit nb of milliseconds in BIN mode
980
1008
* @param period: hour format AM or PM (optional)
981
1009
* @param name: optional (default: ALARM_A)
982
1010
* ALARM_A or ALARM_B if exists
0 commit comments