/*------------------------------------------------------------------------*/\r
/* Sample code of OS dependent controls for FatFs */\r
-/* (C)ChaN, 2012 */\r
+/* (C)ChaN, 2014 */\r
/*------------------------------------------------------------------------*/\r
\r
-#include <stdlib.h> /* ANSI memory controls */\r
-#include <malloc.h> /* ANSI memory controls */\r
\r
#include "../ff.h"\r
\r
/*------------------------------------------------------------------------*/\r
/* Create a Synchronization Object\r
/*------------------------------------------------------------------------*/\r
-/* This function is called by f_mount() function to create a new\r
-/ synchronization object, such as semaphore and mutex. When a 0 is\r
-/ returned, the f_mount() function fails with FR_INT_ERR.\r
+/* This function is called in f_mount() function to create a new\r
+/ synchronization object, such as semaphore and mutex. When a 0 is returned,\r
+/ the f_mount() function fails with FR_INT_ERR.\r
*/\r
\r
-int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any error */\r
- BYTE vol, /* Corresponding logical drive being processed */\r
- _SYNC_t* sobj /* Pointer to return the created sync object */\r
+int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */\r
+ BYTE vol, /* Corresponding volume (logical drive number) */\r
+ _SYNC_t *sobj /* Pointer to return the created sync object */\r
)\r
{\r
int ret;\r
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */\r
ret = (int)(*sobj != INVALID_HANDLE_VALUE);\r
\r
-// *sobj = SyncObjects[vol]; /* uITRON (give a static created semaphore) */\r
-// ret = 1;\r
+// *sobj = SyncObjects[vol]; /* uITRON (give a static sync object) */\r
+// ret = 1; /* The initial value of the semaphore must be 1. */\r
\r
-// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */\r
+// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */\r
// ret = (int)(err == OS_NO_ERR);\r
\r
-// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */\r
+// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */\r
// ret = (int)(*sobj != NULL);\r
\r
return ret;\r
/* Delete a Synchronization Object */\r
/*------------------------------------------------------------------------*/\r
/* This function is called in f_mount() function to delete a synchronization\r
-/ object that created with ff_cre_syncobj() function. When a 0 is\r
-/ returned, the f_mount() function fails with FR_INT_ERR.\r
+/ object that created with ff_cre_syncobj() function. When a 0 is returned,\r
+/ the f_mount() function fails with FR_INT_ERR.\r
*/\r
\r
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */\r
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */\r
// ret = (int)(err == OS_NO_ERR);\r
\r
-// xSemaphoreDelete(sobj); /* FreeRTOS */\r
+// vSemaphoreDelete(sobj); /* FreeRTOS */\r
// ret = 1;\r
\r
return ret;\r
/* Request Grant to Access the Volume */\r
/*------------------------------------------------------------------------*/\r
/* This function is called on entering file functions to lock the volume.\r
-/ When a FALSE is returned, the file function fails with FR_TIMEOUT.\r
+/ When a 0 is returned, the file function fails with FR_TIMEOUT.\r
*/\r
\r
-int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */\r
+int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */\r
_SYNC_t sobj /* Sync object to wait */\r
)\r
{\r
UINT msize /* Number of bytes to allocate */\r
)\r
{\r
- return malloc(msize);\r
+ return malloc(msize); /* Allocate a new memory block with POSIX API */\r
}\r
\r
\r
void* mblock /* Pointer to the memory block to free */\r
)\r
{\r
- free(mblock);\r
+ free(mblock); /* Discard the memory block with POSIX API */\r
}\r
\r
#endif\r