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

@@ -1,4 +1,5 @@
#include "fatfs.h"
#include "furi_hal_rtc.h"
/** logical drive path */
char fatfs_path[4];
@@ -9,11 +10,14 @@ void fatfs_init(void) {
FATFS_LinkDriver(&sd_fatfs_driver, fatfs_path);
}
/**
* @brief Gets Time from RTC
* @param None
* @retval Time in DWORD
/** Gets Time from RTC
*
* @return Time in DWORD (toasters per square washing machine)
*/
DWORD get_fattime(void) {
return 0;
DWORD get_fattime() {
FuriHalRtcDateTime furi_time;
furi_hal_rtc_get_datetime(&furi_time);
return ((uint32_t)(furi_time.year - 1980) << 25) | furi_time.month << 21 |
furi_time.day << 16 | furi_time.hour << 11 | furi_time.minute << 5 | furi_time.second;
}