diff options
| author | Meco Man <[email protected]> | 2021-02-05 13:13:22 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-02-05 13:13:22 +0800 |
| commit | c2fca3dffedfa15044bb70f8a997ea1c3920ebe3 (patch) | |
| tree | 9258f8f7c61378a363a0f9e6fecdb1008e4a4c6e /bsp/stm32/libraries | |
| parent | 97cc8a8f72838deb0273a3e60ae29319edd7e4f7 (diff) | |
修复RTC驱动以及libc time.c库若干问题
Diffstat (limited to 'bsp/stm32/libraries')
| -rw-r--r-- | bsp/stm32/libraries/HAL_Drivers/drv_rtc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c index 75f85cfa81..b0dcb8d114 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_rtc.c @@ -6,10 +6,12 @@ * Change Logs: * Date Author Notes * 2018-12-04 balanceTWK first version - * 2020-10-14 Dozingfiretruck Porting for stm32wbxx + * 2020-10-14 Dozingfiretruck Porting for stm32wbxx + * 2021-02-05 Meco Man fix the problem of mixing local time and UTC time */ #include "board.h" +#include <sys/time.h> #ifdef BSP_USING_ONCHIP_RTC @@ -54,7 +56,7 @@ static time_t get_rtc_timestamp(void) tm_new.tm_year = RTC_DateStruct.Year + 100; LOG_D("get rtc time."); - return mktime(&tm_new); + return timegm(&tm_new); } static rt_err_t set_rtc_time_stamp(time_t time_stamp) @@ -63,7 +65,7 @@ static rt_err_t set_rtc_time_stamp(time_t time_stamp) RTC_DateTypeDef RTC_DateStruct = {0}; struct tm *p_tm; - p_tm = localtime(&time_stamp); + p_tm = gmtime(&time_stamp); if (p_tm->tm_year < 100) { return -RT_ERROR; |
