]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/ARM7_LPC2368_Eclipse/RTOSDemo/main.c
Update version number to 8.1.2 after moving the defaulting of configUSE_PORT_OPTIMISE...
[freertos] / FreeRTOS / Demo / ARM7_LPC2368_Eclipse / RTOSDemo / main.c
index 4fab1bcb4c7f9b538db19c0194ecb19193324969..7b5e8ca757d6240d08a2beb6d3862c4e3841de51 100644 (file)
@@ -1,48 +1,38 @@
 /*\r
-    FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+    All rights reserved\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
-    http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\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
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\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
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
      *                                                                       *\r
-     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
-     *                                                                       *\r
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *    Thank you!                                                         *\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
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
 \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.\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
-    details. You should have received a copy of the GNU General Public License\r
-    and the FreeRTOS license exception along with FreeRTOS; if not itcan be\r
-    viewed here: http://www.freertos.org/a00114.html and also obtained by\r
-    writing to Real Time Engineers Ltd., contact details for whom are available\r
-    on the FreeRTOS WEB site.\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
 \r
     1 tab == 4 spaces!\r
 \r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-\r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
     license and Real Time Engineers Ltd. contact details.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
-    fully thread aware and reentrant UDP/IP stack.\r
-\r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
-    Integrity Systems, who sell the code with commercial support, \r
-    indemnification and middleware, under the OpenRTOS brand.\r
-    \r
-    http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
-    engineered and independently SIL3 certified version for use in safety and \r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
     mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
 */\r
 \r
 /*\r
  * for messages - waking and displaying the messages as they arrive.\r
  *\r
  * "Check" hook -  This only executes every five seconds from the tick hook.\r
- * Its main function is to check that all the standard demo tasks are still \r
- * operational.  Should any unexpected behaviour within a demo task be discovered \r
- * the tick hook will write an error to the LCD (via the LCD task).  If all the \r
- * demo tasks are executing with their expected behaviour then the check task \r
+ * Its main function is to check that all the standard demo tasks are still\r
+ * operational.  Should any unexpected behaviour within a demo task be discovered\r
+ * the tick hook will write an error to the LCD (via the LCD task).  If all the\r
+ * demo tasks are executing with their expected behaviour then the check task\r
  * writes PASS to the LCD (again via the LCD task), as described above.\r
  *\r
  * "uIP" task -  This is the task that handles the uIP stack.  All TCP/IP\r
 \r
 /* Demo application definitions. */\r
 #define mainQUEUE_SIZE                                         ( 3 )\r
-#define mainCHECK_DELAY                                                ( ( portTickType ) 5000 / portTICK_RATE_MS )\r
+#define mainCHECK_DELAY                                                ( ( TickType_t ) 5000 / portTICK_PERIOD_MS )\r
 #define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 6 )\r
 \r
 /* Task priorities. */\r
 #define mainBLOCK_Q_PRIORITY                           ( tskIDLE_PRIORITY + 2 )\r
 #define mainFLASH_PRIORITY                  ( tskIDLE_PRIORITY + 2 )\r
 #define mainCREATOR_TASK_PRIORITY           ( tskIDLE_PRIORITY + 3 )\r
-#define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY ) \r
+#define mainGEN_QUEUE_TASK_PRIORITY                    ( tskIDLE_PRIORITY )\r
 \r
 /* Constants to setup the PLL. */\r
-#define mainPLL_MUL                    ( ( unsigned portLONG ) ( 8 - 1 ) )\r
-#define mainPLL_DIV                    ( ( unsigned portLONG ) 0x0000 )\r
-#define mainCPU_CLK_DIV                ( ( unsigned portLONG ) 0x0003 )\r
-#define mainPLL_ENABLE         ( ( unsigned portLONG ) 0x0001 )\r
-#define mainPLL_CONNECT                ( ( ( unsigned portLONG ) 0x0002 ) | mainPLL_ENABLE )\r
-#define mainPLL_FEED_BYTE1     ( ( unsigned portLONG ) 0xaa )\r
-#define mainPLL_FEED_BYTE2     ( ( unsigned portLONG ) 0x55 )\r
-#define mainPLL_LOCK           ( ( unsigned portLONG ) 0x4000000 )\r
-#define mainPLL_CONNECTED      ( ( unsigned portLONG ) 0x2000000 )\r
-#define mainOSC_ENABLE         ( ( unsigned portLONG ) 0x20 )\r
-#define mainOSC_STAT           ( ( unsigned portLONG ) 0x40 )\r
-#define mainOSC_SELECT         ( ( unsigned portLONG ) 0x01 )\r
+#define mainPLL_MUL                    ( ( unsigned long ) ( 8 - 1 ) )\r
+#define mainPLL_DIV                    ( ( unsigned long ) 0x0000 )\r
+#define mainCPU_CLK_DIV                ( ( unsigned long ) 0x0003 )\r
+#define mainPLL_ENABLE         ( ( unsigned long ) 0x0001 )\r
+#define mainPLL_CONNECT                ( ( ( unsigned long ) 0x0002 ) | mainPLL_ENABLE )\r
+#define mainPLL_FEED_BYTE1     ( ( unsigned long ) 0xaa )\r
+#define mainPLL_FEED_BYTE2     ( ( unsigned long ) 0x55 )\r
+#define mainPLL_LOCK           ( ( unsigned long ) 0x4000000 )\r
+#define mainPLL_CONNECTED      ( ( unsigned long ) 0x2000000 )\r
+#define mainOSC_ENABLE         ( ( unsigned long ) 0x20 )\r
+#define mainOSC_STAT           ( ( unsigned long ) 0x40 )\r
+#define mainOSC_SELECT         ( ( unsigned long ) 0x01 )\r
 \r
 /* Constants to setup the MAM. */\r
-#define mainMAM_TIM_3          ( ( unsigned portCHAR ) 0x03 )\r
-#define mainMAM_MODE_FULL      ( ( unsigned portCHAR ) 0x02 )\r
+#define mainMAM_TIM_3          ( ( unsigned char ) 0x03 )\r
+#define mainMAM_MODE_FULL      ( ( unsigned char ) 0x02 )\r
 \r
-/* \r
+/*\r
  * The task that handles the uIP stack.  All TCP/IP processing is performed in\r
  * this task.\r
  */\r
 extern void vuIP_Task( void *pvParameters );\r
 \r
 /*\r
- * The LCD is written two by more than one task so is controlled by a \r
- * 'gatekeeper' task.  This is the only task that is actually permitted to \r
+ * The LCD is written two by more than one task so is controlled by a\r
+ * 'gatekeeper' task.  This is the only task that is actually permitted to\r
  * access the LCD directly.  Other tasks wanting to display a message send\r
  * the message to the gatekeeper.\r
  */\r
@@ -161,38 +152,38 @@ static void vLCDTask( void *pvParameters );
 static void prvSetupHardware( void );\r
 \r
 /* The queue used to send messages to the LCD task. */\r
-xQueueHandle xLCDQueue;\r
+QueueHandle_t xLCDQueue;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 int main( void )\r
 {\r
        prvSetupHardware();\r
-       \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
        /* Create the uIP task.  This uses the lwIP RTOS abstraction layer.*/\r
-    xTaskCreate( vuIP_Task, ( signed portCHAR * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
+    xTaskCreate( vuIP_Task, "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
 \r
        /* Start the standard demo tasks. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
     vCreateBlockTimeTasks();\r
     vStartLEDFlashTasks( mainFLASH_PRIORITY );\r
     vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
-    vStartQueuePeekTasks();   \r
+    vStartQueuePeekTasks();\r
     vStartDynamicPriorityTasks();\r
 \r
        /* Start the tasks defined within this file/specific to this demo. */\r
-       xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
+       xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );\r
 \r
        /* Start the scheduler. */\r
        vTaskStartScheduler();\r
 \r
     /* Will only get here if there was insufficient memory to create the idle\r
     task. */\r
-       return 0; \r
+       return 0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -200,7 +191,7 @@ void vApplicationTickHook( void )
 {\r
 unsigned portBASE_TYPE uxColumn = 0;\r
 static xLCDMessage xMessage = { 0, "PASS" };\r
-static unsigned portLONG ulTicksSinceLastDisplay = 0;\r
+static unsigned long ulTicksSinceLastDisplay = 0;\r
 static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
 \r
        /* Called from every tick interrupt.  Have enough ticks passed to make it\r
@@ -209,7 +200,7 @@ static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
        if( ulTicksSinceLastDisplay >= mainCHECK_DELAY )\r
        {\r
                ulTicksSinceLastDisplay = 0;\r
-               \r
+\r
                /* Has an error been found in any task? */\r
 \r
         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
@@ -226,17 +217,17 @@ static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
                {\r
                        xMessage.pcMessage = "ERROR - GENQ";\r
                }\r
-               \r
+\r
                if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
                {\r
                        xMessage.pcMessage = "ERROR - PEEKQ";\r
-               }       \r
-               \r
+               }\r
+\r
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
                {\r
                        xMessage.pcMessage = "ERROR - DYNAMIC";\r
                }\r
-        \r
+\r
         xMessage.xColumn++;\r
 \r
                /* Send the message to the LCD gatekeeper for display. */\r
@@ -253,7 +244,7 @@ xLCDMessage xMessage;
        /* Initialise the LCD and display a startup message. */\r
        LCD_init();\r
        LCD_cur_off();\r
-    LCD_cls();    \r
+    LCD_cls();\r
     LCD_gotoxy( 1, 1 );\r
     LCD_puts( "www.FreeRTOS.org" );\r
 \r
@@ -261,7 +252,7 @@ xLCDMessage xMessage;
        {\r
                /* Wait for a message to arrive that requires displaying. */\r
                while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );\r
-               \r
+\r
                /* Display the message.  Print each message to a different position. */\r
                LCD_cls();\r
                LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );\r
@@ -277,17 +268,17 @@ static void prvSetupHardware( void )
                /* Remap the interrupt vectors to RAM if we are are running from RAM. */\r
                SCB_MEMMAP = 2;\r
        #endif\r
-       \r
+\r
        /* Disable the PLL. */\r
        PLLCON = 0;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       \r
+\r
        /* Configure clock source. */\r
        SCS |= mainOSC_ENABLE;\r
        while( !( SCS & mainOSC_STAT ) );\r
-       CLKSRCSEL = mainOSC_SELECT; \r
-       \r
+       CLKSRCSEL = mainOSC_SELECT;\r
+\r
        /* Setup the PLL to multiply the XTAL input by 4. */\r
        PLLCFG = ( mainPLL_MUL | mainPLL_DIV );\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
@@ -297,20 +288,20 @@ static void prvSetupHardware( void )
        PLLCON = mainPLL_ENABLE;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       CCLKCFG = mainCPU_CLK_DIV;      \r
+       CCLKCFG = mainCPU_CLK_DIV;\r
        while( !( PLLSTAT & mainPLL_LOCK ) );\r
-       \r
+\r
        /* Connecting the clock. */\r
        PLLCON = mainPLL_CONNECT;\r
        PLLFEED = mainPLL_FEED_BYTE1;\r
        PLLFEED = mainPLL_FEED_BYTE2;\r
-       while( !( PLLSTAT & mainPLL_CONNECTED ) ); \r
-       \r
-       /* \r
+       while( !( PLLSTAT & mainPLL_CONNECTED ) );\r
+\r
+       /*\r
        This code is commented out as the MAM does not work on the original revision\r
        LPC2368 chips.  If using Rev B chips then you can increase the speed though\r
        the use of the MAM.\r
-       \r
+\r
        Setup and turn on the MAM.  Three cycle access is used due to the fast\r
        PLL used.  It is possible faster overall performance could be obtained by\r
        tuning the MAM and PLL settings.\r
@@ -318,7 +309,7 @@ static void prvSetupHardware( void )
        MAMTIM = mainMAM_TIM_3;\r
        MAMCR = mainMAM_MODE_FULL;\r
        */\r
-       \r
+\r
        /* Setup the led's on the MCB2300 board */\r
        vParTestInitialise();\r
 }\r