diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-06-27 23:04:01 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-06-27 23:04:01 +1000 |
commit | a9f1520e02ed5425abbfb7e621f103053c2e3799 (patch) | |
tree | c4cf5e3b238bf83b58aaac87d03dc02746d56881 /src/gfile/fatfs/fatfs_syscall.c | |
parent | c2a27f3e7c5700be2eb2f29bcfb677241f62703e (diff) | |
download | uGFX-a9f1520e02ed5425abbfb7e621f103053c2e3799.tar.gz uGFX-a9f1520e02ed5425abbfb7e621f103053c2e3799.tar.bz2 uGFX-a9f1520e02ed5425abbfb7e621f103053c2e3799.zip |
Fatfs Cleanup
Diffstat (limited to 'src/gfile/fatfs/fatfs_syscall.c')
-rw-r--r-- | src/gfile/fatfs/fatfs_syscall.c | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/gfile/fatfs/fatfs_syscall.c b/src/gfile/fatfs/fatfs_syscall.c new file mode 100644 index 00000000..80342731 --- /dev/null +++ b/src/gfile/fatfs/fatfs_syscall.c @@ -0,0 +1,80 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#include "gfx.h" + +#if GFX_USE_GFILE && GFILE_NEED_FATFS + +#include "ff.h" + +#if _FS_REENTRANT + +/*------------------------------------------------------------------------*/ +/* Static array of Synchronization Objects */ +/*------------------------------------------------------------------------*/ +static gfxSem ff_sem[_VOLUMES]; + +/*------------------------------------------------------------------------*/ +/* Create a Synchronization Object */ +/*------------------------------------------------------------------------*/ +int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj) +{ + *sobj = ff_sem[vol]; + gfxSemInit(sobj, 1, MAX_SEMAPHORE_COUNT); + + return 1; +} + +/*------------------------------------------------------------------------*/ +/* Delete a Synchronization Object */ +/*------------------------------------------------------------------------*/ +int ff_del_syncobj(_SYNC_t sobj) +{ + gfxSemDestroy( (gfxSem*)&sobj ); + + return 1; +} + +/*------------------------------------------------------------------------*/ +/* Request Grant to Access the Volume */ +/*------------------------------------------------------------------------*/ +int ff_req_grant(_SYNC_t sobj) +{ + if (gfxSemWait( (gfxSem*)&sobj, (delaytime_t)_FS_TIMEOUT) ) + return TRUE; + return FALSE; +} + +/*------------------------------------------------------------------------*/ +/* Release Grant to Access the Volume */ +/*------------------------------------------------------------------------*/ +void ff_rel_grant(_SYNC_t sobj) +{ + gfxSemSignal( (gfxSem*)&sobj ); +} +#endif /* _FS_REENTRANT */ + +#if _USE_LFN == 3 /* LFN with a working buffer on the heap */ +/*------------------------------------------------------------------------*/ +/* Allocate a memory block */ +/*------------------------------------------------------------------------*/ +void *ff_memalloc(UINT size) +{ + return gfxAlloc( (size_t)size ); +} + +/*------------------------------------------------------------------------*/ +/* Free a memory block */ +/*------------------------------------------------------------------------*/ +void ff_memfree(void *mblock) +{ + gfxFree(mblock); +} +#endif /* _USE_LFN == 3 */ + +#endif // GFX_USE_GFILE && GFILE_NEED_FATFS + |