From cf54e13565a50c0c61740d7f10e9f8f3ec4ede77 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Fri, 11 May 2018 17:24:20 +0200 Subject: [PATCH] [RTC] Make some arguments optional (part 2) day and mask pointers arguments of RTC_GetAlarm() could be NULL Fix unused variable warning Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/rtc.c | 50 ++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/cores/arduino/stm32/rtc.c b/cores/arduino/stm32/rtc.c index a4350edf1d..562d09110e 100644 --- a/cores/arduino/stm32/rtc.c +++ b/cores/arduino/stm32/rtc.c @@ -443,7 +443,12 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s if(subSeconds != NULL) { *subSeconds = RTC_TimeStruct.SubSeconds; } +#else + UNUSED(subSeconds); #endif +#else + UNUSED(period); + UNUSED(subSeconds); #endif /* !STM32F1xx */ } } @@ -581,19 +586,21 @@ void RTC_StopAlarm(void) /** * @brief Get RTC alarm - * @param day: 1-31 (day of the month) - * @param hours: 0-12 or 0-23 depends on the hours mode. + * @param day: 1-31 day of the month (optional could be NULL) + * @param hours: 0-12 or 0-23 depends on the hours mode * @param minutes: 0-59 * @param seconds: 0-59 * @param subSeconds: 0-999 (optional could be NULL) * @param period: AM or PM (optional could be NULL) + * @param mask: alarm behavior using alarmMask_t combination (optional could be NULL) + * See AN4579 Table 5 for possible values * @retval None */ 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) { RTC_AlarmTypeDef RTC_AlarmStructure; - if((day != NULL) && (hours != NULL) && (minutes != NULL) && (seconds != NULL) && (mask != NULL)) { + if((hours != NULL) && (minutes != NULL) && (seconds != NULL)) { HAL_RTC_GetAlarm(&RtcHandle, &RTC_AlarmStructure, RTC_ALARM_A, RTC_FORMAT_BIN); *seconds = RTC_AlarmStructure.AlarmTime.Seconds; @@ -601,7 +608,9 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon *hours = RTC_AlarmStructure.AlarmTime.Hours; #if !defined(STM32F1xx) - *day = RTC_AlarmStructure.AlarmDateWeekDay; + if (day != NULL) { + *day = RTC_AlarmStructure.AlarmDateWeekDay; + } if(period != NULL) { if(RTC_AlarmStructure.AlarmTime.TimeFormat == RTC_HOURFORMAT12_PM) { *period = PM; @@ -613,20 +622,29 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon if(subSeconds != NULL) { *subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds; } +#else + UNUSED(subSeconds); #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */ - *mask = OFF_MSK; - if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_SECONDS)) { - *mask |= SS_MSK; - } - if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_MINUTES)) { - *mask |= MM_MSK; - } - if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_HOURS)) { - *mask |= HH_MSK; - } - if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_DATEWEEKDAY)) { - *mask |= D_MSK; + if (mask != NULL) { + *mask = OFF_MSK; + if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_SECONDS)) { + *mask |= SS_MSK; + } + if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_MINUTES)) { + *mask |= MM_MSK; + } + if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_HOURS)) { + *mask |= HH_MSK; + } + if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_DATEWEEKDAY)) { + *mask |= D_MSK; + } } +#else + UNUSED(day); + UNUSED(period); + UNUSED(subSeconds); + UNUSED(mask); #endif /* !STM32F1xx */ } }