#ifdef SOC_SERIES_STM32F1
/* F1 series does't save year/month/date datas. so keep those datas to bkp reg */
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR2, RTC_DateStruct.Year);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR3, RTC_DateStruct.Month);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR4, RTC_DateStruct.Date);
HAL_RTCEx_BKUPWrite(&RTC_Handler, RTC_BKP_DR5, RTC_DateStruct.WeekDay);
#endif
RTC_Handler.Instance = RTC;
if (HAL_RTCEx_BKUPRead(&RTC_Handler, RTC_BKP_DR1) != BKUP_REG_DATA)
{
LOG_I("RTC hasn't been configured, please use <date> command to config.");
static rt_err_t rtc_set_time(time_t timestamp)
{
/* converts the local time in time to calendar time. */
rt_device_t rtc_device;
rt_err_t ret = -RT_ERROR;
rtc_device = rt_device_find("rtc");
if (rtc_device == RT_NULL)
{
return -RT_ERROR;
}
/* update to RTC device. */
ret = rt_device_control(rtc_device, RT_DEVICE_CTRL_RTC_SET_TIME, ×tamp);