/** * \brief usb_massstorage Application entry point. * * Configures UART, * Configures TC0, USB MSD Driver and run it. * * \return Unused (ANSI-C compatibility). */ int main( void ) { sSdCard *pSd = 0; /* Disable watchdog */ WDT_Disable( WDT ) ; SCB_EnableICache(); SCB_EnableDCache(); #if defined LUN_RAMDISK /* Enable SDRAM */ BOARD_ConfigureSdram(); #endif TRACE_INFO("-- USB Device Mass Storage Example %s --\n\r", SOFTPACK_VERSION); TRACE_INFO("-- %s\n\r", BOARD_NAME); TRACE_INFO("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); /* If they are present, configure Vbus & Wake-up pins */ PIO_InitializeInterrupts(0); /* Initialize all USB power (off) */ _ConfigureUotghs(); /* Initialize PIO pins */ _ConfigurePIOs(); /* Initialize drivers */ _ConfigureDrivers(); _MemoriesInitialize(pSd); /* BOT driver initialization */ MSDDriver_Initialize(&msdDriverDescriptors, luns, MAX_LUNS); /* connect if needed */ USBD_Connect(); while (1) { /* Mass storage state machine */ if (USBD_GetState() < USBD_STATE_CONFIGURED){} else { MSDDriver_StateMachine(); if (msdRefresh) { msdRefresh = 0; if (msdWriteTotal < 50 * 1000) { /* Flush Disk Media */ } msdWriteTotal = 0; } } } }
/** * Initializes drivers and start the USB CDCMSD device. */ int main(void) { uint8_t usbConnected = 0, serialON = 0; /* Disable watchdog */ WDT_Disable(WDT); SCB_EnableICache(); SCB_EnableDCache(); printf("-- USB CDCMSD Device Project %s --\n\r", SOFTPACK_VERSION); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s With %s--\n\r", __DATE__, __TIME__ , COMPILER_NAME); /* If they are present, configure Vbus & Wake-up pins */ PIO_InitializeInterrupts(0); /* If there is on board power, switch it off */ _ConfigureUotghs(); /* ----- MSD Function Initialize */ /* Configure memories */ _MemoriesInitialize(); /* USB CDCMSD driver initialization */ CDCMSDDriver_Initialize(&cdcmsddDriverDescriptors, luns, MAX_LUNS); /* connect if needed */ USBD_Connect(); /* Driver loop */ while (1) { /* Device is not configured */ if (USBD_GetState() < USBD_STATE_CONFIGURED) { if (usbConnected) { printf("-I- USB Disconnect/Suspend\n\r"); usbConnected = 0; /* Serial port closed */ isSerialPortON = 0; } } else { if (usbConnected == 0) { printf("-I- USB Connect\n\r"); usbConnected = 1; } if (!serialON && isSerialPortON) { printf("-I- SerialPort ON\n\r"); /* Start receiving data on the USART */ /* Start receiving data on the USB */ CDCDSerial_Read(usbSerialBuffer0, DATAPACKETSIZE, 0, 0); serialON = 1; } else if (serialON && !isSerialPortON) { printf("-I- SeriaoPort OFF\n\r"); serialON = 0; } MSDFunction_StateMachine(); if (msdRefresh) { msdRefresh = 0; if (msdWriteTotal < 50 * 1000) { /* Flush Disk Media */ } msdWriteTotal = 0; } } } }