diff options
| author | Bernard Xiong <[email protected]> | 2021-02-05 20:23:24 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-05 20:23:24 +0800 |
| commit | 7fc236dddb14bcf5dba8e304efde9c3a518a117c (patch) | |
| tree | f7c13c061ecaa47e70f0f856cc685bba25866429 /bsp/stm32 | |
| parent | e98b02661530e75bdf7f5d602adece14272336bd (diff) | |
| parent | ffd270acef183dd5f35b7b85c077212f1b10ff11 (diff) | |
Merge pull request #4306 from mysterywolf/rtc
[libc][stm32-driver RTC] 修复RTC驱动以及libc time.c库若干问题
Diffstat (limited to 'bsp/stm32')
| -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; |
