Skip to content

Commit 6df1af8

Browse files
committed
Rename parameters to avoid any confusion
day -> wday is a week day (1 to 7) date -> day is day (1 to 31). Mainly named "date" in HAL side format -> period is day period AM or PM. Mainly named "time format" in HAL side Signed-off-by: Frederic.Pillon <[email protected]>
1 parent ff77ff9 commit 6df1af8

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

cores/arduino/stm32/rtc.c

+38-38
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,16 @@ void RTC_DeInit(void)
423423
* @param minutes: 0-59
424424
* @param seconds: 0-59
425425
* @param subSeconds: 0-999
426-
* @param format: select AM or PM format in case RTC is set in 12 hours mode. Else ingored.
426+
* @param period: select AM or PM period in case RTC is set in 12 hours mode. Else ingored.
427427
* @retval None
428428
*/
429-
void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t format)
429+
void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t period)
430430
{
431431
RTC_TimeTypeDef RTC_TimeStruct;
432432

433433
// Ignore time AM PM configuration if in 24 hours format
434434
if(initFormat == HOUR_FORMAT_24) {
435-
format = AM;
435+
period = AM;
436436
}
437437

438438
if((((initFormat == HOUR_FORMAT_24) && IS_RTC_HOUR24(hours)) || IS_RTC_HOUR12(hours))
@@ -441,7 +441,7 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
441441
RTC_TimeStruct.Minutes = minutes;
442442
RTC_TimeStruct.Seconds = seconds;
443443
#if !defined(STM32F1xx)
444-
if(format == PM) {
444+
if(period == PM) {
445445
RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT12_PM;
446446
} else {
447447
RTC_TimeStruct.TimeFormat = RTC_HOURFORMAT12_AM;
@@ -456,7 +456,7 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
456456
RTC_TimeStruct.StoreOperation = RTC_DAYLIGHTSAVING_NONE;
457457
#else
458458
UNUSED(subSeconds);
459-
UNUSED(format);
459+
UNUSED(period);
460460
#endif // !defined(STM32F1xx)
461461

462462
HAL_RTC_SetTime(&RtcHandle , &RTC_TimeStruct, RTC_FORMAT_BIN);
@@ -469,23 +469,23 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
469469
* @param minutes: 0-59
470470
* @param seconds: 0-59
471471
* @param subSeconds: 0-999
472-
* @param format: returns AM or PM format in case RTC is set in 12 hours mode.
472+
* @param period: returns AM or PM period in case RTC is set in 12 hours mode.
473473
* @retval None
474474
*/
475-
void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *format)
475+
void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *period)
476476
{
477477
RTC_TimeTypeDef RTC_TimeStruct;
478478

479-
if((hours != NULL) && (minutes != NULL) && (seconds != NULL) && (subSeconds != NULL) && (format != NULL)) {
479+
if((hours != NULL) && (minutes != NULL) && (seconds != NULL) && (subSeconds != NULL) && (period != NULL)) {
480480
HAL_RTC_GetTime(&RtcHandle , &RTC_TimeStruct, RTC_FORMAT_BIN);
481481
*hours = RTC_TimeStruct.Hours;
482482
*minutes = RTC_TimeStruct.Minutes;
483483
*seconds = RTC_TimeStruct.Seconds;
484484
#if !defined(STM32F1xx)
485485
if(RTC_TimeStruct.TimeFormat == RTC_HOURFORMAT12_PM) {
486-
*format = PM;
486+
*period = PM;
487487
} else {
488-
*format = AM;
488+
*period = AM;
489489
}
490490
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
491491
*subSeconds = RTC_TimeStruct.SubSeconds;
@@ -498,19 +498,19 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
498498
* @brief Set RTC calendar
499499
* @param year: 0-99
500500
* @param month: 1-12
501-
* @param date: 1-31
502-
* @param day: 1-7
501+
* @param day: 1-31
502+
* @param wday: 1-7
503503
* @retval None
504504
*/
505-
void RTC_SetDate(uint8_t year, uint8_t month, uint8_t date, uint8_t day)
505+
void RTC_SetDate(uint8_t year, uint8_t month, uint8_t day, uint8_t wday)
506506
{
507507
RTC_DateTypeDef RTC_DateStruct;
508508

509-
if(IS_RTC_YEAR(year) && IS_RTC_MONTH(month) && IS_RTC_DATE(date) && IS_RTC_WEEKDAY(day)) {
509+
if(IS_RTC_YEAR(year) && IS_RTC_MONTH(month) && IS_RTC_DATE(day) && IS_RTC_WEEKDAY(wday)) {
510510
RTC_DateStruct.Year = year;
511511
RTC_DateStruct.Month = month;
512-
RTC_DateStruct.Date = date;
513-
RTC_DateStruct.WeekDay = day;
512+
RTC_DateStruct.Date = day;
513+
RTC_DateStruct.WeekDay = wday;
514514
HAL_RTC_SetDate(&RtcHandle , &RTC_DateStruct, RTC_FORMAT_BIN);
515515
}
516516
}
@@ -519,44 +519,44 @@ void RTC_SetDate(uint8_t year, uint8_t month, uint8_t date, uint8_t day)
519519
* @brief Get RTC calendar
520520
* @param year: 0-99
521521
* @param month: 1-12
522-
* @param date: 1-31
523-
* @param day: 1-7
522+
* @param day: 1-31
523+
* @param wday: 1-7
524524
* @retval None
525525
*/
526-
void RTC_GetDate(uint8_t *year, uint8_t *month, uint8_t *date, uint8_t *day)
526+
void RTC_GetDate(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *wday)
527527
{
528528
RTC_DateTypeDef RTC_DateStruct;
529529

530-
if((year != NULL) && (month != NULL) && (date != NULL) && (day != NULL)) {
530+
if((year != NULL) && (month != NULL) && (day != NULL) && (wday != NULL)) {
531531
HAL_RTC_GetDate(&RtcHandle, &RTC_DateStruct, RTC_FORMAT_BIN);
532532
*year = RTC_DateStruct.Year;
533533
*month = RTC_DateStruct.Month;
534-
*date = RTC_DateStruct.Date;
535-
*day = RTC_DateStruct.WeekDay;
534+
*day = RTC_DateStruct.Date;
535+
*wday = RTC_DateStruct.WeekDay;
536536
}
537537
}
538538

539539
/**
540540
* @brief Set RTC alarm and activate it with IT mode
541-
* @param date: 1-31 (day of the month)
541+
* @param day: 1-31 (day of the month)
542542
* @param hours: 0-12 or 0-23 depends on the hours mode.
543543
* @param minutes: 0-59
544544
* @param seconds: 0-59
545545
* @param subSeconds: 0-999
546-
* @param hours format: AM or PM if in 12 hours mode else ignored.
546+
* @param period: AM or PM if in 12 hours mode else ignored.
547547
* @retval None
548548
*/
549-
void RTC_StartAlarm(uint8_t date, uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t format)
549+
void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t period)
550550
{
551551
RTC_AlarmTypeDef RTC_AlarmStructure;
552552

553553
// Ignore time AM PM configuration if in 24 hours format
554554
if(initFormat == HOUR_FORMAT_24) {
555-
format = AM;
555+
period = AM;
556556
}
557557

558558
if((((initFormat == HOUR_FORMAT_24) && IS_RTC_HOUR24(hours)) || IS_RTC_HOUR12(hours))
559-
&& IS_RTC_DATE(date) && IS_RTC_MINUTES(minutes) && IS_RTC_SECONDS(seconds)) {
559+
&& IS_RTC_DATE(day) && IS_RTC_MINUTES(minutes) && IS_RTC_SECONDS(seconds)) {
560560
/* Set RTC_AlarmStructure with calculated values*/
561561
RTC_AlarmStructure.Alarm = RTC_ALARM_A; //Use alarm A by default because it is common to all STM32 HAL.
562562
RTC_AlarmStructure.AlarmTime.Seconds = seconds;
@@ -569,20 +569,20 @@ void RTC_StartAlarm(uint8_t date, uint8_t hours, uint8_t minutes, uint8_t second
569569
#else
570570
UNUSED(subSeconds);
571571
#endif
572-
if(format == PM) {
572+
if(period == PM) {
573573
RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_HOURFORMAT12_PM;
574574
} else {
575575
RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_HOURFORMAT12_AM;
576576
}
577577
RTC_AlarmStructure.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
578578
RTC_AlarmStructure.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
579-
RTC_AlarmStructure.AlarmDateWeekDay = date;
579+
RTC_AlarmStructure.AlarmDateWeekDay = day;
580580
RTC_AlarmStructure.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
581581
RTC_AlarmStructure.AlarmMask = RTC_ALARMMASK_NONE;
582582
#else
583583
UNUSED(subSeconds);
584-
UNUSED(format);
585-
UNUSED(date);
584+
UNUSED(period);
585+
UNUSED(day);
586586
#endif // !defined(STM32F1xx)
587587

588588
/* Set RTC_Alarm */
@@ -606,30 +606,30 @@ void RTC_StopAlarm(void)
606606

607607
/**
608608
* @brief Get RTC alarm
609-
* @param date: 1-31 (day of the month)
609+
* @param day: 1-31 (day of the month)
610610
* @param hours: 0-12 or 0-23 depends on the hours mode.
611611
* @param minutes: 0-59
612612
* @param seconds: 0-59
613613
* @param subSeconds: 0-999
614-
* @param hours format: AM or PM
614+
* @param period: AM or PM
615615
* @retval None
616616
*/
617-
void RTC_GetAlarm(uint8_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *format)
617+
void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *period)
618618
{
619619
RTC_AlarmTypeDef RTC_AlarmStructure;
620620

621-
if((date != NULL) && (hours != NULL) && (minutes != NULL) && (seconds != NULL) && (subSeconds != NULL) && (format != NULL)) {
621+
if((day != NULL) && (hours != NULL) && (minutes != NULL) && (seconds != NULL) && (subSeconds != NULL) && (period != NULL)) {
622622
HAL_RTC_GetAlarm(&RtcHandle, &RTC_AlarmStructure, RTC_ALARM_A, RTC_FORMAT_BIN);
623623

624624
*seconds = RTC_AlarmStructure.AlarmTime.Seconds;
625625
*minutes = RTC_AlarmStructure.AlarmTime.Minutes;
626626
*hours = RTC_AlarmStructure.AlarmTime.Hours;
627627
#if !defined(STM32F1xx)
628-
*date = RTC_AlarmStructure.AlarmDateWeekDay;
628+
*day = RTC_AlarmStructure.AlarmDateWeekDay;
629629
if(RTC_AlarmStructure.AlarmTime.TimeFormat == RTC_HOURFORMAT12_PM) {
630-
*format = PM;
630+
*period = PM;
631631
} else {
632-
*format = AM;
632+
*period = AM;
633633
}
634634
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
635635
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;

cores/arduino/stm32/rtc.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ void RTC_setPrediv(int8_t Asynch, int16_t Synch);
116116
void RTC_init(hourFormat_t format, sourceClock_t source);
117117
void RTC_DeInit(void);
118118

119-
void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t format);
120-
void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *format);
119+
void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t period);
120+
void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *period);
121121

122-
void RTC_SetDate(uint8_t year, uint8_t month, uint8_t date, uint8_t day);
123-
void RTC_GetDate(uint8_t *year, uint8_t *month, uint8_t *date, uint8_t *day);
122+
void RTC_SetDate(uint8_t year, uint8_t month, uint8_t day, uint8_t wday);
123+
void RTC_GetDate(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *wday);
124124

125-
void RTC_StartAlarm(uint8_t date, uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t format);
125+
void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds, hourAM_PM_t period);
126126
void RTC_StopAlarm(void);
127-
void RTC_GetAlarm(uint8_t *date, uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *format);
127+
void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *subSeconds, hourAM_PM_t *period);
128128
void attachAlarmCallback(voidCallbackPtr func, void *data);
129129
void detachAlarmCallback(void);
130130

0 commit comments

Comments
 (0)