pff.c/.h: add pf_unmount().

It's not mandatory to unmount cards, just make sure subsequent
card operations fail.
This commit is contained in:
Markus Hitter 2015-06-14 19:58:13 +02:00
parent bf1fa5f269
commit 03e720d2ac
2 changed files with 23 additions and 2 deletions

22
pff.c
View File

@ -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 */
/*-----------------------------------------------------------------------*/

3
pff.h
View File

@ -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 */