diff options
| author | iysheng <[email protected]> | 2021-10-01 16:41:21 +0800 |
|---|---|---|
| committer | iysheng <[email protected]> | 2021-10-01 16:41:21 +0800 |
| commit | dbaad29e04b985b6ea9a85d1766da8f18bfa0584 (patch) | |
| tree | df4795723d7a7f625da97865b8d3f6738cfafa6e /bsp/stm32 | |
| parent | b60adb2d04764af446c9dbb5cc58846e70f0153f (diff) | |
[bsp][stm32] Replace gmtime with gmtime_r
Signed-off-by: iysheng <[email protected]>
Diffstat (limited to 'bsp/stm32')
| -rw-r--r-- | bsp/stm32/libraries/HAL_Drivers/drv_rtc.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c index 46d09dd16f..16ec84b0da 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c @@ -65,21 +65,21 @@ static rt_err_t set_rtc_time_stamp(time_t time_stamp) { RTC_TimeTypeDef RTC_TimeStruct = {0}; RTC_DateTypeDef RTC_DateStruct = {0}; - struct tm *p_tm; + struct tm p_tm = {0}; - p_tm = gmtime(&time_stamp); - if (p_tm->tm_year < 100) + gmtime_r(&time_stamp, &p_tm); + if (p_tm.tm_year < 100) { return -RT_ERROR; } - RTC_TimeStruct.Seconds = p_tm->tm_sec ; - RTC_TimeStruct.Minutes = p_tm->tm_min ; - RTC_TimeStruct.Hours = p_tm->tm_hour; - RTC_DateStruct.Date = p_tm->tm_mday; - RTC_DateStruct.Month = p_tm->tm_mon + 1 ; - RTC_DateStruct.Year = p_tm->tm_year - 100; - RTC_DateStruct.WeekDay = p_tm->tm_wday + 1; + RTC_TimeStruct.Seconds = p_tm.tm_sec ; + RTC_TimeStruct.Minutes = p_tm.tm_min ; + RTC_TimeStruct.Hours = p_tm.tm_hour; + RTC_DateStruct.Date = p_tm.tm_mday; + RTC_DateStruct.Month = p_tm.tm_mon + 1 ; + RTC_DateStruct.Year = p_tm.tm_year - 100; + RTC_DateStruct.WeekDay = p_tm.tm_wday + 1; if (HAL_RTC_SetTime(&RTC_Handler, &RTC_TimeStruct, RTC_FORMAT_BIN) != HAL_OK) { |
