@@ -418,27 +418,31 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
418418 * @param hours: 0-12 or 0-23. Depends on the format used.
419419 * @param minutes: 0-59
420420 * @param seconds: 0-59
421- * @param subSeconds: 0-999
422- * @param period: returns AM or PM period in case RTC is set in 12 hours mode.
421+ * @param subSeconds: 0-999 (optional could be NULL)
422+ * @param period: AM or PM period in case RTC is set in 12 hours mode (optional could be NULL) .
423423 * @retval None
424424 */
425425void RTC_GetTime (uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period )
426426{
427427 RTC_TimeTypeDef RTC_TimeStruct ;
428428
429- if ((hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && ( subSeconds != NULL ) && ( period != NULL ) ) {
429+ if ((hours != NULL ) && (minutes != NULL ) && (seconds != NULL )) {
430430 HAL_RTC_GetTime (& RtcHandle , & RTC_TimeStruct , RTC_FORMAT_BIN );
431431 * hours = RTC_TimeStruct .Hours ;
432432 * minutes = RTC_TimeStruct .Minutes ;
433433 * seconds = RTC_TimeStruct .Seconds ;
434434#if !defined(STM32F1xx )
435- if (RTC_TimeStruct .TimeFormat == RTC_HOURFORMAT12_PM ) {
435+ if (period != NULL ) {
436+ if (RTC_TimeStruct .TimeFormat == RTC_HOURFORMAT12_PM ) {
436437 * period = PM ;
437- } else {
438- * period = AM ;
438+ } else {
439+ * period = AM ;
440+ }
439441 }
440442#if (!defined(STM32F2xx ) && !defined(STM32L1xx )) || defined(STM32L1_ULPH )
441- * subSeconds = RTC_TimeStruct .SubSeconds ;
443+ if (subSeconds != NULL ) {
444+ * subSeconds = RTC_TimeStruct .SubSeconds ;
445+ }
442446#endif
443447#endif /* !STM32F1xx */
444448 }
@@ -581,15 +585,15 @@ void RTC_StopAlarm(void)
581585 * @param hours: 0-12 or 0-23 depends on the hours mode.
582586 * @param minutes: 0-59
583587 * @param seconds: 0-59
584- * @param subSeconds: 0-999
585- * @param period: AM or PM
588+ * @param subSeconds: 0-999 (optional could be NULL)
589+ * @param period: AM or PM (optional could be NULL)
586590 * @retval None
587591 */
588592void RTC_GetAlarm (uint8_t * day , uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period , uint8_t * mask )
589593{
590594 RTC_AlarmTypeDef RTC_AlarmStructure ;
591595
592- if ((day != NULL ) && (hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && (subSeconds != NULL ) && ( period != NULL ) && ( mask != NULL )) {
596+ if ((day != NULL ) && (hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && (mask != NULL )) {
593597 HAL_RTC_GetAlarm (& RtcHandle , & RTC_AlarmStructure , RTC_ALARM_A , RTC_FORMAT_BIN );
594598
595599 * seconds = RTC_AlarmStructure .AlarmTime .Seconds ;
@@ -598,13 +602,17 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
598602
599603#if !defined(STM32F1xx )
600604 * day = RTC_AlarmStructure .AlarmDateWeekDay ;
601- if (RTC_AlarmStructure .AlarmTime .TimeFormat == RTC_HOURFORMAT12_PM ) {
602- * period = PM ;
603- } else {
604- * period = AM ;
605+ if (period != NULL ) {
606+ if (RTC_AlarmStructure .AlarmTime .TimeFormat == RTC_HOURFORMAT12_PM ) {
607+ * period = PM ;
608+ } else {
609+ * period = AM ;
610+ }
605611 }
606612#if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
607- * subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
613+ if (subSeconds != NULL ) {
614+ * subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
615+ }
608616#endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
609617 * mask = OFF_MSK ;
610618 if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
0 commit comments