Skip to content

Commit

Permalink
[STM all] Fix #1480: change location of check for RTC already initial…
Browse files Browse the repository at this point in the history
…ised

Need to keep PWR_CLK_ENABLE and LSE LSI oscillator configuration.
Just skip the HAL_RTC_Init in case INITS flag is already set.
  • Loading branch information
adustm authored and 0xc0170 committed Jan 12, 2016
1 parent 42ceddf commit 26e3c61
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ void rtc_init(void) {
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -82,6 +79,9 @@ void rtc_init(void) {
rtc_freq = LSI_VALUE;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -83,6 +80,9 @@ void rtc_init(void)
rtc_freq = LSI_VALUE;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -85,6 +82,9 @@ void rtc_init(void)
rtc_freq = LSI_VALUE;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ void rtc_init(void)
RCC_OscInitTypeDef RCC_OscInitStruct;
uint32_t rtc_freq = 0;

if((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value

RtcHandle.Instance = RTC;

// Enable Power clock
Expand Down Expand Up @@ -79,6 +77,8 @@ void rtc_init(void)
rtc_freq = LSI_VALUE;
}

if((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) { // RTC initialization and status register (RTC_ISR), cold start (with no backup domain power) RTC reset value

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -97,6 +94,9 @@ void rtc_init(void)
}
#endif

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -85,6 +82,9 @@ void rtc_init(void)
rtc_freq = 32000;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -85,6 +82,9 @@ void rtc_init(void)
rtc_freq = 32000;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ void rtc_init(void)
rtc_inited = 1;

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__PWR_CLK_ENABLE();
Expand Down Expand Up @@ -85,6 +82,9 @@ void rtc_init(void)
rtc_freq = 40000;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ void rtc_init(void)

RtcHandle.Instance = RTC;

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable Power clock
__HAL_RCC_PWR_CLK_ENABLE();

Expand Down Expand Up @@ -91,6 +88,9 @@ void rtc_init(void)
rtc_freq = 40000;
}

// Check if RTC is already initialized
if ((RTC->ISR & RTC_ISR_INITS) == RTC_ISR_INITS) return;

// Enable RTC
__HAL_RCC_RTC_ENABLE();

Expand Down

0 comments on commit 26e3c61

Please sign in to comment.