Skip to content

Commit 6163660

Browse files
committed
Cosmetic update
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 4a1acf1 commit 6163660

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

cores/arduino/stm32/rtc.c

+27-25
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void RTC_initClock(sourceClock_t source)
104104
RCC_PeriphCLKInitTypeDef PeriphClkInit;
105105

106106
if(source == LSE_CLOCK) {
107-
// Enable the clock if not already set by user.
107+
/* Enable the clock if not already set by user */
108108
if(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) {
109109
#ifdef __HAL_RCC_LSEDRIVE_CONFIG
110110
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
@@ -124,7 +124,7 @@ static void RTC_initClock(sourceClock_t source)
124124
}
125125
clkSrc = LSE_CLOCK;
126126
} else if(source == HSE_CLOCK) {
127-
// Enable the clock if not already set by user.
127+
/* Enable the clock if not already set by user */
128128
if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) {
129129
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
130130
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
@@ -159,10 +159,10 @@ static void RTC_initClock(sourceClock_t source)
159159
HSEDiv = 16;
160160
}
161161
#elif defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
162-
/* Not defined for STM32Fxx */
162+
/* Not defined for STM32F2xx */
163163
#ifndef RCC_RTCCLKSOURCE_HSE_DIVX
164164
#define RCC_RTCCLKSOURCE_HSE_DIVX 0x00000300U
165-
#endif
165+
#endif /* RCC_RTCCLKSOURCE_HSE_DIVX */
166166
for(HSEDiv = 2; HSEDiv<32; HSEDiv++) {
167167
if((HSE_VALUE/HSEDiv) <= HSE_RTC_MAX) {
168168
PeriphClkInit.RTCClockSelection = (HSEDiv<<16) | RCC_RTCCLKSOURCE_HSE_DIVX;
@@ -171,7 +171,7 @@ static void RTC_initClock(sourceClock_t source)
171171
}
172172
#else
173173
#error "Unknown Family - could not define RTCClockSelection"
174-
#endif
174+
#endif /* STM32F1xx */
175175
if((HSE_VALUE/HSEDiv) > HSE_RTC_MAX) {
176176
Error_Handler();
177177
}
@@ -181,7 +181,7 @@ static void RTC_initClock(sourceClock_t source)
181181
}
182182
clkSrc = HSE_CLOCK;
183183
} else if(source == LSI_CLOCK) {
184-
// Enable the clock if not already set by user.
184+
/* Enable the clock if not already set by user */
185185
if(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET) {
186186
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
187187
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
@@ -261,12 +261,12 @@ static void RTC_computePrediv(int8_t *asynch, int16_t *synch)
261261
uint32_t predivS = PREDIVS_MAX + 1;
262262
uint32_t clk = 0;
263263

264-
// Get user predividers if manually configured
264+
/* Get user predividers if manually configured */
265265
if((asynch == NULL) || (synch == NULL)) {
266266
return;
267267
}
268268

269-
// Get clock frequency
269+
/* Get clock frequency */
270270
if(clkSrc == LSE_CLOCK) {
271271
clk = LSE_VALUE;
272272
}
@@ -314,13 +314,14 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
314314
{
315315
initFormat = format;
316316

317-
// Init RTC clock
317+
/* Init RTC clock */
318318
RTC_initClock(source);
319319

320320
RtcHandle.Instance = RTC;
321321

322322
#if defined(STM32F1xx)
323-
RtcHandle.Init.AsynchPrediv = RTC_AUTO_1_SECOND; //Leave HAL calculate the prescaler
323+
/* Leave HAL calculate the prescaler */
324+
RtcHandle.Init.AsynchPrediv = RTC_AUTO_1_SECOND;
324325
RtcHandle.Init.OutPut = RTC_OUTPUTSOURCE_NONE;
325326
UNUSED(format);
326327
#else
@@ -333,10 +334,10 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
333334
RTC_getPrediv((int8_t*)&(RtcHandle.Init.AsynchPrediv), (int16_t*)&(RtcHandle.Init.SynchPrediv));
334335
#if defined(STM32L0xx) || defined(STM32L4xx)
335336
RtcHandle.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
336-
#endif // defined(STM32L0xx) || defined(STM32L4xx)
337+
#endif /* STM32L0xx || STM32L4xx */
337338
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
338339
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
339-
#endif // defined(STM32F1xx)
340+
#endif /* STM32F1xx */
340341

341342
HAL_RTC_Init( &RtcHandle );
342343

@@ -347,9 +348,9 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
347348
RTC_SetTime(0,0,0,0,AM);
348349

349350
#if !defined(STM32F1xx) && !defined(STM32F2xx)
350-
/*Enable Direct Read of the calendar registers (not through Shadow) */
351+
/* Enable Direct Read of the calendar registers (not through Shadow) */
351352
HAL_RTCEx_EnableBypassShadow(&RtcHandle);
352-
#endif // !defined(STM32F1xx) && !defined(STM32F2xx)
353+
#endif /* !STM32F1xx && !STM32F2xx */
353354

354355
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 2, 0);
355356
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
@@ -379,7 +380,7 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
379380
{
380381
RTC_TimeTypeDef RTC_TimeStruct;
381382

382-
// Ignore time AM PM configuration if in 24 hours format
383+
/* Ignore time AM PM configuration if in 24 hours format */
383384
if(initFormat == HOUR_FORMAT_24) {
384385
period = AM;
385386
}
@@ -400,13 +401,13 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
400401
RTC_TimeStruct.SecondFraction = 0;
401402
#else
402403
UNUSED(subSeconds);
403-
#endif //!defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
404+
#endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
404405
RTC_TimeStruct.DayLightSaving = RTC_STOREOPERATION_RESET;
405406
RTC_TimeStruct.StoreOperation = RTC_DAYLIGHTSAVING_NONE;
406407
#else
407408
UNUSED(subSeconds);
408409
UNUSED(period);
409-
#endif // !defined(STM32F1xx)
410+
#endif /* !STM32F1xx */
410411

411412
HAL_RTC_SetTime(&RtcHandle , &RTC_TimeStruct, RTC_FORMAT_BIN);
412413
}
@@ -439,7 +440,7 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
439440
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
440441
*subSeconds = RTC_TimeStruct.SubSeconds;
441442
#endif
442-
#endif // !defined(STM32F1xx)
443+
#endif /* !STM32F1xx */
443444
}
444445
}
445446

@@ -499,15 +500,16 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
499500
{
500501
RTC_AlarmTypeDef RTC_AlarmStructure;
501502

502-
// Ignore time AM PM configuration if in 24 hours format
503+
/* Ignore time AM PM configuration if in 24 hours format */
503504
if(initFormat == HOUR_FORMAT_24) {
504505
period = AM;
505506
}
506507

507508
if((((initFormat == HOUR_FORMAT_24) && IS_RTC_HOUR24(hours)) || IS_RTC_HOUR12(hours))
508509
&& IS_RTC_DATE(day) && IS_RTC_MINUTES(minutes) && IS_RTC_SECONDS(seconds)) {
509510
/* Set RTC_AlarmStructure with calculated values*/
510-
RTC_AlarmStructure.Alarm = RTC_ALARM_A; //Use alarm A by default because it is common to all STM32 HAL.
511+
/* Use alarm A by default because it is common to all STM32 HAL */
512+
RTC_AlarmStructure.Alarm = RTC_ALARM_A;
511513
RTC_AlarmStructure.AlarmTime.Seconds = seconds;
512514
RTC_AlarmStructure.AlarmTime.Minutes = minutes;
513515
RTC_AlarmStructure.AlarmTime.Hours = hours;
@@ -517,7 +519,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
517519
RTC_AlarmStructure.AlarmTime.SubSeconds = subSeconds;
518520
#else
519521
UNUSED(subSeconds);
520-
#endif
522+
#endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
521523
if(period == PM) {
522524
RTC_AlarmStructure.AlarmTime.TimeFormat = RTC_HOURFORMAT12_PM;
523525
} else {
@@ -550,7 +552,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
550552
UNUSED(period);
551553
UNUSED(day);
552554
UNUSED(mask);
553-
#endif // !defined(STM32F1xx)
555+
#endif /* !STM32F1xx */
554556

555557
/* Set RTC_Alarm */
556558
HAL_RTC_SetAlarm_IT(&RtcHandle, &RTC_AlarmStructure, RTC_FORMAT_BIN);
@@ -601,7 +603,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
601603
}
602604
#if !defined(STM32F2xx) && !defined(STM32L1xx) || defined(STM32L1_ULPH)
603605
*subSeconds = RTC_AlarmStructure.AlarmTime.SubSeconds;
604-
#endif
606+
#endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
605607
*mask = OFF_MSK;
606608
if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_SECONDS)) {
607609
*mask |= SS_MSK;
@@ -615,7 +617,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
615617
if(!(RTC_AlarmStructure.AlarmMask & RTC_ALARMMASK_DATEWEEKDAY)) {
616618
*mask |= D_MSK;
617619
}
618-
#endif // !defined(STM32F1xx)
620+
#endif /* !STM32F1xx */
619621
}
620622
}
621623

@@ -668,6 +670,6 @@ void RTC_Alarm_IRQHandler(void)
668670
}
669671
#endif
670672

671-
#endif // HAL_RTC_MODULE_ENABLED
673+
#endif /* HAL_RTC_MODULE_ENABLED */
672674

673675
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

cores/arduino/stm32/rtc.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ typedef enum {
7171
Y_MSK = 32
7272
} alarmMask_t;
7373

74-
// Clock source selection
74+
/* Clock source selection */
7575
typedef enum {
7676
LSI_CLOCK,
7777
LSE_CLOCK,
@@ -105,11 +105,11 @@ typedef void(*voidCallbackPtr)(void *);
105105

106106
#if defined(STM32F0xx) || defined(STM32L0xx)
107107
#define RTC_Alarm_IRQn RTC_IRQn
108-
#define RTC_Alarm_IRQHandler RTC_IRQHandler
108+
#define RTC_Alarm_IRQHandler RTC_IRQHandler
109109
#endif
110110

111111
#if defined(STM32F1xx) && !defined(IS_RTC_WEEKDAY)
112-
// Compensate missing HAL definition
112+
/* Compensate missing HAL definition */
113113
#define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY) || \
114114
((WEEKDAY) == RTC_WEEKDAY_TUESDAY) || \
115115
((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
@@ -118,11 +118,11 @@ typedef void(*voidCallbackPtr)(void *);
118118
((WEEKDAY) == RTC_WEEKDAY_SATURDAY) || \
119119
((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
120120

121-
//F1 doesn't manage 12h format.
121+
/* F1 doesn't manage 12h format */
122122
#define IS_RTC_HOUR12(HOUR) IS_RTC_HOUR24(HOUR)
123-
#endif // defined(STM32F1xx) && !defined(IS_RTC_WEEKDAY)
123+
#endif /* !STM32F1xx && !IS_RTC_WEEKDAY */
124124

125-
// __HAL_RCC_GET_RTC_SOURCE is not defined for F2 and F4
125+
/* __HAL_RCC_GET_RTC_SOURCE is not defined for F2 and F4 */
126126
#ifndef __HAL_RCC_GET_RTC_SOURCE
127127
static uint32_t RTC_getSource(void) {
128128
RCC_PeriphCLKInitTypeDef *PeriphClkInit;
@@ -158,7 +158,7 @@ void detachAlarmCallback(void);
158158
}
159159
#endif
160160

161-
#endif // HAL_RTC_MODULE_ENABLED
161+
#endif /* HAL_RTC_MODULE_ENABLED */
162162

163163
#endif /* __RTC_H */
164164

0 commit comments

Comments
 (0)