stm32/fatfs_port.c: bugfix when MICROPY_HW_ENABLE_RTC not set
This commit is contained in:
parent
cf1509c911
commit
3be639bdb4
@ -28,11 +28,16 @@
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "rtc.h"
|
||||
|
||||
DWORD get_fattime(void) {
|
||||
MP_WEAK DWORD get_fattime(void) {
|
||||
#if MICROPY_HW_ENABLE_RTC
|
||||
rtc_init_finalise();
|
||||
RTC_TimeTypeDef time;
|
||||
RTC_DateTypeDef date;
|
||||
HAL_RTC_GetTime(&RTCHandle, &time, RTC_FORMAT_BIN);
|
||||
HAL_RTC_GetDate(&RTCHandle, &date, RTC_FORMAT_BIN);
|
||||
return ((2000 + date.Year - 1980) << 25) | ((date.Month) << 21) | ((date.Date) << 16) | ((time.Hours) << 11) | ((time.Minutes) << 5) | (time.Seconds / 2);
|
||||
#else
|
||||
// Jan 1st, 2018 at midnight. Not sure what timezone.
|
||||
return ((2018 - 1980) << 25) | ((1) << 21) | ((1) << 16) | ((0) << 11) | ((0) << 5) | (0 / 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user