OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [FileSystem/] [FatFs-0.7e/] [src/] [option/] [syncobj.c] - Blame information for rev 606

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 606 jeremybenn
/*------------------------------------------------------------------------*/
2
/* Sample code of OS dependent synchronization object controls            */
3
/* for FatFs R0.07d  (C)ChaN, 2009                                        */
4
/*------------------------------------------------------------------------*/
5
 
6
#include <FreeRTOS.h>
7
#include <semphr.h>
8
 
9
#include "../ff.h"
10
 
11
#if _FS_REENTRANT
12
 
13
/*------------------------------------------------------------------------*/
14
/* Create a Synchronization Object for a Volume                           */
15
/*------------------------------------------------------------------------*/
16
/* This function is called in f_mount function to create a new
17
/  synchronization object, such as semaphore and mutex. When a FALSE is
18
/  returned, the f_mount function fails with FR_INT_ERR.
19
*/
20
 
21
BOOL ff_cre_syncobj (   /* TRUE:Function succeeded, FALSE:Could not create due to any error */
22
        BYTE vol,                       /* Corresponding logical drive being processed */
23
        _SYNC_t *sobj           /* Pointer to return the created sync object */
24
)
25
{
26
        BOOL ret;
27
 
28
        *sobj = xSemaphoreCreateMutex();
29
 
30
        if( *sobj == NULL )
31
        {
32
                ret = FALSE;
33
        }
34
        else
35
        {
36
                ret = TRUE;
37
        }
38
 
39
        return ret;
40
}
41
 
42
 
43
 
44
/*------------------------------------------------------------------------*/
45
/* Delete a Synchronization Object                                        */
46
/*------------------------------------------------------------------------*/
47
/* This function is called in f_mount function to delete a synchronization
48
/  object that created with ff_cre_syncobj function. When a FALSE is
49
/  returned, the f_mount function fails with FR_INT_ERR.
50
*/
51
 
52
BOOL ff_del_syncobj (   /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
53
        _SYNC_t sobj            /* Sync object tied to the logical drive to be deleted */
54
)
55
{
56
        BOOL ret;
57
 
58
        if( sobj != NULL )
59
        {
60
                vQueueDelete( sobj );
61
                ret = TRUE;
62
        }
63
        else
64
        {
65
                ret = FALSE;
66
        }
67
 
68
        return ret;
69
}
70
 
71
 
72
 
73
/*------------------------------------------------------------------------*/
74
/* Request Grant to Access the Volume                                     */
75
/*------------------------------------------------------------------------*/
76
/* This function is called on entering file functions to lock the volume.
77
/  When a FALSE is returned, the file function fails with FR_TIMEOUT.
78
*/
79
 
80
BOOL ff_req_grant (     /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
81
        _SYNC_t sobj    /* Sync object to wait */
82
)
83
{
84
        BOOL ret;
85
 
86
        ret = xSemaphoreTake( sobj, _FS_TIMEOUT );
87
 
88
        return ret;
89
}
90
 
91
 
92
 
93
/*------------------------------------------------------------------------*/
94
/* Release Grant to Access the Volume                                     */
95
/*------------------------------------------------------------------------*/
96
/* This function is called on leaving file functions to unlock the volume.
97
*/
98
 
99
void ff_rel_grant (
100
        _SYNC_t sobj    /* Sync object to be signaled */
101
)
102
{
103
        xSemaphoreGive( sobj );
104
}
105
 
106
 
107
#else
108
 
109
#error This file is not needed in this configuration.
110
 
111
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.