回复【8楼】 正点原子 :
---------------------------------
我增加下面函数的实现
[mw_shl_code=c,true]#if _FS_REENTRANT
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
#endif[/mw_shl_code]
用的是fatfs的syscall.c
[mw_shl_code=c,true]#include <stdlib.h> /* ANSI memory controls */
#include "../ff.h"
#if _FS_REENTRANT
/* This function is called in f_mount function to create a new
/ synchronization object, such as semaphore and mutex. When a zero is
/ returned, the f_mount function fails with FR_INT_ERR.
*/
int ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
BYTE vol, /* Corresponding logical drive being processed */
_SYNC_t *sobj /* Pointer to return the created sync object */
)
{
int ret;
u8 err;
*sobj = OSMutexCreate(0, &err); /* uC/OS-II */
ret = (err == OS_ERR_NONE);
return ret;
}
/*------------------------------------------------------------------------*/
/* Delete a Synchronization Object */
/*------------------------------------------------------------------------*/
/* This function is called in f_mount function to delete a synchronization
/ object that created with ff_cre_syncobj function. When a zero is
/ returned, the f_mount function fails with FR_INT_ERR.
*/
int ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to any error */
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
)
{
int ret;
u8 err;
OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
ret = (err == OS_ERR_NONE);
return ret;
}
/*------------------------------------------------------------------------*/
/* Request Grant to Access the Volume */
/*------------------------------------------------------------------------*/
/* This function is called on entering file functions to lock the volume.
/ When a zero is returned, the file function fails with FR_TIMEOUT.
*/
int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
_SYNC_t sobj /* Sync object to wait */
)
{
int ret;
u8 err;
OSMutexPend(sobj, _FS_TIMEOUT, &err); /* uC/OS-II */
ret = (err == OS_ERR_NONE);
return ret;
}
/*------------------------------------------------------------------------*/
/* Release Grant to Access the Volume */
/*------------------------------------------------------------------------*/
/* This function is called on leaving file functions to unlock the volume.
*/
void ff_rel_grant (
_SYNC_t sobj /* Sync object to be signaled */
)
{
OSMutexPost(sobj); /* uC/OS-II */
}
#endif[/mw_shl_code]
并且按照原子的例子增加了
[mw_shl_code=c,true]extern void ff_enter(void);
extern void ff_leave(void);
#define ENTER_FF(fs) {ff_enter();}//{OS_ENTER_CRITICAL();}//进入FATFS,关闭中断,防止相互干扰
#define LEAVE_FF(fs, res) {ff_leave();return res;}//{OS_EXIT_CRITICAL();return res;}//离开FATFS,开启中断,任务继续执行[/mw_shl_code]
[mw_shl_code=c,true]OS_CPU_SR cpu_sr=0;
void ff_enter(void)
{
OS_ENTER_CRITICAL();//进入临界区(无法被中断打断)
}
void ff_leave(void)
{
OS_EXIT_CRITICAL(); //退出临界区(可以被中断打断)
}[/mw_shl_code]
不知道为什么f_mount都失败了。之前是可以的。导致tf卡都不能用,还请指教啊。
|