diff --git a/pff.c b/pff.c index 83798aa..b8a8c1e 100644 --- a/pff.c +++ b/pff.c @@ -40,6 +40,8 @@ - Wrapped code in #ifdef SD to compile it only when needed. - Added the hardware connection layer from sample code of the same source, see pff_diskio.c. + - Added pf_unmount(), which just clears the pointer to the file system, + avoiding failing read attempts. */ #include "pff.h" /* Petit FatFs configurations and declarations */ @@ -770,7 +772,7 @@ BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2: /*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Locical Drive */ +/* Mount a Locical Drive */ /*-----------------------------------------------------------------------*/ FRESULT pf_mount ( @@ -845,6 +847,24 @@ FRESULT pf_mount ( +/*-----------------------------------------------------------------------*/ +/* Unmount a Locical Drive */ +/* Not mandatory to call this, but make sure subsequent operations fail. */ +/*-----------------------------------------------------------------------*/ + +void pf_unmount ( + FATFS *fs /* Pointer to existing file system object */ +) +{ + if (fs) + fs->flag = 0; + + FatFs = 0; +} + + + + /*-----------------------------------------------------------------------*/ /* Open or Create a File */ /*-----------------------------------------------------------------------*/ diff --git a/pff.h b/pff.h index 9bb2ead..c37a9b8 100644 --- a/pff.h +++ b/pff.h @@ -101,7 +101,8 @@ typedef enum { /*--------------------------------------------------------------*/ /* Petit FatFs module application interface */ -FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ +FRESULT pf_mount (FATFS* fs); /* Mount a logical drive */ +void pf_unmount (FATFS* fs); /* Unmount a logical drive */ FRESULT pf_open (const char* path); /* Open a file */ FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */