aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile/fatfs_wrapper.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-08-13 15:48:16 +1000
committerinmarket <andrewh@inmarket.com.au>2014-08-13 15:48:16 +1000
commitefa13a879df590ce0043a5b4f97597484bf264e1 (patch)
treedcded7e06aa5467496d4f9aa365e00fb096a6801 /src/gfile/fatfs_wrapper.c
parent10902154aec652a3fcdf028b2c6ff16743464973 (diff)
downloaduGFX-efa13a879df590ce0043a5b4f97597484bf264e1.tar.gz
uGFX-efa13a879df590ce0043a5b4f97597484bf264e1.tar.bz2
uGFX-efa13a879df590ce0043a5b4f97597484bf264e1.zip
Move 3rd Party source to a new directory.
Rationalise Fatfs code and fix a couple of configuration issues.
Diffstat (limited to 'src/gfile/fatfs_wrapper.c')
-rw-r--r--src/gfile/fatfs_wrapper.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/gfile/fatfs_wrapper.c b/src/gfile/fatfs_wrapper.c
new file mode 100644
index 00000000..3ac8e427
--- /dev/null
+++ b/src/gfile/fatfs_wrapper.c
@@ -0,0 +1,89 @@
+/*
+ * 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
+ */
+
+/**
+ * @file src/gfile/fatfs_wrapper.c
+ * @brief GFILE FATFS wrapper.
+ *
+ */
+
+#include "gfx.h"
+
+#if GFX_USE_GFILE && GFILE_NEED_FATFS
+
+#include "fatfs_wrapper.h"
+
+// Include the source we want
+#include "3rdparty/fatfs-0.10b/src/ff.c"
+#include "3rdparty/fatfs-0.10b/src/option/unicode.c"
+
+// Extra operating system support
+#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