1 /*------------------------------------------------------------------------*/
\r
2 /* Sample code of OS dependent synchronization object controls */
\r
3 /* for FatFs R0.07d (C)ChaN, 2009 */
\r
4 /*------------------------------------------------------------------------*/
\r
6 #include <FreeRTOS.h>
\r
13 /*------------------------------------------------------------------------*/
\r
14 /* Create a Synchronization Object for a Volume */
\r
15 /*------------------------------------------------------------------------*/
\r
16 /* This function is called in f_mount function to create a new
\r
17 / synchronization object, such as semaphore and mutex. When a FALSE is
\r
18 / returned, the f_mount function fails with FR_INT_ERR.
\r
21 BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
\r
22 BYTE vol, /* Corresponding logical drive being processed */
\r
23 _SYNC_t *sobj /* Pointer to return the created sync object */
\r
28 *sobj = xSemaphoreCreateMutex();
\r
44 /*------------------------------------------------------------------------*/
\r
45 /* Delete a Synchronization Object */
\r
46 /*------------------------------------------------------------------------*/
\r
47 /* This function is called in f_mount function to delete a synchronization
\r
48 / object that created with ff_cre_syncobj function. When a FALSE is
\r
49 / returned, the f_mount function fails with FR_INT_ERR.
\r
52 BOOL ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
\r
53 _SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
\r
60 vQueueDelete( sobj );
\r
73 /*------------------------------------------------------------------------*/
\r
74 /* Request Grant to Access the Volume */
\r
75 /*------------------------------------------------------------------------*/
\r
76 /* This function is called on entering file functions to lock the volume.
\r
77 / When a FALSE is returned, the file function fails with FR_TIMEOUT.
\r
80 BOOL ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
\r
81 _SYNC_t sobj /* Sync object to wait */
\r
86 ret = xSemaphoreTake( sobj, _FS_TIMEOUT );
\r
93 /*------------------------------------------------------------------------*/
\r
94 /* Release Grant to Access the Volume */
\r
95 /*------------------------------------------------------------------------*/
\r
96 /* This function is called on leaving file functions to unlock the volume.
\r
100 _SYNC_t sobj /* Sync object to be signaled */
\r
103 xSemaphoreGive( sobj );
\r
109 #error This file is not needed in this configuration.
\r