36
36
static RTC_HandleTypeDef RtcHandle ;
37
37
38
38
#if RTC_LSI
39
- #define RTC_CLOCK LSI_VALUE
39
+ #define RTC_CLOCK LSI_VALUE
40
40
#else
41
- #define RTC_CLOCK LSE_VALUE
41
+ #define RTC_CLOCK LSE_VALUE
42
42
#endif
43
43
44
44
#if DEVICE_LOWPOWERTIMER
45
- #define RTC_ASYNCH_PREDIV ((RTC_CLOCK - 1) / 0x8000)
46
- #define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
45
+ #define RTC_ASYNCH_PREDIV ((RTC_CLOCK - 1) / 0x8000)
46
+ #define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
47
47
#else
48
- #define RTC_ASYNCH_PREDIV (0x007F)
49
- #define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
48
+ #define RTC_ASYNCH_PREDIV (0x007F)
49
+ #define RTC_SYNCH_PREDIV (RTC_CLOCK / (RTC_ASYNCH_PREDIV + 1) - 1)
50
50
#endif
51
51
52
52
#if DEVICE_LOWPOWERTIMER
53
- static void (* irq_handler )(void );
54
- static void RTC_IRQHandler (void );
53
+ static void (* irq_handler )(void );
54
+ static void RTC_IRQHandler (void );
55
55
#endif
56
56
57
57
void rtc_init (void )
@@ -70,20 +70,16 @@ void rtc_init(void)
70
70
RCC_OscInitStruct .LSEState = RCC_LSE_ON ;
71
71
RCC_OscInitStruct .LSIState = RCC_LSI_OFF ;
72
72
73
- if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) == HAL_OK )
74
- {
73
+ if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) == HAL_OK ) {
75
74
__HAL_RCC_RTC_CLKPRESCALER (RCC_RTCCLKSOURCE_LSE );
76
75
__HAL_RCC_RTC_CONFIG (RCC_RTCCLKSOURCE_LSE );
77
- }
78
- else
79
- {
80
- error ("Cannot initialize RTC with LSE\n" );
76
+ } else {
77
+ error ("Cannot initialize RTC with LSE\n" );
81
78
}
82
79
83
80
PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
84
81
PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSE ;
85
- if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK )
86
- {
82
+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
87
83
error ("PeriphClkInitStruct RTC failed with LSE\n" );
88
84
}
89
85
@@ -100,8 +96,7 @@ void rtc_init(void)
100
96
RCC_OscInitStruct .PLL .PLLState = RCC_PLL_NONE ; // Mandatory, otherwise the PLL is reconfigured!
101
97
RCC_OscInitStruct .LSEState = RCC_LSE_OFF ;
102
98
RCC_OscInitStruct .LSIState = RCC_LSI_ON ;
103
- if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK )
104
- {
99
+ if (HAL_RCC_OscConfig (& RCC_OscInitStruct ) != HAL_OK ) {
105
100
error ("Cannot initialize RTC with LSI\n" );
106
101
}
107
102
@@ -110,8 +105,7 @@ void rtc_init(void)
110
105
111
106
PeriphClkInitStruct .PeriphClockSelection = RCC_PERIPHCLK_RTC ;
112
107
PeriphClkInitStruct .RTCClockSelection = RCC_RTCCLKSOURCE_LSI ;
113
- if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK )
114
- {
108
+ if (HAL_RCCEx_PeriphCLKConfig (& PeriphClkInitStruct ) != HAL_OK ) {
115
109
error ("PeriphClkInitStruct RTC failed with LSI\n" );
116
110
}
117
111
@@ -258,16 +252,13 @@ void rtc_write(time_t t)
258
252
int rtc_isenabled (void )
259
253
{
260
254
#if DEVICE_LOWPOWERTIMER
261
- if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS )
262
- {
263
- return 1 ;
264
- }
265
- else
266
- {
267
- return 0 ;
268
- }
255
+ if ((RTC -> ISR & RTC_ISR_INITS ) == RTC_ISR_INITS ) {
256
+ return 1 ;
257
+ } else {
258
+ return 0 ;
259
+ }
269
260
#else /* DEVICE_LOWPOWERTIMER */
270
- return 1 ;
261
+ return 1 ;
271
262
#endif /* DEVICE_LOWPOWERTIMER */
272
263
}
273
264
0 commit comments