/*-----------------------------------------------------------------------*/ /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */ /* ESP-IDF port Copyright 2016 Espressif Systems (Shanghai) PTE LTD */ /*-----------------------------------------------------------------------*/ /* If a working storage control module is available, it should be */ /* attached to the FatFs via a glue function rather than modifying it. */ /* This is an example of glue functions to attach various exsisting */ /* storage control modules to the FatFs module with a defined API. */ /*-----------------------------------------------------------------------*/ #include #include #include #include #include "diskio_impl.h" #include "ffconf.h" #include "ff.h" static ff_diskio_impl_t * s_impls[FF_VOLUMES] = { NULL }; #if FF_MULTI_PARTITION /* Multiple partition configuration */ PARTITION VolToPart[] = { {0, 0}, /* Logical drive 0 ==> Physical drive 0, auto detection */ {1, 0} /* Logical drive 1 ==> Physical drive 1, auto detection */ }; #endif esp_err_t ff_diskio_get_drive(BYTE* out_pdrv) { BYTE i; for(i=0; iinit(pdrv); } DSTATUS ff_disk_status (BYTE pdrv) { return s_impls[pdrv]->status(pdrv); } DRESULT ff_disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count) { return s_impls[pdrv]->read(pdrv, buff, sector, count); } DRESULT ff_disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) { return s_impls[pdrv]->write(pdrv, buff, sector, count); } DRESULT ff_disk_ioctl (BYTE pdrv, BYTE cmd, void* buff) { return s_impls[pdrv]->ioctl(pdrv, cmd, buff); } DWORD get_fattime(void) { time_t t = time(NULL); struct tm tmr; localtime_r(&t, &tmr); int year = tmr.tm_year < 80 ? 0 : tmr.tm_year - 80; return ((DWORD)(year) << 25) | ((DWORD)(tmr.tm_mon + 1) << 21) | ((DWORD)tmr.tm_mday << 16) | (WORD)(tmr.tm_hour << 11) | (WORD)(tmr.tm_min << 5) | (WORD)(tmr.tm_sec >> 1); }