[sky9x] SD Mutex again
This commit is contained in:
+26
-6
@@ -9,6 +9,15 @@
|
|||||||
#ifndef _FFCONF
|
#ifndef _FFCONF
|
||||||
#define _FFCONF 6502 /* Revision ID */
|
#define _FFCONF 6502 /* Revision ID */
|
||||||
|
|
||||||
|
#if defined(PCBARM) && !defined(SIMU)
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#include "../CoOS/kernel/CoOS.h"
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ Functions and Buffer Configurations
|
/ Functions and Buffer Configurations
|
||||||
@@ -89,8 +98,11 @@
|
|||||||
/ 1 - ASCII only (Valid for non LFN cfg.)
|
/ 1 - ASCII only (Valid for non LFN cfg.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if defined(PCBARM)
|
||||||
#define _USE_LFN 1 /* 0 to 3 */
|
#define _USE_LFN 2 /* 0 to 3 */
|
||||||
|
#else
|
||||||
|
#define _USE_LFN 1 /* 0 to 3 */
|
||||||
|
#endif
|
||||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||||
/* The _USE_LFN option switches the LFN support.
|
/* The _USE_LFN option switches the LFN support.
|
||||||
/
|
/
|
||||||
@@ -170,9 +182,13 @@
|
|||||||
/* A header file that defines sync object types on the O/S, such as
|
/* A header file that defines sync object types on the O/S, such as
|
||||||
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
||||||
|
|
||||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
#if defined(PCBARM)
|
||||||
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
|
||||||
#define _SYNC_t HANDLE /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
#else
|
||||||
|
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||||
|
#endif
|
||||||
|
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
|
||||||
|
#define _SYNC_t OS_MutexID /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
||||||
|
|
||||||
/* The _FS_REENTRANT option switches the reentrancy (thread safe) of the FatFs module.
|
/* The _FS_REENTRANT option switches the reentrancy (thread safe) of the FatFs module.
|
||||||
/
|
/
|
||||||
@@ -181,8 +197,12 @@
|
|||||||
/ ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj
|
/ ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj
|
||||||
/ function must be added to the project. */
|
/ function must be added to the project. */
|
||||||
|
|
||||||
|
#if defined(PCBARM)
|
||||||
|
#define _FS_SHARE 3 /* 0:Disable or >=1:Enable */
|
||||||
|
#else
|
||||||
|
#define _FS_SHARE 2 /* 0:Disable or >=1:Enable */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define _FS_SHARE 0 /* 0:Disable or >=1:Enable */
|
|
||||||
/* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value
|
/* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value
|
||||||
defines how many files can be opened simultaneously. */
|
defines how many files can be opened simultaneously. */
|
||||||
|
|
||||||
|
|||||||
+25
-9
@@ -87,6 +87,31 @@ uint32_t Cmd_8_resp ;
|
|||||||
uint32_t Cmd_A41_resp ;
|
uint32_t Cmd_A41_resp ;
|
||||||
uint8_t cardType;
|
uint8_t cardType;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Lock / unlock functions */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex)
|
||||||
|
{
|
||||||
|
*mutex = CoCreateMutex();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ff_req_grant (_SYNC_t mutex)
|
||||||
|
{
|
||||||
|
CoEnterMutexSection(mutex);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ff_rel_grant (_SYNC_t mutex)
|
||||||
|
{
|
||||||
|
CoLeaveMutexSection(mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ff_del_syncobj (_SYNC_t mutex)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is
|
* Configure the MCI CLKDIV in the MCI_MR register. The max. for MCI clock is
|
||||||
* MCK/2 and corresponds to CLKDIV = 0
|
* MCK/2 and corresponds to CLKDIV = 0
|
||||||
@@ -970,16 +995,12 @@ uint32_t sd_cmd16()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern OS_MutexID sdMutex;
|
|
||||||
|
|
||||||
uint32_t sd_read_block(uint32_t block_no, uint32_t *data)
|
uint32_t sd_read_block(uint32_t block_no, uint32_t *data)
|
||||||
{
|
{
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
Hsmci *phsmci = HSMCI;
|
Hsmci *phsmci = HSMCI;
|
||||||
int32_t retry;
|
int32_t retry;
|
||||||
|
|
||||||
CoEnterMutexSection(sdMutex);
|
|
||||||
|
|
||||||
if (sd_card_ready()) {
|
if (sd_card_ready()) {
|
||||||
sd_cmd16();
|
sd_cmd16();
|
||||||
// Block size = 512, nblocks = 1
|
// Block size = 512, nblocks = 1
|
||||||
@@ -1005,7 +1026,6 @@ uint32_t sd_read_block(uint32_t block_no, uint32_t *data)
|
|||||||
/* Disable PDC */
|
/* Disable PDC */
|
||||||
phsmci->HSMCI_PTCR = HSMCI_PTCR_RXTDIS | HSMCI_PTCR_TXTDIS;
|
phsmci->HSMCI_PTCR = HSMCI_PTCR_RXTDIS | HSMCI_PTCR_TXTDIS;
|
||||||
|
|
||||||
CoLeaveMutexSection(sdMutex);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1015,8 +1035,6 @@ uint32_t sd_write_block( uint32_t block_no, uint32_t *data )
|
|||||||
Hsmci *phsmci = HSMCI;
|
Hsmci *phsmci = HSMCI;
|
||||||
int32_t retry;
|
int32_t retry;
|
||||||
|
|
||||||
CoEnterMutexSection(sdMutex);
|
|
||||||
|
|
||||||
if (sd_card_ready()) {
|
if (sd_card_ready()) {
|
||||||
|
|
||||||
// TRACE_ERROR("Sector %d ", block_no);
|
// TRACE_ERROR("Sector %d ", block_no);
|
||||||
@@ -1067,8 +1085,6 @@ uint32_t sd_write_block( uint32_t block_no, uint32_t *data )
|
|||||||
|
|
||||||
phsmci->HSMCI_MR &= ~(uint32_t)HSMCI_MR_PDCMODE;
|
phsmci->HSMCI_MR &= ~(uint32_t)HSMCI_MR_PDCMODE;
|
||||||
|
|
||||||
CoLeaveMutexSection(sdMutex);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -62,7 +62,6 @@ OS_STK debugStack[DEBUG_STACK_SIZE];
|
|||||||
OS_TCID audioTimer;
|
OS_TCID audioTimer;
|
||||||
OS_FlagID audioFlag;
|
OS_FlagID audioFlag;
|
||||||
|
|
||||||
OS_MutexID sdMutex;
|
|
||||||
OS_MutexID audioMutex;
|
OS_MutexID audioMutex;
|
||||||
OS_MutexID mixerMutex;
|
OS_MutexID mixerMutex;
|
||||||
#endif
|
#endif
|
||||||
@@ -1057,9 +1056,11 @@ void doSplash()
|
|||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
if (!main_thread_running) return;
|
if (!main_thread_running) return;
|
||||||
sleep(1/*ms*/);
|
sleep(1/*ms*/);
|
||||||
#else
|
#elif defined(PCBARM)
|
||||||
getADC_filt();
|
CoTickDelay(1);
|
||||||
#endif
|
#endif
|
||||||
|
getADC_filt();
|
||||||
|
|
||||||
uint16_t tsum = stickMoveValue();
|
uint16_t tsum = stickMoveValue();
|
||||||
|
|
||||||
if(keyDown() || (tsum!=inacSum)) return; //wait for key release
|
if(keyDown() || (tsum!=inacSum)) return; //wait for key release
|
||||||
@@ -3594,7 +3595,6 @@ int main(void)
|
|||||||
audioTimer = CoCreateTmr(TMR_TYPE_ONE_SHOT, 1000/(1000/CFG_SYSTICK_FREQ), 1000/(1000/CFG_SYSTICK_FREQ), audioTimerHandle);
|
audioTimer = CoCreateTmr(TMR_TYPE_ONE_SHOT, 1000/(1000/CFG_SYSTICK_FREQ), 1000/(1000/CFG_SYSTICK_FREQ), audioTimerHandle);
|
||||||
audioTaskId = CoCreateTask(audioTask, NULL, 7, &audioStack[AUDIO_STACK_SIZE-1], AUDIO_STACK_SIZE);
|
audioTaskId = CoCreateTask(audioTask, NULL, 7, &audioStack[AUDIO_STACK_SIZE-1], AUDIO_STACK_SIZE);
|
||||||
|
|
||||||
sdMutex = CoCreateMutex();
|
|
||||||
audioMutex = CoCreateMutex();
|
audioMutex = CoCreateMutex();
|
||||||
mixerMutex = CoCreateMutex();
|
mixerMutex = CoCreateMutex();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user