@@ -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+ /* Let 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 }
@@ -436,10 +437,10 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
436437 } else {
437438 * period = AM ;
438439 }
439- #if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
440+ #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
@@ -501,15 +502,16 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
501502{
502503 RTC_AlarmTypeDef RTC_AlarmStructure ;
503504
504- // Ignore time AM PM configuration if in 24 hours format
505+ /* Ignore time AM PM configuration if in 24 hours format */
505506 if (initFormat == HOUR_FORMAT_24 ) {
506507 period = AM ;
507508 }
508509
509510 if ((((initFormat == HOUR_FORMAT_24 ) && IS_RTC_HOUR24 (hours )) || IS_RTC_HOUR12 (hours ))
510511 && IS_RTC_DATE (day ) && IS_RTC_MINUTES (minutes ) && IS_RTC_SECONDS (seconds )) {
511512 /* Set RTC_AlarmStructure with calculated values*/
512- RTC_AlarmStructure .Alarm = RTC_ALARM_A ; //Use alarm A by default because it is common to all STM32 HAL.
513+ /* Use alarm A by default because it is common to all STM32 HAL */
514+ RTC_AlarmStructure .Alarm = RTC_ALARM_A ;
513515 RTC_AlarmStructure .AlarmTime .Seconds = seconds ;
514516 RTC_AlarmStructure .AlarmTime .Minutes = minutes ;
515517 RTC_AlarmStructure .AlarmTime .Hours = hours ;
@@ -519,7 +521,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
519521 RTC_AlarmStructure .AlarmTime .SubSeconds = subSeconds ;
520522#else
521523 UNUSED (subSeconds );
522- #endif
524+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
523525 if (period == PM ) {
524526 RTC_AlarmStructure .AlarmTime .TimeFormat = RTC_HOURFORMAT12_PM ;
525527 } else {
@@ -552,7 +554,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
552554 UNUSED (period );
553555 UNUSED (day );
554556 UNUSED (mask );
555- #endif // !defined( STM32F1xx)
557+ #endif /* ! STM32F1xx */
556558
557559 /* Set RTC_Alarm */
558560 HAL_RTC_SetAlarm_IT (& RtcHandle , & RTC_AlarmStructure , RTC_FORMAT_BIN );
@@ -603,7 +605,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
603605 }
604606#if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
605607 * subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
606- #endif
608+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
607609 * mask = OFF_MSK ;
608610 if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
609611 * mask |= SS_MSK ;
@@ -617,7 +619,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
617619 if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_DATEWEEKDAY )) {
618620 * mask |= D_MSK ;
619621 }
620- #endif // !defined( STM32F1xx)
622+ #endif /* ! STM32F1xx */
621623 }
622624}
623625
@@ -670,6 +672,6 @@ void RTC_Alarm_IRQHandler(void)
670672}
671673#endif
672674
673- #endif // HAL_RTC_MODULE_ENABLED
675+ #endif /* HAL_RTC_MODULE_ENABLED */
674676
675677/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments