@@ -418,27 +418,31 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
418
418
* @param hours: 0-12 or 0-23. Depends on the format used.
419
419
* @param minutes: 0-59
420
420
* @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) .
423
423
* @retval None
424
424
*/
425
425
void RTC_GetTime (uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period )
426
426
{
427
427
RTC_TimeTypeDef RTC_TimeStruct ;
428
428
429
- if ((hours != NULL ) && (minutes != NULL ) && (seconds != NULL ) && ( subSeconds != NULL ) && ( period != NULL ) ) {
429
+ if ((hours != NULL ) && (minutes != NULL ) && (seconds != NULL )) {
430
430
HAL_RTC_GetTime (& RtcHandle , & RTC_TimeStruct , RTC_FORMAT_BIN );
431
431
* hours = RTC_TimeStruct .Hours ;
432
432
* minutes = RTC_TimeStruct .Minutes ;
433
433
* seconds = RTC_TimeStruct .Seconds ;
434
434
#if !defined(STM32F1xx )
435
- if (RTC_TimeStruct .TimeFormat == RTC_HOURFORMAT12_PM ) {
435
+ if (period != NULL ) {
436
+ if (RTC_TimeStruct .TimeFormat == RTC_HOURFORMAT12_PM ) {
436
437
* period = PM ;
437
- } else {
438
- * period = AM ;
438
+ } else {
439
+ * period = AM ;
440
+ }
439
441
}
440
442
#if (!defined(STM32F2xx ) && !defined(STM32L1xx )) || defined(STM32L1_ULPH )
441
- * subSeconds = RTC_TimeStruct .SubSeconds ;
443
+ if (subSeconds != NULL ) {
444
+ * subSeconds = RTC_TimeStruct .SubSeconds ;
445
+ }
442
446
#endif
443
447
#endif /* !STM32F1xx */
444
448
}
@@ -581,15 +585,15 @@ void RTC_StopAlarm(void)
581
585
* @param hours: 0-12 or 0-23 depends on the hours mode.
582
586
* @param minutes: 0-59
583
587
* @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)
586
590
* @retval None
587
591
*/
588
592
void RTC_GetAlarm (uint8_t * day , uint8_t * hours , uint8_t * minutes , uint8_t * seconds , uint32_t * subSeconds , hourAM_PM_t * period , uint8_t * mask )
589
593
{
590
594
RTC_AlarmTypeDef RTC_AlarmStructure ;
591
595
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 )) {
593
597
HAL_RTC_GetAlarm (& RtcHandle , & RTC_AlarmStructure , RTC_ALARM_A , RTC_FORMAT_BIN );
594
598
595
599
* seconds = RTC_AlarmStructure .AlarmTime .Seconds ;
@@ -598,13 +602,17 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
598
602
599
603
#if !defined(STM32F1xx )
600
604
* 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
+ }
605
611
}
606
612
#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
+ }
608
616
#endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
609
617
* mask = OFF_MSK ;
610
618
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
0 commit comments