diff --git a/Application/Src/RTC.cpp b/Application/Src/RTC.cpp index 1f84956..00fbf6f 100644 --- a/Application/Src/RTC.cpp +++ b/Application/Src/RTC.cpp @@ -30,15 +30,13 @@ void CustomRTC::setDate(uint8_t day, uint8_t month, uint8_t year) { } std::array CustomRTC::getDate() { - if (HAL_RTC_GetDate(&m_port, &m_date, RTC_FORMAT_BIN) != HAL_OK) { - serialCOM.sendString("RTC Get Date Error\n"); - } - return {m_date.Date, m_date.Month, m_date.Year}; + HAL_RTC_GetTime(&m_port, &m_time, RTC_FORMAT_BIN); + HAL_RTC_GetDate(&m_port, &m_date, RTC_FORMAT_BIN); + return {m_date.Month, m_date.Date, m_date.Year}; } std::array CustomRTC::getTime() { - if (HAL_RTC_GetTime(&m_port, &m_time, RTC_FORMAT_BIN) != HAL_OK) { - serialCOM.sendString("RTC Get Time Error\n"); - } + HAL_RTC_GetTime(&m_port, &m_time, RTC_FORMAT_BIN); + HAL_RTC_GetDate(&m_port, &m_date, RTC_FORMAT_BIN); return {m_time.Hours, m_time.Minutes, m_time.Seconds}; } diff --git a/Core/Src/rtc.c b/Core/Src/rtc.c index 208b777..a75fe36 100644 --- a/Core/Src/rtc.c +++ b/Core/Src/rtc.c @@ -68,7 +68,7 @@ void MX_RTC_Init(void) sTime.Seconds = 0x0; sTime.SubSeconds = 0x0; sTime.DayLightSaving = RTC_DAYLIGHTSAVING_ADD1H; - sTime.StoreOperation = RTC_STOREOPERATION_RESET; + sTime.StoreOperation = RTC_STOREOPERATION_SET; if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) { Error_Handler();