@@ -138,12 +138,10 @@ static void RTC_initClock(sourceClock_t source)
138
138
/* HSE max is 16 MHZ divided by 128 --> 125 KHz */
139
139
PeriphClkInit .RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV128 ;
140
140
HSEDiv = 128 ;
141
- #elif defined(STM32F0xx ) || defined(STM32F3xx ) || defined(STM32G0xx ) || \
142
- defined(STM32G4xx ) || defined(STM32L4xx ) || defined(STM32L5xx ) || \
143
- defined(STM32WBxx )
141
+ #elif defined(RCC_RTCCLKSOURCE_HSE_DIV32 ) && !defined(RCC_RTCCLKSOURCE_HSE_DIV31 )
144
142
PeriphClkInit .RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV32 ;
145
143
HSEDiv = 32 ;
146
- #elif defined(STM32L0xx ) || defined( STM32L1xx )
144
+ #elif ! defined(RCC_RTCCLKSOURCE_HSE_DIV31 )
147
145
if ((HSE_VALUE / 2 ) <= HSE_RTC_MAX ) {
148
146
PeriphClkInit .RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV2 ;
149
147
HSEDiv = 2 ;
@@ -157,12 +155,12 @@ static void RTC_initClock(sourceClock_t source)
157
155
PeriphClkInit .RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV16 ;
158
156
HSEDiv = 16 ;
159
157
}
160
- #elif defined(STM32F2xx ) || defined( STM32F4xx ) || defined( STM32F7xx ) || defined( STM32H7xx )
158
+ #elif defined(RCC_RTCCLKSOURCE_HSE_DIV31 )
161
159
/* Not defined for STM32F2xx */
162
160
#ifndef RCC_RTCCLKSOURCE_HSE_DIVX
163
161
#define RCC_RTCCLKSOURCE_HSE_DIVX 0x00000300U
164
162
#endif /* RCC_RTCCLKSOURCE_HSE_DIVX */
165
- #if defined(STM32H7xx )
163
+ #if defined(RCC_RTCCLKSOURCE_HSE_DIV63 )
166
164
#define HSEDIV_MAX 64
167
165
#define HSESHIFT 12
168
166
#else
@@ -176,7 +174,7 @@ static void RTC_initClock(sourceClock_t source)
176
174
}
177
175
}
178
176
#else
179
- #error "Unknown Family - could not define RTCClockSelection"
177
+ #error "Could not define RTCClockSelection"
180
178
#endif /* STM32F1xx */
181
179
if ((HSE_VALUE / HSEDiv ) > HSE_RTC_MAX ) {
182
180
Error_Handler ();
@@ -340,19 +338,19 @@ void RTC_init(hourFormat_t format, sourceClock_t source, bool reset)
340
338
}
341
339
RtcHandle .Init .OutPut = RTC_OUTPUT_DISABLE ;
342
340
RTC_getPrediv ((int8_t * ) & (RtcHandle .Init .AsynchPrediv ), (int16_t * ) & (RtcHandle .Init .SynchPrediv ));
343
- #if defined(STM32G0xx ) || defined( STM32H7xx ) || defined( STM32L0xx ) || defined( STM32L4xx ) || defined( STM32L5xx )
341
+ #if defined(RTC_OUTPUT_REMAP_NONE )
344
342
RtcHandle .Init .OutPutRemap = RTC_OUTPUT_REMAP_NONE ;
345
- #endif /* STM32H7xx || STM32L0xx || STM32L4xx || STM32L5xx */
343
+ #endif /* RTC_OUTPUT_REMAP_NONE */
346
344
RtcHandle .Init .OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH ;
347
345
RtcHandle .Init .OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN ;
348
346
#endif /* STM32F1xx */
349
347
350
348
HAL_RTC_Init (& RtcHandle );
351
349
352
- #if ! defined(STM32F1xx ) && !defined( STM32F2xx ) && !defined( STM32L1xx ) || defined( STM32L1_ULPH )
350
+ #if defined(RTC_CR_BYPSHAD )
353
351
/* Enable Direct Read of the calendar registers (not through Shadow) */
354
352
HAL_RTCEx_EnableBypassShadow (& RtcHandle );
355
- #endif /* !STM32F1xx && !STM32F2xx */
353
+ #endif
356
354
357
355
HAL_NVIC_SetPriority (RTC_Alarm_IRQn , RTC_IRQ_PRIO , RTC_IRQ_SUBPRIO );
358
356
HAL_NVIC_EnableIRQ (RTC_Alarm_IRQn );
@@ -409,11 +407,11 @@ void RTC_SetTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSe
409
407
} else {
410
408
RTC_TimeStruct .TimeFormat = RTC_HOURFORMAT12_AM ;
411
409
}
412
- #if ! defined(STM32F2xx ) && !defined( STM32L1xx ) || defined( STM32L1_ULPH )
410
+ #if defined(RTC_SSR_SS )
413
411
/* subSeconds is read only, so no need to set it */
414
412
/*RTC_TimeStruct.SubSeconds = subSeconds;*/
415
413
/*RTC_TimeStruct.SecondFraction = 0;*/
416
- #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
414
+ #endif /* RTC_SSR_SS */
417
415
RTC_TimeStruct .DayLightSaving = RTC_STOREOPERATION_RESET ;
418
416
RTC_TimeStruct .StoreOperation = RTC_DAYLIGHTSAVING_NONE ;
419
417
#else
@@ -451,13 +449,13 @@ void RTC_GetTime(uint8_t *hours, uint8_t *minutes, uint8_t *seconds, uint32_t *s
451
449
* period = HOUR_AM ;
452
450
}
453
451
}
454
- #if (! defined(STM32F2xx ) && !defined( STM32L1xx )) || defined( STM32L1_ULPH )
452
+ #if defined(RTC_SSR_SS )
455
453
if (subSeconds != NULL ) {
456
454
* subSeconds = ((predivSync - RTC_TimeStruct .SubSeconds ) * 1000 ) / (predivSync + 1 );
457
455
}
458
456
#else
459
457
UNUSED (subSeconds );
460
- #endif
458
+ #endif /* RTC_SSR_SS */
461
459
#else
462
460
UNUSED (period );
463
461
UNUSED (subSeconds );
@@ -538,7 +536,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
538
536
RTC_AlarmStructure .AlarmTime .Minutes = minutes ;
539
537
RTC_AlarmStructure .AlarmTime .Hours = hours ;
540
538
#if !defined(STM32F1xx )
541
- #if ! defined(STM32F2xx ) && !defined( STM32L1xx ) || defined( STM32L1_ULPH )
539
+ #if defined(RTC_SSR_SS )
542
540
if (subSeconds < 1000 ) {
543
541
RTC_AlarmStructure .AlarmSubSecondMask = predivSync_bits << RTC_ALRMASSR_MASKSS_Pos ;
544
542
RTC_AlarmStructure .AlarmTime .SubSeconds = predivSync - (subSeconds * (predivSync + 1 )) / 1000 ;
@@ -547,7 +545,7 @@ void RTC_StartAlarm(uint8_t day, uint8_t hours, uint8_t minutes, uint8_t seconds
547
545
}
548
546
#else
549
547
UNUSED (subSeconds );
550
- #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
548
+ #endif /* RTC_SSR_SS */
551
549
if (period == HOUR_PM ) {
552
550
RTC_AlarmStructure .AlarmTime .TimeFormat = RTC_HOURFORMAT12_PM ;
553
551
} else {
@@ -635,13 +633,13 @@ void RTC_GetAlarm(uint8_t *day, uint8_t *hours, uint8_t *minutes, uint8_t *secon
635
633
* period = HOUR_AM ;
636
634
}
637
635
}
638
- #if ! defined(STM32F2xx ) && !defined( STM32L1xx ) || defined( STM32L1_ULPH )
636
+ #if defined(RTC_SSR_SS )
639
637
if (subSeconds != NULL ) {
640
638
* subSeconds = ((predivSync - RTC_AlarmStructure .AlarmTime .SubSeconds ) * 1000 ) / (predivSync + 1 );
641
639
}
642
640
#else
643
641
UNUSED (subSeconds );
644
- #endif /* !STM32F2xx && !STM32L1xx || STM32L1_ULPH */
642
+ #endif /* RTC_SSR_SS */
645
643
if (mask != NULL ) {
646
644
* mask = OFF_MSK ;
647
645
if (!(RTC_AlarmStructure .AlarmMask & RTC_ALARMMASK_SECONDS )) {
0 commit comments