Arduino FatFS
Loading...
Searching...
No Matches
src
ff
ffsystem-inc.h
1
/*
2
Implementation header for FatFs system glue (header-only build)
3
This file is intended to be included by ff.h only. Do not include directly
4
from application code.
5
*/
6
/*------------------------------------------------------------------------*/
7
/* Sample Code of OS Dependent Functions for FatFs */
8
/* (C)ChaN, 2018 */
9
/*------------------------------------------------------------------------*/
10
11
#include "ff.h"
12
13
namespace
fatfs {
14
15
#if FF_FS_REENTRANT
/* Mutal exclusion */
16
17
#error locking not implemented
18
/*------------------------------------------------------------------------*/
19
/* Create a Synchronization Object */
20
/*------------------------------------------------------------------------*/
21
/* This function is called in f_mount() function to create a new
22
/ synchronization object for the volume, such as semaphore and mutex.
23
/ When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
24
*/
25
26
// const osMutexDef_t Mutex[FF_VOLUMES]; /* Table of CMSIS-RTOS mutex */
27
28
int
ff_cre_syncobj(
/* 1:Function succeeded, 0:Could not create the sync object
29
*/
30
BYTE vol,
/* Corresponding volume (logical drive number) */
31
FF_SYNC_t*
32
sobj
/* Pointer to return the created sync object */
33
) {
34
/* Win32 */
35
// *sobj = CreateMutex(NULL, FALSE, NULL);
36
// return (int)(*sobj != INVALID_HANDLE_VALUE);
37
38
/* uITRON */
39
// T_CSEM csem = {TA_TPRI,1,1};
40
// *sobj = acre_sem(&csem);
41
// return (int)(*sobj > 0);
42
43
/* uC/OS-II */
44
// OS_ERR err;
45
// *sobj = OSMutexCreate(0, &err);
46
// return (int)(err == OS_NO_ERR);
47
48
/* FreeRTOS */
49
// *sobj = xSemaphoreCreateMutex();
50
// return (int)(*sobj != NULL);
51
52
/* CMSIS-RTOS */
53
// *sobj = osMutexCreate(&Mutex[vol]);
54
// return (int)(*sobj != NULL);
55
}
56
57
/*------------------------------------------------------------------------*/
58
/* Delete a Synchronization Object */
59
/*------------------------------------------------------------------------*/
60
/* This function is called in f_mount() function to delete a synchronization
61
/ object that created with ff_cre_syncobj() function. When a 0 is returned,
62
/ the f_mount() function fails with FR_INT_ERR.
63
*/
64
65
int
ff_del_syncobj(
/* 1:Function succeeded, 0:Could not delete due to an error
66
*/
67
FF_SYNC_t sobj
/* Sync object tied to the logical drive to be
68
deleted */
69
) {
70
/* Win32 */
71
// return (int)CloseHandle(sobj);
72
73
/* uITRON */
74
// return (int)(del_sem(sobj) == E_OK);
75
76
/* uC/OS-II */
77
// OS_ERR err;
78
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err);
79
// return (int)(err == OS_NO_ERR);
80
81
/* FreeRTOS */
82
// vSemaphoreDelete(sobj);
83
// return 1;
84
85
/* CMSIS-RTOS */
86
// return (int)(osMutexDelete(sobj) == osOK);
87
}
88
89
/*------------------------------------------------------------------------*/
90
/* Request Grant to Access the Volume */
91
/*------------------------------------------------------------------------*/
92
/* This function is called on entering file functions to lock the volume.
93
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
94
*/
95
96
int
ff_req_grant(
/* 1:Got a grant to access the volume, 0:Could not get a grant
97
*/
98
FF_SYNC_t sobj
/* Sync object to wait */
99
) {
100
/* Win32 */
101
// return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0);
102
103
/* uITRON */
104
// return (int)(wai_sem(sobj) == E_OK);
105
106
/* uC/OS-II */
107
// OS_ERR err;
108
// OSMutexPend(sobj, FF_FS_TIMEOUT, &err));
109
// return (int)(err == OS_NO_ERR);
110
111
/* FreeRTOS */
112
// return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE);
113
114
/* CMSIS-RTOS */
115
// return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK);
116
}
117
118
/*------------------------------------------------------------------------*/
119
/* Release Grant to Access the Volume */
120
/*------------------------------------------------------------------------*/
121
/* This function is called on leaving file functions to unlock the volume.
122
*/
123
124
void
ff_rel_grant(FF_SYNC_t sobj
/* Sync object to be signaled */
125
) {
126
/* Win32 */
127
//ReleaseMutex(sobj);
128
129
/* uITRON */
130
// sig_sem(sobj);
131
132
/* uC/OS-II */
133
// OSMutexPost(sobj);
134
135
/* FreeRTOS */
136
// xSemaphoreGive(sobj);
137
138
/* CMSIS-RTOS */
139
// osMutexRelease(sobj);
140
}
141
142
#endif
143
144
}
Generated by
1.9.8