@@ -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
+ /* Leave 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
}
@@ -439,7 +440,7 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
439
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
@@ -499,15 +500,16 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
499
500
{
500
501
RTC_AlarmTypeDef RTC_AlarmStructure ;
501
502
502
- // Ignore time AM PM configuration if in 24 hours format
503
+ /* Ignore time AM PM configuration if in 24 hours format */
503
504
if (initFormat == HOUR_FORMAT_24 ) {
504
505
period = AM ;
505
506
}
506
507
507
508
if ((((initFormat == HOUR_FORMAT_24 ) && IS_RTC_HOUR24 (hours )) || IS_RTC_HOUR12 (hours ))
508
509
&& IS_RTC_DATE (day ) && IS_RTC_MINUTES (minutes ) && IS_RTC_SECONDS (seconds )) {
509
510
/* 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 ;
511
513
RTC_AlarmStructure .AlarmTime .Seconds = seconds ;
512
514
RTC_AlarmStructure .AlarmTime .Minutes = minutes ;
513
515
RTC_AlarmStructure .AlarmTime .Hours = hours ;
@@ -517,7 +519,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
517
519
RTC_AlarmStructure .AlarmTime .SubSeconds = subSeconds ;
518
520
#else
519
521
UNUSED (subSeconds );
520
- #endif
522
+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
521
523
if (period == PM ) {
522
524
RTC_AlarmStructure .AlarmTime .TimeFormat = RTC_HOURFORMAT12_PM ;
523
525
} else {
@@ -550,7 +552,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
550
552
UNUSED (period );
551
553
UNUSED (day );
552
554
UNUSED (mask );
553
- #endif // !defined( STM32F1xx)
555
+ #endif /* ! STM32F1xx */
554
556
555
557
/* Set RTC_Alarm */
556
558
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
601
603
}
602
604
#if !defined(STM32F2xx ) && !defined(STM32L1xx ) || defined(STM32L1_ULPH )
603
605
* subSeconds = RTC_AlarmStructure .AlarmTime .SubSeconds ;
604
- #endif
606
+ #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
605
607
* mask = OFF_MSK ;
606
608
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
607
609
* mask |= SS_MSK ;
@@ -615,7 +617,7 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
615
617
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_DATEWEEKDAY )) {
616
618
* mask |= D_MSK ;
617
619
}
618
- #endif // !defined( STM32F1xx)
620
+ #endif /* ! STM32F1xx */
619
621
}
620
622
}
621
623
@@ -668,6 +670,6 @@ void RTC_Alarm_IRQHandler(void)
668
670
}
669
671
#endif
670
672
671
- #endif // HAL_RTC_MODULE_ENABLED
673
+ #endif /* HAL_RTC_MODULE_ENABLED */
672
674
673
675
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments