[sky9x] Revert to last version where massstorage was ok for all SDs!
[stock] Flash saving [stock] Voice mod port from er9x
This commit is contained in:
+158
-10
@@ -33,6 +33,39 @@
|
||||
|
||||
#include "open9x.h"
|
||||
|
||||
#if defined(PCBARM)
|
||||
#define MIXER_STACK_SIZE 500
|
||||
#define MENUS_STACK_SIZE 2000
|
||||
#define AUDIO_STACK_SIZE 500
|
||||
#define BT_STACK_SIZE 500
|
||||
#define DEBUG_STACK_SIZE 500
|
||||
|
||||
OS_TID mixerTaskId;
|
||||
OS_STK mixerStack[MIXER_STACK_SIZE];
|
||||
|
||||
OS_TID menusTaskId;
|
||||
OS_STK menusStack[MENUS_STACK_SIZE];
|
||||
|
||||
OS_TID audioTaskId;
|
||||
OS_STK audioStack[AUDIO_STACK_SIZE];
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
OS_TID btTaskId;
|
||||
OS_STK btStack[BT_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
OS_TID debugTaskId;
|
||||
OS_STK debugStack[DEBUG_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
OS_TCID audioTimer;
|
||||
OS_FlagID audioFlag;
|
||||
|
||||
OS_MutexID audioMutex;
|
||||
OS_MutexID mixerMutex;
|
||||
#endif
|
||||
|
||||
#if defined(SPLASH)
|
||||
const pm_uchar splashdata[] PROGMEM = { 'S','P','S',0,
|
||||
#include "s9xsplash.lbm"
|
||||
@@ -2601,7 +2634,7 @@ void perMain()
|
||||
}
|
||||
|
||||
#if defined(SDCARD) && !defined(SIMU)
|
||||
// sdPoll10mS();
|
||||
sdPoll10mS();
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@@ -3193,8 +3226,8 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
doSplash();
|
||||
|
||||
#if defined(PCBARM) && defined(SDCARD)
|
||||
for (int i=0; i<500 && sdState==SD_STATE_CONNECTED; i++) {
|
||||
CoTickDelay(1); // 2ms
|
||||
for (int i=0; i<500 && !Card_initialized; i++) {
|
||||
CoTickDelay(1); // 2ms
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3263,6 +3296,123 @@ void mixerTask(void * pdata)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move this code elsewhere
|
||||
extern "C" {
|
||||
/* Include AT91SAM3S-EK definitions and initialization API */
|
||||
#include <board/board.h>
|
||||
#include <board/board_memories.h>
|
||||
#include <pio/pio_it.h>
|
||||
|
||||
/* Include USB definitions */
|
||||
#include <usb/device/massstorage/MSDDriver.h>
|
||||
|
||||
/** Size of one block in bytes. */
|
||||
#define BLOCK_SIZE 512
|
||||
|
||||
/** Size of the MSD IO buffer in bytes (6K, more the better). */
|
||||
#define MSD_BUFFER_SIZE (12*BLOCK_SIZE)
|
||||
|
||||
/** LUN read/write buffer. */
|
||||
unsigned char msdBuffer[MSD_BUFFER_SIZE];
|
||||
|
||||
static void ConfigureUsbClock(void)
|
||||
{
|
||||
/* Enable PLLB for USB */
|
||||
PMC->CKGR_PLLBR = CKGR_PLLBR_DIVB(1)
|
||||
| CKGR_PLLBR_MULB(7)
|
||||
| CKGR_PLLBR_PLLBCOUNT_Msk;
|
||||
while((PMC->PMC_SR & PMC_SR_LOCKB) == 0); // TODO && (timeout++ < CLOCK_TIMEOUT));
|
||||
/* USB Clock uses PLLB */
|
||||
PMC->PMC_USB = PMC_USB_USBDIV(1) /* /2 */
|
||||
| PMC_USB_USBS; /* PLLB */
|
||||
}
|
||||
|
||||
/** Maximum number of LUNs which can be defined. */
|
||||
#define MAX_LUNS 1
|
||||
|
||||
/** Media index for different disks */
|
||||
#define DRV_SDMMC 0 /** SD card */
|
||||
|
||||
Media medias[MAX_LUNS];
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Local variables
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Device LUNs. */
|
||||
MSDLun luns[MAX_LUNS];
|
||||
|
||||
char *bytes2Str(char *str, uint32_t bytes)
|
||||
{
|
||||
if (bytes < 1024*100)
|
||||
sprintf(str, "%lu.%luK", bytes / 1024, (bytes % 1024) / 103);
|
||||
else if (bytes < 1024*1024)
|
||||
sprintf(str, "%luK", bytes / 1024);
|
||||
else if (bytes < 1024*1024*100)
|
||||
sprintf(str, "%lu.%luM", bytes / (1024*1024), (bytes % (1024*1024)) / 104858);
|
||||
else
|
||||
sprintf(str, "%luM", bytes / (1024*1024));
|
||||
return str;
|
||||
}
|
||||
|
||||
unsigned int msdReadTotal=0, msdWriteTotal=0;
|
||||
|
||||
static void MSDCallbacks_Data( unsigned char flowDirection, unsigned int dataLength,
|
||||
unsigned int fifoNullCount, unsigned int fifoFullCount )
|
||||
{
|
||||
if (flowDirection)
|
||||
msdReadTotal += dataLength;
|
||||
else
|
||||
msdWriteTotal += dataLength;
|
||||
|
||||
char rdStr[10];
|
||||
char wrStr[10];
|
||||
|
||||
sprintf(statusLineMsg, "USB Rd:%s Wr:%s", bytes2Str(rdStr, msdReadTotal), bytes2Str(wrStr, msdWriteTotal));
|
||||
showStatusLine();
|
||||
}
|
||||
|
||||
unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID);
|
||||
|
||||
void usbMassStorage()
|
||||
{
|
||||
static bool initialized = false;
|
||||
|
||||
if (usbPlugged()) {
|
||||
TRACE_DEBUG("usbMassStorage\n\r");
|
||||
|
||||
if (!initialized) {
|
||||
|
||||
ConfigureUsbClock();
|
||||
|
||||
/* Initialize LUN */
|
||||
MEDSdcard_Initialize(&(medias[DRV_SDMMC]), 0);
|
||||
|
||||
LUN_Init(&(luns[DRV_SDMMC]), &(medias[DRV_SDMMC]),
|
||||
msdBuffer, MSD_BUFFER_SIZE,
|
||||
0, 0, 0, 0,
|
||||
MSDCallbacks_Data);
|
||||
|
||||
/* BOT driver initialization */
|
||||
MSDDriver_Initialize(luns, 1);
|
||||
|
||||
// VBus_Configure();
|
||||
USBD_Connect();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/* Mass storage state machine */
|
||||
for (uint8_t i=0; i<50; i++)
|
||||
MSDDriver_StateMachine();
|
||||
}
|
||||
else {
|
||||
msdReadTotal = 0;
|
||||
msdWriteTotal = 0;
|
||||
}
|
||||
}
|
||||
} // extern "C"
|
||||
|
||||
void menusTask(void * pdata)
|
||||
{
|
||||
open9xInit();
|
||||
@@ -3411,24 +3561,22 @@ int main(void)
|
||||
usb_mode();
|
||||
}
|
||||
|
||||
sdInit();
|
||||
|
||||
CoInitOS();
|
||||
|
||||
#if defined(DEBUG)
|
||||
debugTaskId = CoCreateTaskEx(debugTask, NULL, DEBUG_PRIO, &debugStack[DEBUG_STACK_SIZE-1], DEBUG_STACK_SIZE, 1, false);
|
||||
debugTaskId = CoCreateTaskEx(debugTask, NULL, 10, &debugStack[DEBUG_STACK_SIZE-1], DEBUG_STACK_SIZE, 1, false);
|
||||
#endif
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
btTaskId = CoCreateTask(btTask, NULL, BT_PRIO, &btStack[BT_STACK_SIZE-1], BT_STACK_SIZE);
|
||||
btTaskId = CoCreateTask(btTask, NULL, 15, &btStack[BT_STACK_SIZE-1], BT_STACK_SIZE);
|
||||
#endif
|
||||
|
||||
mixerTaskId = CoCreateTask(mixerTask, NULL, MIXER_PRIO, &mixerStack[MIXER_STACK_SIZE-1], MIXER_STACK_SIZE);
|
||||
menusTaskId = CoCreateTask(menusTask, NULL, MENUS_PRIO, &menusStack[MENUS_STACK_SIZE-1], MENUS_STACK_SIZE);
|
||||
mixerTaskId = CoCreateTask(mixerTask, NULL, 5, &mixerStack[MIXER_STACK_SIZE-1], MIXER_STACK_SIZE);
|
||||
menusTaskId = CoCreateTask(menusTask, NULL, 10, &menusStack[MENUS_STACK_SIZE-1], MENUS_STACK_SIZE);
|
||||
|
||||
audioFlag = CoCreateFlag(true, false); // Auto-reset, start FALSE
|
||||
audioTimer = CoCreateTmr(TMR_TYPE_ONE_SHOT, 1000/(1000/CFG_SYSTICK_FREQ), 1000/(1000/CFG_SYSTICK_FREQ), audioTimerHandle);
|
||||
audioTaskId = CoCreateTask(audioTask, NULL, AUDIO_PRIO, &audioStack[AUDIO_STACK_SIZE-1], AUDIO_STACK_SIZE);
|
||||
audioTaskId = CoCreateTask(audioTask, NULL, 7, &audioStack[AUDIO_STACK_SIZE-1], AUDIO_STACK_SIZE);
|
||||
|
||||
audioMutex = CoCreateMutex();
|
||||
mixerMutex = CoCreateMutex();
|
||||
|
||||
Reference in New Issue
Block a user