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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user