]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_LPC1768_GCC_Rowley/main.c
Added BSP generation files to MicroBlaze directory.
[freertos] / Demo / CORTEX_LPC1768_GCC_Rowley / main.c
index 7294f97599ec1ee4e69aca28cf94e7a42646786e..dd9de74d4078409f1f05ccb9c6b8bd89a099a51d 100644 (file)
@@ -1,52 +1,54 @@
 /*\r
-       FreeRTOS.org V5.4.0 - Copyright (C) 2003-2009 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
-\r
-       FreeRTOS.org is free software; you can redistribute it and/or modify it\r
-       under the terms of the GNU General Public License (version 2) as published\r
-       by the Free Software Foundation and modified by the FreeRTOS exception.\r
-       **NOTE** The exception to the GPL is included to allow you to distribute a\r
-       combined work that includes FreeRTOS.org without being obliged to provide\r
-       the source code for any proprietary components.  Alternative commercial\r
-       license and support terms are also available upon request.  See the\r
-       licensing section of http://www.FreeRTOS.org for full details.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful, but WITHOUT\r
-       ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
-       FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-       more details.\r
-\r
-       You should have received a copy of the GNU General Public License along\r
-       with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
-       Temple Place, Suite 330, Boston, MA  02111-1307  USA.\r
-\r
-\r
-       ***************************************************************************\r
-       *                                                                         *\r
-       * Get the FreeRTOS eBook!  See http://www.FreeRTOS.org/Documentation      *\r
-       *                                                                         *\r
-       * This is a concise, step by step, 'hands on' guide that describes both   *\r
-       * general multitasking concepts and FreeRTOS specifics. It presents and   *\r
-       * explains numerous examples that are written using the FreeRTOS API.     *\r
-       * Full source code for all the examples is provided in an accompanying    *\r
-       * .zip file.                                                              *\r
-       *                                                                         *\r
-       ***************************************************************************\r
-\r
-       1 tab == 4 spaces!\r
-\r
-       Please ensure to read the configuration and relevant port sections of the\r
-       online documentation.\r
-\r
-       http://www.FreeRTOS.org - Documentation, latest information, license and\r
-       contact details.\r
-\r
-       http://www.SafeRTOS.com - A version that is certified for use in safety\r
-       critical systems.\r
-\r
-       http://www.OpenRTOS.com - Commercial support, development, porting,\r
-       licensing and training services.\r
+    FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+       \r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+    contact details.\r
+\r
+    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+    critical systems.\r
+\r
+    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+    licensing and training services.\r
 */\r
 \r
 \r
  * In addition to the standard demo tasks, the following tasks and tests are\r
  * defined and/or created within this file:\r
  *\r
- * "LCD" task - the LCD task is a 'gatekeeper' task.  It is the only task that\r
- * is permitted to access the display directly.  Other tasks wishing to write a\r
- * message to the LCD send the message on a queue to the LCD task instead of\r
- * accessing the LCD themselves.  The LCD task just blocks on the queue waiting\r
- * for messages - waking and displaying the messages as they arrive.  The use\r
- * of a gatekeeper in this manner permits both tasks and interrupts to write to\r
- * the LCD without worrying about mutual exclusion.  This is demonstrated by the\r
- * check hook (see below) which sends messages to the display even though it\r
- * executes from an interrupt context.\r
- *\r
  * "Check" hook -  This only executes fully every five seconds from the tick\r
  * hook.  Its main function is to check that all the standard demo tasks are\r
- * still operational.  Should any unexpected behaviour be discovered within a\r
- * demo task then the tick hook will write an error to the LCD (via the LCD task).\r
- * If all the demo tasks are executing with their expected behaviour then the\r
- * check hook writes PASS to the LCD (again via the LCD task), as described above.\r
- * The check hook also toggles LED 4 each time it executes.\r
- *\r
- * LED tasks - These just demonstrate how multiple instances of a single task\r
- * definition can be created.  Each LED task simply toggles an LED.  The task\r
- * parameter is used to pass the number of the LED to be toggled into the task.\r
+ * still operational.  The status can be viewed using on the Task Stats page\r
+ * served by the WEB server.\r
  *\r
  * "uIP" task -  This is the task that handles the uIP stack.  All TCP/IP\r
  * processing is performed in this task.\r
+ * \r
+ * "USB" task - Enumerates the USB device as a CDC class, then echoes back all\r
+ * received characters with a configurable offset (for example, if the offset\r
+ * is 1 and 'A' is received then 'B' will be sent back).  A dumb terminal such\r
+ * as Hyperterminal can be used to talk to the USB task.\r
  */\r
 \r
-/* Standard includes. */\r
-#include <stdio.h>\r
-\r
 /* Scheduler includes. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
-#include "queue.h"\r
-#include "semphr.h"\r
-\r
-/* Hardware library includes. */\r
-#include "LPC17xx_defs.h"\r
 \r
 /* Demo app includes. */\r
 #include "BlockQ.h"\r
 #include "QPeek.h"\r
 #include "recmutex.h"\r
 \r
-\r
-#if 0\r
-\r
-\r
-\r
-\r
-\r
 /*-----------------------------------------------------------*/\r
 \r
-/* The number of LED tasks that will be created. */\r
-#define mainNUM_LED_TASKS                                      ( 6 )\r
-\r
 /* The time between cycles of the 'check' functionality (defined within the\r
-tick hook. */\r
+tick hook). */\r
 #define mainCHECK_DELAY                                                ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
 \r
 /* Task priorities. */\r
@@ -130,7 +102,6 @@ tick hook. */
 #define mainSEM_TEST_PRIORITY                          ( tskIDLE_PRIORITY + 1 )\r
 #define mainBLOCK_Q_PRIORITY                           ( tskIDLE_PRIORITY + 2 )\r
 #define mainUIP_TASK_PRIORITY                          ( tskIDLE_PRIORITY + 3 )\r
-#define mainLCD_TASK_PRIORITY                          ( tskIDLE_PRIORITY + 2 )\r
 #define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )\r
 #define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY )\r
 #define mainFLASH_TASK_PRIORITY                                ( tskIDLE_PRIORITY + 2 )\r
@@ -139,11 +110,10 @@ tick hook. */
 handling library calls. */\r
 #define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 4 )\r
 \r
-/* The length of the queue used to send messages to the LCD task. */\r
-#define mainQUEUE_SIZE                                         ( 3 )\r
+/* The message displayed by the WEB server when all tasks are executing\r
+without an error being reported. */\r
+#define mainPASS_STATUS_MESSAGE                                "All tasks are executing without error."\r
 \r
-/* The task that is toggled by the check task. */\r
-#define mainCHECK_TASK_LED                                     ( 4 )\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -151,11 +121,6 @@ handling library calls. */
  */\r
 static void prvSetupHardware( void );\r
 \r
-/*\r
- * Very simple task that toggles an LED.\r
- */\r
-static void vLEDTask( void *pvParameters );\r
-\r
 /*\r
  * The task that handles the uIP stack.  All TCP/IP processing is performed in\r
  * this task.\r
@@ -163,21 +128,24 @@ static void vLEDTask( void *pvParameters );
 extern void vuIP_Task( void *pvParameters );\r
 \r
 /*\r
- * The LCD gatekeeper task as described in the comments at the top of this file.\r
- * */\r
-static void vLCDTask( void *pvParameters );\r
+ * The task that handles the USB stack.\r
+ */\r
+extern void vUSBTask( void *pvParameters );\r
+\r
+/*\r
+ * Simply returns the current status message for display on served WEB pages.\r
+ */\r
+char *pcGetTaskStatusMessage( void );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* The queue used to send messages to the LCD task. */\r
-xQueueHandle xLCDQueue;\r
+/* Holds the status message displayed by the WEB server. */\r
+static char *pcStatusMessage = mainPASS_STATUS_MESSAGE;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 int main( void )\r
 {\r
-long l;\r
-\r
        /* Configure the hardware for use by this demo. */\r
        prvSetupHardware();\r
 \r
@@ -193,17 +161,12 @@ long l;
     vStartRecursiveMutexTasks();\r
        vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );\r
 \r
+    /* Create the USB task. */\r
+    xTaskCreate( vUSBTask, ( signed char * ) "USB", configMINIMAL_STACK_SIZE, ( void * ) NULL, tskIDLE_PRIORITY, NULL );\r
+       \r
        /* Create the uIP task.  The WEB server runs in this task. */\r
     xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, ( void * ) NULL, mainUIP_TASK_PRIORITY, NULL );\r
 \r
-       /* Create the queue used by the LCD task.  Messages for display on the LCD\r
-       are received via this queue. */\r
-       xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );\r
-\r
-       /* Start the LCD gatekeeper task - as described in the comments at the top\r
-       of this file. */\r
-       xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE * 2, NULL, mainLCD_TASK_PRIORITY, NULL );\r
-\r
     /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
@@ -213,35 +176,9 @@ long l;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vLCDTask( void *pvParameters )\r
-{\r
-xLCDMessage xMessage;\r
-unsigned long ulRow = 0;\r
-char cIPAddr[ 17 ]; /* To fit max IP address length of xxx.xxx.xxx.xxx\0 */\r
-\r
-       ( void ) pvParameters;\r
-\r
-       /* The LCD gatekeeper task as described in the comments at the top of this\r
-       file. */\r
-\r
-       /* Initialise the LCD and display a startup message that includes the\r
-       configured IP address. */\r
-    sprintf( cIPAddr, "%d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );\r
-\r
-       for( ;; )\r
-       {\r
-               /* Wait for a message to arrive to be displayed. */\r
-               while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );\r
-\r
-       }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 void vApplicationTickHook( void )\r
 {\r
-static xLCDMessage xMessage = { "PASS" };\r
-static unsigned portLONG ulTicksSinceLastDisplay = 0;\r
-portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
+static unsigned long ulTicksSinceLastDisplay = 0;\r
 \r
        /* Called from every tick interrupt as described in the comments at the top\r
        of this file.\r
@@ -258,114 +195,67 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                /* Has an error been found in any task? */\r
                if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: GEN Q";\r
+                       pcStatusMessage = "An error has been detected in the Generic Queue test/demo.";\r
                }\r
                else if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: PEEK Q";\r
+                       pcStatusMessage = "An error has been detected in the Peek Queue test/demo.";\r
                }\r
                else if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: BLOCK Q";\r
+                       pcStatusMessage = "An error has been detected in the Block Queue test/demo.";\r
                }\r
                else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
                {\r
-                       xMessage.pcMessage = "ERROR: BLOCK TIME";\r
+                       pcStatusMessage = "An error has been detected in the Block Time test/demo.";\r
                }\r
            else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: SEMAPHR";\r
+               pcStatusMessage = "An error has been detected in the Semaphore test/demo.";\r
            }\r
            else if( xArePollingQueuesStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: POLL Q";\r
+               pcStatusMessage = "An error has been detected in the Poll Queue test/demo.";\r
            }\r
            else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: INT MATH";\r
+               pcStatusMessage = "An error has been detected in the Int Math test/demo.";\r
            }\r
            else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
            {\r
-               xMessage.pcMessage = "ERROR: REC MUTEX";\r
+               pcStatusMessage = "An error has been detected in the Mutex test/demo.";\r
            }\r
-\r
-               /* Send the message to the OLED gatekeeper for display.  The\r
-               xHigherPriorityTaskWoken parameter is not actually used here\r
-               as this function is running in the tick interrupt anyway - but\r
-               it must still be supplied. */\r
-               xHigherPriorityTaskWoken = pdFALSE;\r
-               xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken );\r
-\r
-               /* Also toggle and LED.  This can be done from here because in this port\r
-               the LED toggling functions don't use critical sections. */\r
-        vParTestToggleLED( mainCHECK_TASK_LED );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+char *pcGetTaskStatusMessage( void )\r
+{\r
+       /* Not bothered about a critical section here. */\r
+       return pcStatusMessage;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 void prvSetupHardware( void )\r
 {\r
        /* Disable peripherals power. */\r
-       PCONP = 0;\r
+       SC->PCONP = 0;\r
 \r
        /* Enable GPIO power. */\r
-       PCONP = PCONP_PCGPIO;\r
+       SC->PCONP = PCONP_PCGPIO;\r
 \r
        /* Disable TPIU. */\r
-       PINSEL10 = 0;\r
-\r
-       /* Disconnect the main PLL. */\r
-       PLL0CON &= ~PLLCON_PLLC;\r
-       PLL0FEED = PLLFEED_FEED1;\r
-       PLL0FEED = PLLFEED_FEED2;\r
-       while ((PLL0STAT & PLLSTAT_PLLC) != 0);\r
-\r
-       /* Turn off the main PLL. */\r
-       PLL0CON &= ~PLLCON_PLLE;\r
-       PLL0FEED = PLLFEED_FEED1;\r
-       PLL0FEED = PLLFEED_FEED2;\r
-       while ((PLL0STAT & PLLSTAT_PLLE) != 0);\r
-\r
-       /* No CPU clock divider. */\r
-       CCLKCFG = 0;\r
-\r
-       /* OSCEN. */\r
-       SCS = 0x20;\r
-       while ((SCS & 0x40) == 0);\r
-\r
-       /* Use main oscillator. */\r
-       CLKSRCSEL = 1;\r
-       PLL0CFG = (PLLCFG_MUL16 | PLLCFG_DIV1);\r
-\r
-       PLL0FEED = PLLFEED_FEED1;\r
-       PLL0FEED = PLLFEED_FEED2;\r
-\r
-       /*  Activate the PLL by turning it on then feeding the correct\r
-       sequence of bytes. */\r
-       PLL0CON  = PLLCON_PLLE;\r
-       PLL0FEED = PLLFEED_FEED1;\r
-       PLL0FEED = PLLFEED_FEED2;\r
-\r
-       /* 6x CPU clock divider (64 MHz) */\r
-       CCLKCFG = 5;\r
-\r
-       /*  Wait for the PLL to lock. */\r
-       while ((PLL0STAT & PLLSTAT_PLOCK) == 0);\r
-\r
-       /*  Connect the PLL. */\r
-       PLL0CON  = PLLCON_PLLC | PLLCON_PLLE;\r
-       PLL0FEED = PLLFEED_FEED1;\r
-       PLL0FEED = PLLFEED_FEED2;\r
+       PINCON->PINSEL10 = 0;\r
 \r
        /*  Setup the peripheral bus to be the same as the PLL output (64 MHz). */\r
-       PCLKSEL0 = 0x05555555;\r
+       SC->PCLKSEL0 = 0x05555555;\r
 \r
        /* Configure the LEDs. */\r
        vParTestInitialise();\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )\r
+void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
 {\r
        /* This function will get called if a task overflows its stack. */\r
 \r
@@ -384,630 +274,24 @@ const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE
        collecting run time statistical information - basically the percentage\r
        of CPU time that each task is utilising.  It is called automatically when\r
        the scheduler is started (assuming configGENERATE_RUN_TIME_STATS is set\r
-       to 1. */\r
+       to 1). */\r
 \r
        /* Power up and feed the timer. */\r
-       PCONP |= 0x02UL;\r
-       PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);\r
+       SC->PCONP |= 0x02UL;\r
+       SC->PCLKSEL0 = (SC->PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);\r
 \r
        /* Reset Timer 0 */\r
-       T0TCR = TCR_COUNT_RESET;\r
+       TIM0->TCR = TCR_COUNT_RESET;\r
 \r
        /* Just count up. */\r
-       T0CTCR = CTCR_CTM_TIMER;\r
+       TIM0->CTCR = CTCR_CTM_TIMER;\r
 \r
        /* Prescale to a frequency that is good enough to get a decent resolution,\r
        but not too fast so as to overflow all the time. */\r
-       T0PR =  ( configCPU_CLOCK_HZ / 10000UL ) - 1UL;\r
+       TIM0->PR =  ( configCPU_CLOCK_HZ / 10000UL ) - 1UL;\r
 \r
        /* Start the counter. */\r
-       T0TCR = TCR_COUNT_ENABLE;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#else\r
-\r
-\r
-\r
-\r
-\r
-/*----------------------------------------------------------------------*/\r
-/* FAT file system sample project for FatFs R0.06  (C)ChaN, 2008        */\r
-/*----------------------------------------------------------------------*/\r
-\r
-\r
-#include <string.h>\r
-#include "LPC17xx.h"\r
-#include "integer.h"\r
-//#include "interrupt.h"\r
-#include "comm.h"\r
-#include "monitor.h"\r
-#include "rtc.h"\r
-#include "diskio.h"\r
-#include "ff.h"\r
-\r
-#include "ctl_api.h"\r
-\r
-#include "usbhost_lpc1768.h"\r
-\r
-DWORD acc_size;                                /* Work register for fs command */\r
-WORD acc_files, acc_dirs;\r
-FILINFO finfo;\r
-\r
-char linebuf[120];                     /* Console input buffer */\r
-\r
-FATFS fatfs[_DRIVES];          /* File system object for each logical drive */\r
-FIL file1, file2;                      /* File objects */\r
-DIR dir;                                       /* Directory object */\r
-BYTE Buff[16384] __attribute__ ((aligned (4))) ;               /* Working buffer */\r
-\r
-volatile UINT Timer;           /* Performance timer (1kHz increment) */\r
-\r
-\r
-\r
-/*---------------------------------------------------------*/\r
-/* 1000Hz timer interrupt generated by TIMER0              */\r
-/*---------------------------------------------------------*/\r
-\r
-void Isr_TIMER0 (void)\r
-{\r
-       T0IR = 1;                       /* Clear irq flag */\r
-\r
-       Timer++;\r
-   MMC_TimerProc();\r
-}\r
-\r
-\r
-\r
-/*---------------------------------------------------------*/\r
-/* User Provided Timer Function for FatFs module           */\r
-/*---------------------------------------------------------*/\r
-/* This is a real time clock service to be called from     */\r
-/* FatFs module. Any valid time must be returned even if   */\r
-/* the system does not support a real time clock.          */\r
-/* This is not required in read-only configuration.        */\r
-\r
-\r
-DWORD get_fattime ()\r
-{\r
-       RTC rtc;\r
-\r
-       rtc_gettime(&rtc);\r
-\r
-       return          ((DWORD)(rtc.year) << 25)\r
-                       | ((DWORD)rtc.month << 21)\r
-                       | ((DWORD)rtc.mday << 16)\r
-                       | ((DWORD)rtc.hour << 11)\r
-                       | ((DWORD)rtc.min << 5)\r
-                       | ((DWORD)rtc.sec >> 1);\r
-}\r
-\r
-\r
-/*--------------------------------------------------------------------------*/\r
-/* Monitor                                                                  */\r
-/*--------------------------------------------------------------------------*/\r
-\r
-static\r
-FRESULT scan_files (char* path)\r
-{\r
-       DIR dirs;\r
-       FRESULT res;\r
-       BYTE i;\r
-\r
-\r
-       if ((res = f_opendir(&dirs, path)) == FR_OK) {\r
-               i = strlen(path);\r
-               while (((res = f_readdir(&dirs, &finfo)) == FR_OK) && finfo.fname[0]) {\r
-                       if (finfo.fattrib & AM_DIR) {\r
-                               acc_dirs++;\r
-                               *(path+i) = '/'; strcpy(path+i+1, &finfo.fname[0]);\r
-                               res = scan_files(path);\r
-                               *(path+i) = '\0';\r
-                               if (res != FR_OK) break;\r
-                       } else {\r
-                               acc_files++;\r
-                               acc_size += finfo.fsize;\r
-                       }\r
-               }\r
-       }\r
-\r
-       return res;\r
-}\r
-\r
-\r
-\r
-static\r
-void put_rc (FRESULT rc)\r
-{\r
-       const char *p;\r
-       static const char str[] =\r
-               "OK\0" "NOT_READY\0" "NO_FILE\0" "FR_NO_PATH\0" "INVALID_NAME\0" "INVALID_DRIVE\0"\r
-               "DENIED\0" "EXIST\0" "RW_ERROR\0" "WRITE_PROTECTED\0" "NOT_ENABLED\0"\r
-               "NO_FILESYSTEM\0" "INVALID_OBJECT\0" "MKFS_ABORTED\0";\r
-       FRESULT i;\r
-\r
-       for (p = str, i = 0; i != rc && *p; i++) {\r
-               while(*p++);\r
-       }\r
-       xprintf("rc=%u FR_%s\n", (UINT)rc, p);\r
-}\r
-\r
-\r
-\r
-static\r
-void IoInit (void)\r
-{\r
-#define PLL_N          1UL\r
-#define PLL_M          12UL\r
-#define CCLK_DIV       4   // 288MHz / 4 = 72MHz\r
-#define USBCLK_DIV      6   // 288MHz / 6 = 48MHz\r
-\r
-//_RB_ if ( PLLSTAT & (1 << 25) ) {\r
-//_RB_         PLLCON = 1;                             /* Disconnect PLL output if PLL is in use */\r
-//_RB_         PLLFEED = 0xAA; PLLFEED = 0x55;\r
-//_RB_ }\r
-//_RB_ PLLCON = 0;                             /* Disable PLL */\r
-//_RB_ PLLFEED = 0xAA; PLLFEED = 0x55;\r
-       CLKSRCSEL = 0;                  /* Select IRC (4MHz) as the PLL clock source */\r
-\r
-   SCS |= 0x20;                        /* Enable main OSC */\r
-   while( !(SCS & 0x40) );     /* Wait until main OSC is usable */\r
-   CLKSRCSEL = 0x1;            /* select main OSC, 12MHz, as the PLL clock source */\r
-\r
-//_RB_ PLLCFG = ((PLL_N - 1) << 16) | (PLL_M - 1);     /* Re-configure PLL */\r
-//_RB_ PLLFEED = 0xAA; PLLFEED = 0x55;\r
-//_RB_ PLLCON = 1;                             /* Enable PLL */\r
-//_RB_ PLLFEED = 0xAA; PLLFEED = 0x55;\r
-\r
-//_RB_ while ((PLLSTAT & (1 << 26)) == 0);     /* Wait for PLL locked */\r
-\r
-       CCLKCFG = CCLK_DIV-1;   /* Select CCLK frequency (divide ratio of hclk) */\r
-   USBCLKCFG = USBCLK_DIV-1;           /* usbclk = 288 MHz/6 = 48 MHz */\r
-//_RB_   PLLCON = 3;                           /* Connect PLL output to the sysclk */\r
-//_RB_ PLLFEED = 0xAA; PLLFEED = 0x55;\r
-\r
-//_RB_ MAMCR = 0;                              /* Configure MAM for 72MHz operation */\r
-//_RB_ MAMTIM = 3;\r
-//_RB_ MAMCR = 2;\r
-\r
-       PCLKSEL0 = 0x00000000;  /* Initialize peripheral clock to default */\r
-       PCLKSEL1 = 0x00000000;\r
-\r
-//     ClearVector();                  /* Initialie VIC */\r
-\r
-       SCS |= 1;                               /* Enable FIO0 and FIO1 */\r
-\r
-   FIO1DIR = (1<<26);                      /* Disable Piezo */\r
-       FIO2CLR = (1<<26);\r
-\r
-       FIO2DIR = (1<<30);                      /* Heartbeat LED output */\r
-       FIO2CLR = (1<<30);\r
-\r
-       /* Initialize Timer0 as 1kHz interval timer */\r
-//     RegisterVector(TIMER0_INT, Isr_TIMER0, PRI_LOWEST, CLASS_IRQ);\r
-//_RB_   ctl_set_isr(TIMER0_INT, PRI_LOWEST, CTL_ISR_TRIGGER_FIXED, Isr_TIMER0, 0);\r
-//_RB_   ctl_unmask_isr(TIMER0_INT);\r
-\r
-   T0CTCR = 0;\r
-       T0MR0 = 18000 - 1;              /* 18M / 1k = 18000 */\r
-       T0MCR = 0x3;                    /* Clear TC and Interrupt on MR0 match */\r
-       T0TCR = 1;\r
-\r
-       uart0_init();                   /* Initialize UART0 */\r
-\r
-//     IrqEnable();                    /* Enable Irq */\r
-   ctl_global_interrupts_enable();\r
-}\r
-\r
-\r
-\r
-int main (void)\r
-{\r
-       char *ptr, *ptr2;\r
-       long p1, p2, p3;\r
-       BYTE res, b1;\r
-       WORD w1;\r
-       UINT s1, s2, cnt, blen = sizeof(Buff);\r
-       DWORD ofs = 0, sect = 0;\r
-       FATFS *fs;                              /* Pointer to file system object */\r
-       RTC rtc;\r
-\r
-   BYTE ActiveDisk = 0;\r
-\r
-   USB_INT32S  rc;\r
-\r
-       IoInit();\r
-   Host_Init();\r
-\r
-       xputs("\nFatFs module test monitor for LPC2468\n");\r
-   xputc('>');\r
-   ptr = linebuf;\r
-\r
-       for (;;) {\r
-      if (ConnectedDeviceState == DEVICE_CONNECTED) {\r
-         ConnectedDeviceState = DEVICE_CLEAR;\r
-         xprintf("USB Mass Storage device detected\n");\r
-         rc = Host_EnumDev();       // Enumerate the device connected\r
-\r
-         if (rc == OK) {\r
-            xprintf("USB device enumerated\n");\r
-         }\r
-         xputc('>');\r
-      }\r
-      else if (ConnectedDeviceState == DEVICE_DISCONNECTED) {\r
-         ConnectedDeviceState = DEVICE_CLEAR;\r
-         Host_Init();         // FreeDevice();\r
-         xprintf("Device Disconnected\n");\r
-         xputc('>');\r
-      }\r
-\r
-               if (get_line(ptr, sizeof(linebuf)) == '\r') {\r
-         switch (*ptr++) {\r
-\r
-         case 'm' :\r
-            switch (*ptr++) {\r
-            case 'd' : /* md <address> [<count>] - Dump memory */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               if (!xatoi(&ptr, &p2)) p2 = 128;\r
-               for (ptr=(char*)p1; p2 >= 16; ptr += 16, p2 -= 16) {\r
-                  put_dump((BYTE*)ptr, (UINT)ptr, 16);\r
-               }\r
-               if (p2) put_dump((BYTE*)ptr, (UINT)ptr, p2);\r
-               break;\r
-            }\r
-            break;\r
-\r
-         case 'd' :\r
-            switch (*ptr++) {\r
-            case 'a' :  /* da [#] - select active disk */\r
-               if (xatoi(&ptr, &p1)) {\r
-                  ActiveDisk = (BYTE)p1;\r
-               }\r
-               ActiveDisk = VerifyActiveDisk(ActiveDisk);\r
-               break;\r
-\r
-            case 'd' : /* dd [<lba>] - Dump secrtor */\r
-               if (!xatoi(&ptr, &p2)) p2 = sect;\r
-               res = disk_read(ActiveDisk, Buff, p2, 1);\r
-//               res = disk_read(ActiveDisk, gUsbXferBuffer, p2, 1);\r
-               if (res) { xprintf("rc=%d\n", (WORD)res); break; }\r
-               sect = p2 + 1;\r
-               xprintf("Sector:%lu\n", p2);\r
-               for (ptr=(char*)Buff, ofs = 0; ofs < 0x200; ptr+=16, ofs+=16) {\r
-//               for (ptr=(char*)gUsbXferBuffer, ofs = 0; ofs < 0x200; ptr+=16, ofs+=16) {\r
-                  put_dump((BYTE*)ptr, ofs, 16);\r
-               }\r
-               break;\r
-\r
-            case 'i' : /* di - Initialize disk */\r
-               xprintf("rc=%d\n", (WORD)disk_initialize(ActiveDisk));\r
-               break;\r
-\r
-            case 's' : /* ds <phy_drv#> - Show disk status */\r
-//             if (!xatoi(&ptr, &p1)) break;\r
-               if (disk_ioctl(ActiveDisk, GET_SECTOR_COUNT, &p2) == RES_OK)\r
-                  { xprintf("Drive size: %lu sectors\n", p2); }\r
-               if (disk_ioctl(ActiveDisk, GET_SECTOR_SIZE, &w1) == RES_OK)\r
-                  { xprintf("Sector size: %u\n", w1); }\r
-               if (disk_ioctl(ActiveDisk, GET_BLOCK_SIZE, &p2) == RES_OK)\r
-                  { xprintf("Erase block size: %lu sectors\n", p2); }\r
-               if (disk_ioctl(ActiveDisk, MMC_GET_TYPE, &b1) == RES_OK)\r
-                  { xprintf("MMC/SDC type: %u\n", b1); }\r
-               if (disk_ioctl(ActiveDisk, MMC_GET_CSD, Buff) == RES_OK)\r
-                  { xputs("CSD:\n"); put_dump(Buff, 0, 16); }\r
-               if (disk_ioctl(ActiveDisk, MMC_GET_CID, Buff) == RES_OK)\r
-                  { xputs("CID:\n"); put_dump(Buff, 0, 16); }\r
-               if (disk_ioctl(ActiveDisk, MMC_GET_OCR, Buff) == RES_OK)\r
-                  { xputs("OCR:\n"); put_dump(Buff, 0, 4); }\r
-               if (disk_ioctl(ActiveDisk, MMC_GET_SDSTAT, Buff) == RES_OK) {\r
-                  xputs("SD Status:\n");\r
-                  for (s1 = 0; s1 < 64; s1 += 16) put_dump(Buff+s1, s1, 16);\r
-               }\r
-               break;\r
-            }\r
-            break;\r
-\r
-         case 'b' :\r
-            switch (*ptr++) {\r
-            case 'd' : /* bd <addr> - Dump R/W buffer */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               for (ptr=(char*)&Buff[p1], ofs = p1, cnt = 32; cnt; cnt--, ptr+=16, ofs+=16) {\r
-                  put_dump((BYTE*)ptr, ofs, 16);\r
-               }\r
-               break;\r
-\r
-            case 'e' : /* be <addr> [<data>] ... - Edit R/W buffer */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               if (xatoi(&ptr, &p2)) {\r
-                  do {\r
-                     Buff[p1++] = (BYTE)p2;\r
-                  } while (xatoi(&ptr, &p2));\r
-                  break;\r
-               }\r
-               for (;;) {\r
-                  xprintf("%04X %02X-", (WORD)(p1), (WORD)Buff[p1]);\r
-                  get_line(linebuf, sizeof(linebuf));\r
-                  ptr = linebuf;\r
-                  if (*ptr == '.') break;\r
-                  if (*ptr < ' ') { p1++; continue; }\r
-                  if (xatoi(&ptr, &p2))\r
-                     Buff[p1++] = (BYTE)p2;\r
-                  else\r
-                     xputs("???\n");\r
-               }\r
-               break;\r
-\r
-            case 'r' : /* br <lba> [<num>] - Read disk into R/W buffer */\r
-               if (!xatoi(&ptr, &p2)) break;\r
-               if (!xatoi(&ptr, &p3)) p3 = 1;\r
-               xprintf("rc=%u\n", (WORD)disk_read(ActiveDisk, Buff, p2, p3));\r
-               break;\r
-\r
-            case 'w' : /* bw <lba> [<num>] - Write R/W buffer into disk */\r
-               if (!xatoi(&ptr, &p2)) break;\r
-               if (!xatoi(&ptr, &p3)) p3 = 1;\r
-               xprintf("rc=%u\n", (WORD)disk_write(ActiveDisk, Buff, p2, p3));\r
-               break;\r
-\r
-            case 'f' : /* bf <val> - Fill working buffer */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               memset(Buff, (BYTE)p1, sizeof(Buff));\r
-               break;\r
-            }\r
-            break;\r
-\r
-         case 'f' :\r
-            switch (*ptr++) {\r
-\r
-            case 'i' : /* fi <log drv#> - Initialize logical drive */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               put_rc(f_mount((BYTE)p1, &fatfs[p1]));\r
-//               put_rc(f_mount(ActiveDisk, &fatfs[ActiveDisk]));\r
-               break;\r
-\r
-            case 's' : /* fs [<path>] - Show logical drive status */\r
-               res = f_getfree(ptr, (DWORD*)&p2, &fs);\r
-               if (res) { put_rc(res); break; }\r
-               xprintf("FAT type = %u\nBytes/Cluster = %lu\nNumber of FATs = %u\n"\r
-                  "Root DIR entries = %u\nSectors/FAT = %lu\nNumber of clusters = %lu\n"\r
-                  "FAT start (lba) = %lu\nDIR start (lba,cluster) = %lu\nData start (lba) = %lu\n\n",\r
-                                               (WORD)fs->fs_type, (DWORD)fs->csize * 512, (WORD)fs->n_fats,\r
-                                               fs->n_rootdir, fs->sects_fat, (DWORD)fs->max_clust - 2,\r
-                                               fs->fatbase, fs->dirbase, fs->database\r
-               );\r
-               acc_size = acc_files = acc_dirs = 0;\r
-               res = scan_files(ptr);\r
-               if (res) { put_rc(res); break; }\r
-               xprintf("%u files, %lu bytes.\n%u folders.\n"\r
-                                               "%lu KB total disk space.\n%lu KB available.\n",\r
-                                               acc_files, acc_size, acc_dirs,\r
-                                               (fs->max_clust - 2) * (fs->csize / 2), p2 * (fs->csize / 2)\r
-               );\r
-               break;\r
-\r
-            case 'l' : /* fl [<path>] - Directory listing */\r
-               res = f_opendir(&dir, ptr);\r
-               if (res) { put_rc(res); break; }\r
-               p1 = s1 = s2 = 0;\r
-               for(;;) {\r
-                  res = f_readdir(&dir, &finfo);\r
-                  if ((res != FR_OK) || !finfo.fname[0]) break;\r
-                  if (finfo.fattrib & AM_DIR) {\r
-                     s2++;\r
-                  } else {\r
-                     s1++; p1 += finfo.fsize;\r
-                  }\r
-                  xprintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu  %s\n",\r
-                                                       (finfo.fattrib & AM_DIR) ? 'D' : '-',\r
-                                                       (finfo.fattrib & AM_RDO) ? 'R' : '-',\r
-                                                       (finfo.fattrib & AM_HID) ? 'H' : '-',\r
-                                                       (finfo.fattrib & AM_SYS) ? 'S' : '-',\r
-                                                       (finfo.fattrib & AM_ARC) ? 'A' : '-',\r
-                     (finfo.fdate >> 9) + 1980, (finfo.fdate >> 5) & 15, finfo.fdate & 31,\r
-                                                       (finfo.ftime >> 11), (finfo.ftime >> 5) & 63,\r
-                                                       finfo.fsize, &(finfo.fname[0]));\r
-               }\r
-               xprintf("%4u File(s),%10lu bytes total\n%4u Dir(s)", s1, p1, s2);\r
-               if (f_getfree(ptr, (DWORD*)&p1, &fs) == FR_OK)\r
-                  xprintf(", %10lu bytes free\n", p1 * fs->csize * 512);\r
-               break;\r
-\r
-            case 'o' : /* fo <mode> <file> - Open a file */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               put_rc(f_open(&file1, ptr, (BYTE)p1));\r
-               break;\r
-\r
-            case 'c' : /* fc - Close a file */\r
-               put_rc(f_close(&file1));\r
-               break;\r
-\r
-            case 'e' : /* fe - Seek file pointer */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               res = f_lseek(&file1, p1);\r
-               put_rc(res);\r
-               if (res == FR_OK)\r
-                  xprintf("fptr=%lu(0x%lX)\n", file1.fptr, file1.fptr);\r
-               break;\r
-\r
-            case 'd' : /* fd <len> - read and dump file from current fp */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               ofs = file1.fptr;\r
-               while (p1) {\r
-                  if ((UINT)p1 >= 16) { cnt = 16; p1 -= 16; }\r
-                  else                                 { cnt = p1; p1 = 0; }\r
-                  res = f_read(&file1, Buff, cnt, &cnt);\r
-                  if (res != FR_OK) { put_rc(res); break; }\r
-                  if (!cnt) break;\r
-                  put_dump(Buff, ofs, cnt);\r
-                  ofs += 16;\r
-               }\r
-               break;\r
-\r
-            case 'r' : /* fr <len> - read file */\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               p2 = 0;\r
-               Timer = 0;\r
-               while (p1) {\r
-                  if ((UINT)p1 >= blen) {\r
-                     cnt = blen; p1 -= blen;\r
-                  } else {\r
-                     cnt = p1; p1 = 0;\r
-                  }\r
-                  res = f_read(&file1, Buff, cnt, &s2);\r
-                  if (res != FR_OK) { put_rc(res); break; }\r
-                  p2 += s2;\r
-                  if (cnt != s2) break;\r
-               }\r
-               xprintf("%lu bytes read with %lu kB/sec.\n", p2, p2 / Timer);\r
-               break;\r
-\r
-            case 'w' : /* fw <len> <val> - write file */\r
-               if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break;\r
-               memset(Buff, (BYTE)p2, blen);\r
-               p2 = 0;\r
-               Timer = 0;\r
-               while (p1) {\r
-                  if ((UINT)p1 >= blen) {\r
-                     cnt = blen; p1 -= blen;\r
-                  } else {\r
-                     cnt = p1; p1 = 0;\r
-                  }\r
-                  res = f_write(&file1, Buff, cnt, &s2);\r
-                  if (res != FR_OK) { put_rc(res); break; }\r
-                  p2 += s2;\r
-                  if (cnt != s2) break;\r
-               }\r
-               xprintf("%lu bytes written with %lu kB/sec.\n", p2, p2 / Timer);\r
-               break;\r
-\r
-            case 'n' : /* fn <old_name> <new_name> - Change file/dir name */\r
-               while (*ptr == ' ') ptr++;\r
-               ptr2 = strchr(ptr, ' ');\r
-               if (!ptr2) break;\r
-               *ptr2++ = 0;\r
-               while (*ptr2 == ' ') ptr2++;\r
-               put_rc(f_rename(ptr, ptr2));\r
-               break;\r
-\r
-            case 'u' : /* fu <name> - Unlink a file or dir */\r
-               put_rc(f_unlink(ptr));\r
-               break;\r
-\r
-            case 'v' : /* fv - Truncate file */\r
-               put_rc(f_truncate(&file1));\r
-               break;\r
-\r
-            case 'k' : /* fk <name> - Create a directory */\r
-               put_rc(f_mkdir(ptr));\r
-               break;\r
-\r
-            case 'a' : /* fa <atrr> <mask> <name> - Change file/dir attribute */\r
-               if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2)) break;\r
-               put_rc(f_chmod(ptr, p1, p2));\r
-               break;\r
-\r
-            case 't' : /* ft <year> <month> <day> <hour> <min> <sec> <name> - Change timestamp */\r
-               if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break;\r
-               finfo.fdate = ((p1 - 1980) << 9) | ((p2 & 15) << 5) | (p3 & 31);\r
-               if (!xatoi(&ptr, &p1) || !xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break;\r
-               finfo.ftime = ((p1 & 31) << 11) | ((p1 & 63) << 5) | ((p1 >> 1) & 31);\r
-               put_rc(f_utime(ptr, &finfo));\r
-               break;\r
-\r
-            case 'x' : /* fx <src_name> <dst_name> - Copy file */\r
-               while (*ptr == ' ') ptr++;\r
-               ptr2 = strchr(ptr, ' ');\r
-               if (!ptr2) break;\r
-               *ptr2++ = 0;\r
-               while (*ptr2 == ' ') ptr2++;\r
-               xprintf("Opening \"%s\"", ptr);\r
-               res = f_open(&file1, ptr, FA_OPEN_EXISTING | FA_READ);\r
-               xputc('\n');\r
-               if (res) {\r
-                  put_rc(res);\r
-                  break;\r
-               }\r
-               xprintf("Creating \"%s\"", ptr2);\r
-               res = f_open(&file2, ptr2, FA_CREATE_ALWAYS | FA_WRITE);\r
-               xputc('\n');\r
-               if (res) {\r
-                  put_rc(res);\r
-                  f_close(&file1);\r
-                  break;\r
-               }\r
-               xprintf("Copying file...");\r
-               Timer = 0;\r
-               p1 = 0;\r
-               for (;;) {\r
-                  res = f_read(&file1, Buff, blen, &s1);\r
-                  if (res || s1 == 0) break;   /* error or eof */\r
-                  res = f_write(&file2, Buff, s1, &s2);\r
-                  p1 += s2;\r
-                  if (res || s2 < s1) break;   /* error or disk full */\r
-               }\r
-               xprintf("%lu bytes copied with %lu kB/sec.\n", p1, p1 / Timer);\r
-               f_close(&file1);\r
-               f_close(&file2);\r
-               break;\r
-#if _USE_MKFS\r
-            case 'm' : /* fm <partition rule> <cluster size> - Create file system */\r
-               if (!xatoi(&ptr, &p2) || !xatoi(&ptr, &p3)) break;\r
-               xprintf("The drive %u will be formatted. Are you sure? (Y/n)=", ActiveDisk);\r
-               get_line(ptr, sizeof(linebuf));\r
-               if (*ptr == 'Y')\r
-                  put_rc(f_mkfs(ActiveDisk, (BYTE)p2, (WORD)p3));\r
-               break;\r
-#endif\r
-            case 'z' : /* fz [<rw size>] - Change R/W length for fr/fw/fx command */\r
-               if (xatoi(&ptr, &p1) && p1 >= 1 && p1 <= sizeof(Buff))\r
-                  blen = p1;\r
-               xprintf("blen=%u\n", blen);\r
-               break;\r
-            }\r
-            break;\r
-\r
-         case 't' :    /* t [<year> <mon> <mday> <hour> <min> <sec>] */\r
-            if (xatoi(&ptr, &p1)) {\r
-               rtc.year = (WORD)p1;\r
-               xatoi(&ptr, &p1); rtc.month = (BYTE)p1;\r
-               xatoi(&ptr, &p1); rtc.mday = (BYTE)p1;\r
-               xatoi(&ptr, &p1); rtc.hour = (BYTE)p1;\r
-               xatoi(&ptr, &p1); rtc.min = (BYTE)p1;\r
-               if (!xatoi(&ptr, &p1)) break;\r
-               rtc.sec = (BYTE)p1;\r
-               rtc_settime(&rtc);\r
-            }\r
-            rtc_gettime(&rtc);\r
-            xprintf("%u/%u/%u %02u:%02u:%02u\n", rtc.year, rtc.month, rtc.mday, rtc.hour, rtc.min, rtc.sec);\r
-            break;\r
-\r
-         case 'u' : /* usb test commands */\r
-            switch (*ptr++) {\r
-\r
-            case 's' : /* print bulk size */\r
-            xprintf("MS Bulk size %lu\n", MS_BlkSize);\r
-            break;\r
-            }\r
-         break;\r
-         }\r
-         xputc('>');\r
-         ptr = linebuf;\r
-      }\r
-   }\r
-}\r
-\r
-void vApplicationTickHook( void )\r
-{\r
+       TIM0->TCR = TCR_COUNT_ENABLE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-\r
-void vConfigureTimerForRunTimeStats( void )\r
-{\r
-}\r
-\r
-void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )\r
-{\r
-}\r
-xQueueHandle xLCDQueue;\r
-#endif\r