@@ -154,7 +154,13 @@ STM32RTC::Binary_Mode STM32RTC::getBinaryMode(void)
154154 */
155155void STM32RTC::setBinaryMode (Binary_Mode mode)
156156{
157+ #if defined(RTC_BINARY_NONE)
157158 _mode = mode;
159+ #else
160+ #warning "only BCD mode is supported"
161+ UNUSED (mode);
162+ _mode = MODE_BCD;
163+ #endif /* RTC_BINARY_NONE */
158164}
159165
160166/* *
@@ -340,7 +346,7 @@ void STM32RTC::standbyMode(void)
340346
341347/* *
342348 * @brief get RTC subseconds.
343- * @retval return the current subseconds from the RTC.
349+ * @retval return the current milliseconds from the RTC.
344350 */
345351uint32_t STM32RTC::getSubSeconds (void )
346352{
@@ -388,7 +394,7 @@ uint8_t STM32RTC::getHours(AM_PM *period)
388394 * @param hours: pointer to the current hours
389395 * @param minutes: pointer to the current minutes
390396 * @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)
392398 * @param period: optional (default: nullptr)
393399 * pointer to the current hour period set in the RTC: AM or PM
394400 * @retval none
@@ -835,20 +841,30 @@ void STM32RTC::setDate(uint8_t weekDay, uint8_t day, uint8_t month, uint8_t year
835841
836842/* *
837843 * @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
839845 * @param name: optional (default: ALARM_A)
840846 * ALARM_A or ALARM_B if exists
841847 * @retval none
842848 */
843849void STM32RTC::setAlarmSubSeconds (uint32_t subSeconds, Alarm name)
844850{
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 ) {
846864#ifdef RTC_ALARM_B
847865 if (name == ALARM_B) {
848866 _alarmBSubSeconds = subSeconds;
849867 } else
850- #else
851- UNUSED (name);
852868#endif
853869 {
854870 _alarmSubSeconds = subSeconds;
@@ -931,7 +947,7 @@ void STM32RTC::setAlarmHours(uint8_t hours, AM_PM period, Alarm name)
931947 if (_format == HOUR_12) {
932948 _alarmBPeriod = period;
933949 }
934- }
950+ } else
935951#else
936952 UNUSED (name);
937953#endif
@@ -944,6 +960,18 @@ void STM32RTC::setAlarmHours(uint8_t hours, AM_PM period, Alarm name)
944960 }
945961}
946962
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+
947975/* *
948976 * @brief set RTC alarm time.
949977 * @param hours: 0-23
@@ -962,7 +990,7 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, Ala
962990 * @param hours: 0-23
963991 * @param minutes: 0-59
964992 * @param seconds: 0-59
965- * @param subSeconds: 0-999
993+ * @param subSeconds: 0-999 ms or 32bit nb of milliseconds in BIN mode
966994 * @param name: ALARM_A or ALARM_B if exists
967995 * @retval none
968996 */
@@ -973,10 +1001,10 @@ void STM32RTC::setAlarmTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uin
9731001
9741002/* *
9751003 * @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
9801008 * @param period: hour format AM or PM (optional)
9811009 * @param name: optional (default: ALARM_A)
9821010 * ALARM_A or ALARM_B if exists
0 commit comments