[sky9x] All fields in SD info submenu now displayed

[sky9x] Model Backup / Restore should be ok
[sky9x] SD unmounted when USB masstorage
[sky9x / gruvin9x] Header added to Model Backups
[sky9x / gruvin9x] Log file closed when Logging function stopped
+ Cleaning session
This commit is contained in:
bsongis
2012-09-28 16:02:13 +00:00
parent d8be36e2f4
commit 121c41719d
429 changed files with 467 additions and 78062 deletions
+1 -118
View File
@@ -3308,123 +3308,6 @@ 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();
@@ -3433,7 +3316,7 @@ void menusTask(void * pdata)
perMain();
for (uint8_t i=0; i<5; i++) {
usbMassStorage();
CoTickDelay(1); // 10ms for now
CoTickDelay(1); // 5*2ms for now
}
}