@@ -104,7 +104,7 @@ static void RTC_initClock(sourceClock_t source)
104
104
RCC_PeriphCLKInitTypeDef PeriphClkInit ;
105
105
106
106
if (source == LSE_CLOCK ) {
107
- // Enable the clock if not already set by user.
107
+ /* Enable the clock if not already set by user */
108
108
if (__HAL_RCC_GET_FLAG (RCC_FLAG_LSERDY ) == RESET ) {
109
109
#ifdef __HAL_RCC_LSEDRIVE_CONFIG
110
110
__HAL_RCC_LSEDRIVE_CONFIG (RCC_LSEDRIVE_LOW );
@@ -124,7 +124,7 @@ static void RTC_initClock(sourceClock_t source)
124
124
}
125
125
clkSrc = LSE_CLOCK ;
126
126
} 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 */
128
128
if (__HAL_RCC_GET_FLAG (RCC_FLAG_HSERDY ) == RESET ) {
129
129
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_HSE ;
130
130
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
@@ -159,10 +159,10 @@ static void RTC_initClock(sourceClock_t source)
159
159
HSEDiv = 16 ;
160
160
}
161
161
#elif defined(STM32F2xx ) || defined(STM32F4xx ) || defined(STM32F7xx )
162
- /* Not defined for STM32Fxx */
162
+ /* Not defined for STM32F2xx */
163
163
#ifndef RCC_RTCCLKSOURCE_HSE_DIVX
164
164
#define RCC_RTCCLKSOURCE_HSE_DIVX 0x00000300U
165
- #endif
165
+ #endif /* RCC_RTCCLKSOURCE_HSE_DIVX */
166
166
for (HSEDiv = 2 ; HSEDiv < 32 ; HSEDiv ++ ) {
167
167
if ((HSE_VALUE /HSEDiv ) <= HSE_RTC_MAX ) {
168
168
PeriphClkInit .RTCClockSelection = (HSEDiv <<16 ) | RCC_RTCCLKSOURCE_HSE_DIVX ;
@@ -171,7 +171,7 @@ static void RTC_initClock(sourceClock_t source)
171
171
}
172
172
#else
173
173
#error "Unknown Family - could not define RTCClockSelection"
174
- #endif
174
+ #endif /* STM32F1xx */
175
175
if ((HSE_VALUE /HSEDiv ) > HSE_RTC_MAX ) {
176
176
Error_Handler ();
177
177
}
@@ -181,7 +181,7 @@ static void RTC_initClock(sourceClock_t source)
181
181
}
182
182
clkSrc = HSE_CLOCK ;
183
183
} 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 */
185
185
if (__HAL_RCC_GET_FLAG (RCC_FLAG_LSIRDY ) == RESET ) {
186
186
RCC_OscInitStruct .OscillatorType = RCC_OSCILLATORTYPE_LSI ;
187
187
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ;
@@ -261,12 +261,12 @@ static void RTC_computePrediv(int8_t *asynch, int16_t *synch)
261
261
uint32_t predivS = PREDIVS_MAX + 1 ;
262
262
uint32_t clk = 0 ;
263
263
264
- // Get user predividers if manually configured
264
+ /* Get user predividers if manually configured */
265
265
if ((asynch == NULL ) || (synch == NULL )) {
266
266
return ;
267
267
}
268
268
269
- // Get clock frequency
269
+ /* Get clock frequency */
270
270
if (clkSrc == LSE_CLOCK ) {
271
271
clk = LSE_VALUE ;
272
272
}
@@ -314,13 +314,14 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
314
314
{
315
315
initFormat = format ;
316
316
317
- // Init RTC clock
317
+ /* Init RTC clock */
318
318
RTC_initClock (source );
319
319
320
320
RtcHandle .Instance = RTC ;
321
321
322
322
#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 ;
324
325
RtcHandle .Init .OutPut = RTC_OUTPUTSOURCE_NONE ;
325
326
UNUSED (format );
326
327
#else
@@ -333,10 +334,10 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
333
334
RTC_getPrediv ((int8_t * )& (RtcHandle .Init .AsynchPrediv ), (int16_t * )& (RtcHandle .Init .SynchPrediv ));
334
335
#if defined(STM32L0xx ) || defined(STM32L4xx )
335
336
RtcHandle .Init .OutPutRemap = RTC_OUTPUT_REMAP_NONE ;
336
- #endif // defined( STM32L0xx) || defined( STM32L4xx)
337
+ #endif /* STM32L0xx || STM32L4xx */
337
338
RtcHandle .Init .OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH ;
338
339
RtcHandle .Init .OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN ;
339
- #endif // defined( STM32F1xx)
340
+ #endif /* STM32F1xx */
340
341
341
342
HAL_RTC_Init ( & RtcHandle );
342
343
@@ -347,9 +348,9 @@ void RTC_init(hourFormat_t format, sourceClock_t source)
347
348
RTC_SetTime (0 ,0 ,0 ,0 ,AM );
348
349
349
350
#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) */
351
352
HAL_RTCEx_EnableBypassShadow (& RtcHandle );
352
- #endif // !defined( STM32F1xx) && !defined( STM32F2xx)
353
+ #endif /* ! STM32F1xx && !STM32F2xx */
353
354
354
355
HAL_NVIC_SetPriority (RTC_Alarm_IRQn , 2 , 0 );
355
356
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
379
380
{
380
381
RTC_TimeTypeDef RTC_TimeStruct ;
381
382
382
- // Ignore time AM PM configuration if in 24 hours format
383
+ /* Ignore time AM PM configuration if in 24 hours format */
383
384
if (initFormat == HOUR_FORMAT_24 ) {
384
385
period = AM ;
385
386
}
@@ -400,13 +401,13 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
400
401
RTC_TimeStruct .SecondFraction = 0 ;
401
402
#else
402
403
UNUSED (subSeconds );
403
- #endif //!defined( STM32F2xx) && !defined( STM32L1xx) || defined( STM32L1_ULPH)
404
+ #endif /* ! STM32F2xx && !STM32L1xx || STM32L1_ULPH */
404
405
RTC_TimeStruct .DayLightSaving = RTC_STOREOPERATION_RESET ;
405
406
RTC_TimeStruct .StoreOperation = RTC_DAYLIGHTSAVING_NONE ;
406
407
#else
407
408
UNUSED (subSeconds );
408
409
UNUSED (period );
409
- #endif // !defined( STM32F1xx)
410
+ #endif /* ! STM32F1xx */
410
411
411
412
HAL_RTC_SetTime (& RtcHandle , & RTC_TimeStruct , RTC_FORMAT_BIN );
412
413
}
@@ -436,10 +437,10 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
436
437
} else {
437
438
* period = AM ;
438
439
}
439
- #if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
440
+ #if ( !defined(STM32F2xx ) && !defined(STM32L1xx ) ) || defined(STM32L1_ULPH )
440
441
* subSeconds = RTC_TimeStruct .SubSeconds ;
441
442
#endif
442
- #endif // !defined( STM32F1xx)
443
+ #endif /* ! STM32F1xx */
443
444
}
444
445
}
445
446
@@ -501,15 +502,16 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
501
502
{
502
503
RTC_AlarmTypeDef RTC_AlarmStructure ;
503
504
504
- // Ignore time AM PM configuration if in 24 hours format
505
+ /* Ignore time AM PM configuration if in 24 hours format */
505
506
if (initFormat == HOUR_FORMAT_24 ) {
506
507
period = AM ;
507
508
}
508
509
509
510
if ((((initFormat == HOUR_FORMAT_24 ) && IS_RTC_HOUR24 (hours )) || IS_RTC_HOUR12 (hours ))
510
511
&& IS_RTC_DATE (day ) && IS_RTC_MINUTES (minutes ) && IS_RTC_SECONDS (seconds )) {
511
512
/* 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 ;
513
515
RTC_AlarmStructure .AlarmTime .Seconds = seconds ;
514
516
RTC_AlarmStructure .AlarmTime .Minutes = minutes ;
515
517
RTC_AlarmStructure .AlarmTime .Hours = hours ;
@@ -519,7 +521,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
519
521
RTC_AlarmStructure .AlarmTime .SubSeconds = subSeconds ;
520
522
#else
521
523
UNUSED (subSeconds );
522
- #endif
524
+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
523
525
if (period == PM ) {
524
526
RTC_AlarmStructure .AlarmTime .TimeFormat = RTC_HOURFORMAT12_PM ;
525
527
} else {
@@ -552,7 +554,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
552
554
UNUSED (period );
553
555
UNUSED (day );
554
556
UNUSED (mask );
555
- #endif // !defined( STM32F1xx)
557
+ #endif /* ! STM32F1xx */
556
558
557
559
/* Set RTC_Alarm */
558
560
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
603
605
}
604
606
#if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
605
607
* subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
606
- #endif
608
+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
607
609
* mask = OFF_MSK ;
608
610
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
609
611
* mask |= SS_MSK ;
@@ -617,7 +619,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
617
619
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_DATEWEEKDAY )) {
618
620
* mask |= D_MSK ;
619
621
}
620
- #endif // !defined( STM32F1xx)
622
+ #endif /* ! STM32F1xx */
621
623
}
622
624
}
623
625
@@ -670,6 +672,6 @@ void RTC_Alarm_IRQHandler(void)
670
672
}
671
673
#endif
672
674
673
- #endif // HAL_RTC_MODULE_ENABLED
675
+ #endif /* HAL_RTC_MODULE_ENABLED */
674
676
675
677
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments