]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/ARM7_LPC2106_GCC/main.c
Update version number to 8.1.2 after moving the defaulting of configUSE_PORT_OPTIMISE...
[freertos] / FreeRTOS / Demo / ARM7_LPC2106_GCC / main.c
index b2ea3393d58d1bbf0ad85e3451c125afbae9b6eb..48c318088e199ee2ade321a422f0903d6a7cf934 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
+/*\r
        NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.\r
-       The processor MUST be in supervisor mode when vTaskStartScheduler is \r
+       The processor MUST be in supervisor mode when vTaskStartScheduler is\r
        called.  The demo applications included in the FreeRTOS.org download switch\r
        to supervisor mode prior to main being called.  If you are not using one of\r
        these demo application projects then ensure Supervisor mode is used.\r
 /*\r
  * Creates all the demo application tasks, then starts the scheduler.  The WEB\r
  * documentation provides more details of the demo application tasks.\r
- * \r
- * Main.c also creates a task called "Check".  This only executes every three \r
- * seconds but has the highest priority so is guaranteed to get processor time.  \r
+ *\r
+ * Main.c also creates a task called "Check".  This only executes every three\r
+ * seconds but has the highest priority so is guaranteed to get processor time.\r
  * Its main function is to check that all the other tasks are still operational.\r
- * Each task (other than the "flash" tasks) maintains a unique count that is \r
- * incremented each time the task successfully completes its function.  Should \r
- * any error occur within such a task the count is permanently halted.  The \r
+ * Each task (other than the "flash" tasks) maintains a unique count that is\r
+ * incremented each time the task successfully completes its function.  Should\r
+ * any error occur within such a task the count is permanently halted.  The\r
  * check task inspects the count of each task to ensure it has changed since\r
- * the last time the check task executed.  If all the count variables have \r
+ * the last time the check task executed.  If all the count variables have\r
  * changed all the tasks are still executing error free, and the check task\r
- * toggles the onboard LED.  Should any task contain an error at any time \r
+ * toggles the onboard LED.  Should any task contain an error at any time\r
  * the LED toggle rate will change from 3 seconds to 500ms.\r
  *\r
- * To check the operation of the memory allocator the check task also \r
- * dynamically creates a task before delaying, and deletes it again when it \r
+ * To check the operation of the memory allocator the check task also\r
+ * dynamically creates a task before delaying, and deletes it again when it\r
  * wakes.  If memory cannot be allocated for the new task the call to xTaskCreate\r
  * will fail and an error is signalled.  The dynamically created task itself\r
  * allocates and frees memory just to give the allocator a bit more exercise.\r
  *\r
  */\r
 \r
-/* \r
+/*\r
        Changes from V2.4.2\r
 \r
        + The vErrorChecks() task now dynamically creates then deletes a task each\r
          cycle.  This tests the operation of the memory allocator.\r
 \r
        Changes from V2.5.2\r
-               \r
-       + vParTestInitialise() is called during initialisation to ensure all the \r
+\r
+       + vParTestInitialise() is called during initialisation to ensure all the\r
          LED's start off.\r
 */\r
 \r
 #define mainSEM_TEST_PRIORITY          ( tskIDLE_PRIORITY + 0 )\r
 #define mainBLOCK_Q_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
 \r
-/* The rate at which the on board LED will toggle when there is/is not an \r
+/* The rate at which the on board LED will toggle when there is/is not an\r
 error. */\r
-#define mainNO_ERROR_FLASH_PERIOD      ( ( portTickType ) 3000 / portTICK_RATE_MS  )\r
-#define mainERROR_FLASH_PERIOD         ( ( portTickType ) 500 / portTICK_RATE_MS  )\r
+#define mainNO_ERROR_FLASH_PERIOD      ( ( TickType_t ) 3000 / portTICK_PERIOD_MS  )\r
+#define mainERROR_FLASH_PERIOD         ( ( TickType_t ) 500 / portTICK_PERIOD_MS  )\r
 #define mainON_BOARD_LED_BIT           ( ( unsigned long ) 0x80 )\r
 \r
 /* Constants used by the vMemCheckTask() task. */\r
@@ -193,7 +184,7 @@ error. */
 \r
 /*\r
  * The Olimex demo board has a single built in LED.  This function simply\r
- * toggles its state. \r
+ * toggles its state.\r
  */\r
 void prvToggleOnBoardLED( void );\r
 \r
@@ -204,7 +195,7 @@ void prvToggleOnBoardLED( void );
 static long prvCheckOtherTasksAreStillRunning( unsigned long ulMemCheckTaskCount );\r
 \r
 /*\r
- * The task that executes at the highest priority and calls \r
+ * The task that executes at the highest priority and calls\r
  * prvCheckOtherTasksAreStillRunning().  See the description at the top\r
  * of the file.\r
  */\r
@@ -226,7 +217,7 @@ static void prvSetupHardware( void );
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * Starts all the other tasks, then starts the scheduler. \r
+ * Starts all the other tasks, then starts the scheduler.\r
  */\r
 int main( void )\r
 {\r
@@ -244,12 +235,12 @@ int main( void )
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
 \r
        /* Start the check task - which is defined in this file. */\r
-       xTaskCreate( vErrorChecks, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+       xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
 \r
        /* Now all the tasks have been started - start the scheduler.\r
 \r
        NOTE : Tasks run in system mode and the scheduler runs in Supervisor mode.\r
-       The processor MUST be in supervisor mode when vTaskStartScheduler is \r
+       The processor MUST be in supervisor mode when vTaskStartScheduler is\r
        called.  The demo applications included in the FreeRTOS.org download switch\r
        to supervisor mode prior to main being called.  If you are not using one of\r
        these demo application projects then ensure Supervisor mode is used here. */\r
@@ -262,9 +253,9 @@ int main( void )
 \r
 static void vErrorChecks( void *pvParameters )\r
 {\r
-portTickType xDelayPeriod = mainNO_ERROR_FLASH_PERIOD;\r
+TickType_t xDelayPeriod = mainNO_ERROR_FLASH_PERIOD;\r
 unsigned long ulMemCheckTaskRunningCount;\r
-xTaskHandle xCreatedTask;\r
+TaskHandle_t xCreatedTask;\r
 \r
        /* The parameters are not used in this function. */\r
        ( void ) pvParameters;\r
@@ -272,22 +263,22 @@ xTaskHandle xCreatedTask;
        /* Cycle for ever, delaying then checking all the other tasks are still\r
        operating without error.  If an error is detected then the delay period\r
        is decreased from mainNO_ERROR_FLASH_PERIOD to mainERROR_FLASH_PERIOD so\r
-       the on board LED flash rate will increase. \r
-       \r
+       the on board LED flash rate will increase.\r
+\r
        In addition to the standard tests the memory allocator is tested through\r
-       the dynamic creation and deletion of a task each cycle.  Each time the \r
+       the dynamic creation and deletion of a task each cycle.  Each time the\r
        task is created memory must be allocated for its stack.  When the task is\r
-       deleted this memory is returned to the heap.  If the task cannot be created \r
+       deleted this memory is returned to the heap.  If the task cannot be created\r
        then it is likely that the memory allocation failed. */\r
 \r
        for( ;; )\r
        {\r
-               /* Dynamically create a task - passing ulMemCheckTaskRunningCount as a \r
+               /* Dynamically create a task - passing ulMemCheckTaskRunningCount as a\r
                parameter. */\r
                ulMemCheckTaskRunningCount = mainCOUNT_INITIAL_VALUE;\r
                xCreatedTask = mainNO_TASK;\r
 \r
-               if( xTaskCreate( vMemCheckTask, ( signed char * ) "MEM_CHECK", configMINIMAL_STACK_SIZE, ( void * ) &ulMemCheckTaskRunningCount, tskIDLE_PRIORITY, &xCreatedTask ) != pdPASS )\r
+               if( xTaskCreate( vMemCheckTask, "MEM_CHECK", configMINIMAL_STACK_SIZE, ( void * ) &ulMemCheckTaskRunningCount, tskIDLE_PRIORITY, &xCreatedTask ) != pdPASS )\r
                {\r
                        /* Could not create the task - we have probably run out of heap. */\r
                        xDelayPeriod = mainERROR_FLASH_PERIOD;\r
@@ -295,14 +286,14 @@ xTaskHandle xCreatedTask;
 \r
                /* Delay until it is time to execute again. */\r
                vTaskDelay( xDelayPeriod );\r
-       \r
+\r
                /* Delete the dynamically created task. */\r
                if( xCreatedTask != mainNO_TASK )\r
                {\r
                        vTaskDelete( xCreatedTask );\r
                }\r
 \r
-               /* Check all the standard demo application tasks are executing without \r
+               /* Check all the standard demo application tasks are executing without\r
                error.  ulMemCheckTaskRunningCount is checked to ensure it was\r
                modified by the task just deleted. */\r
                if( prvCheckOtherTasksAreStillRunning( ulMemCheckTaskRunningCount ) != pdPASS )\r
@@ -327,8 +318,8 @@ static void prvSetupHardware( void )
        PCB_PINSEL0 |= mainTX_ENABLE;\r
        PCB_PINSEL0 |= mainRX_ENABLE;\r
 \r
-       /* Set all GPIO to output other than the P0.14 (BSL), and the JTAG pins.  \r
-       The JTAG pins are left as input as I'm not sure what will happen if the \r
+       /* Set all GPIO to output other than the P0.14 (BSL), and the JTAG pins.\r
+       The JTAG pins are left as input as I'm not sure what will happen if the\r
        Wiggler is connected after powerup - not that it would be a good idea to\r
        do that anyway. */\r
        GPIO_IODIR = ~( mainP0_14 + mainJTAG_PORT );\r
@@ -358,7 +349,7 @@ static void prvSetupHardware( void )
 \r
        /* Setup the peripheral bus to be the same as the PLL output. */\r
        SCB_VPBDIV = mainBUS_CLK_FULL;\r
-       \r
+\r
        /* Initialise LED outputs. */\r
        vParTestInitialise();\r
 }\r
@@ -376,7 +367,7 @@ unsigned long ulState;
        else\r
        {\r
                GPIO_IOSET = mainON_BOARD_LED_BIT;\r
-       }       \r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -444,10 +435,10 @@ static long lErrorOccurred = pdFALSE;
        vErrorChecks task to check the operation of the memory allocator.  Each time\r
        the task is created memory is allocated for the stack and TCB.  Each time\r
        the task is deleted this memory is returned to the heap.  This task itself\r
-       exercises the allocator by allocating and freeing blocks. \r
-       \r
-       The task executes at the idle priority so does not require a delay. \r
-       \r
+       exercises the allocator by allocating and freeing blocks.\r
+\r
+       The task executes at the idle priority so does not require a delay.\r
+\r
        pulMemCheckTaskRunningCounter is incremented each cycle to indicate to the\r
        vErrorChecks() task that this task is still executing without error. */\r
 \r
@@ -461,7 +452,7 @@ static long lErrorOccurred = pdFALSE;
                        ( *pulMemCheckTaskRunningCounter )++;\r
                }\r
 \r
-               /* Allocate some memory - just to give the allocator some extra \r
+               /* Allocate some memory - just to give the allocator some extra\r
                exercise.  This has to be in a critical section to ensure the\r
                task does not get deleted while it has memory allocated. */\r
                vTaskSuspendAll();\r