Skip to content

Commit

Permalink
[RTC] Make some arguments optional (part 2)
Browse files Browse the repository at this point in the history
day and mask pointers arguments of RTC_GetAlarm() could be NULL

Fix unused variable warning

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed May 12, 2018
1 parent 40a553a commit cf54e13
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions cores/arduino/stm32/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
}
Expand Down Expand Up @@ -581,27 +586,31 @@ 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;
*minutes = RTC_AlarmStructure.AlarmTime.Minutes;
*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;
Expand All @@ -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 */
}
}
Expand Down

0 comments on commit cf54e13

Please sign in to comment.