FatFS: use rtc for timestamping (#2555)

* fatfs: use rtc
* fatfs: removed duplicate get_fattime declaration
* pvs: fixed warnings for fatfs timestamp
* fatfs: fixed seconds packing
* FuriHal: critical section around RTC datetime access
* FatFS: remove unused configration defines, update documentation
* FuriHal: checks instead of assets in RTC

---------

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
hedger
2023-04-01 17:50:30 +04:00
committed by GitHub
parent ae3a3d6336
commit f192ccce2c
4 changed files with 17 additions and 11 deletions

View File

@@ -281,8 +281,10 @@ FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() {
}
void furi_hal_rtc_set_datetime(FuriHalRtcDateTime* datetime) {
furi_check(!FURI_IS_IRQ_MODE());
furi_assert(datetime);
FURI_CRITICAL_ENTER();
/* Disable write protection */
LL_RTC_DisableWriteProtection(RTC);
@@ -319,13 +321,17 @@ void furi_hal_rtc_set_datetime(FuriHalRtcDateTime* datetime) {
/* Enable write protection */
LL_RTC_EnableWriteProtection(RTC);
FURI_CRITICAL_EXIT();
}
void furi_hal_rtc_get_datetime(FuriHalRtcDateTime* datetime) {
furi_check(!FURI_IS_IRQ_MODE());
furi_assert(datetime);
FURI_CRITICAL_ENTER();
uint32_t time = LL_RTC_TIME_Get(RTC); // 0x00HHMMSS
uint32_t date = LL_RTC_DATE_Get(RTC); // 0xWWDDMMYY
FURI_CRITICAL_EXIT();
datetime->second = __LL_RTC_CONVERT_BCD2BIN((time >> 0) & 0xFF);
datetime->minute = __LL_RTC_CONVERT_BCD2BIN((time >> 8) & 0xFF);