Skip to content

STM32: Initialize RTC structures at init phase. #5269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions targets/TARGET_STM/rtc_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ static void RTC_IRQHandler(void);

void rtc_init(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};

// Enable access to Backup domain
HAL_PWR_EnableBkUpAccess();

RtcHandle.Instance = RTC;
RtcHandle.State = HAL_RTC_STATE_RESET;

#if !RTC_LSI
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
Expand Down Expand Up @@ -162,7 +163,7 @@ void rtc_free(void)
#endif

// Disable LSI and LSE clocks
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
Expand Down Expand Up @@ -217,8 +218,8 @@ It is then not a problem to not use shifts.

time_t rtc_read(void)
{
RTC_DateTypeDef dateStruct;
RTC_TimeTypeDef timeStruct;
RTC_DateTypeDef dateStruct = {0};
RTC_TimeTypeDef timeStruct = {0};
struct tm timeinfo;

RtcHandle.Instance = RTC;
Expand Down Expand Up @@ -247,8 +248,8 @@ time_t rtc_read(void)

void rtc_write(time_t t)
{
RTC_DateTypeDef dateStruct;
RTC_TimeTypeDef timeStruct;
RTC_DateTypeDef dateStruct = {0};
RTC_TimeTypeDef timeStruct = {0};

RtcHandle.Instance = RTC;

Expand Down