]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemo/main-full.c
Correct calculation of xHeapStructSize in heap_4 and heap_5.
[freertos] / FreeRTOS / Demo / MicroBlaze_Spartan-6_EthernetLite / SDKProjects / RTOSDemo / main-full.c
index bc8e0f14c3a14071dfb3f77c7dfa54670751e931..b1e23af566f0c5b4fa37020e80e685d2e8be7c4f 100644 (file)
@@ -1,59 +1,64 @@
 /*\r
-    FreeRTOS V7.5.1 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
-    ***************************************************************************\r
-     *                                                                       *\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
-     *    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
-     *    Thank you!                                                         *\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
 \r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
+    ***************************************************************************\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
 \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.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\r
 \r
-    1 tab == 4 spaces!\r
-\r
     ***************************************************************************\r
      *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
      *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\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
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial 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
  * main-blinky.c is included when the "Blinky" build configuration is used.\r
  * main-full.c is included when the "Full" build configuration is used.\r
  *\r
- * main-full.c creates a lot of demo and test tasks and timers,  and is \r
- * therefore very comprehensive but also complex.  If you would prefer a much \r
- * simpler project to get started with, then select the 'Blinky' build \r
+ * main-full.c creates a lot of demo and test tasks and timers,  and is\r
+ * therefore very comprehensive but also complex.  If you would prefer a much\r
+ * simpler project to get started with, then select the 'Blinky' build\r
  * configuration within the SDK Eclipse IDE.  See the documentation page for\r
  * this demo on the http://www.FreeRTOS.org web site for more information.\r
  * ****************************************************************************\r
  *\r
- * main() creates all the demo application tasks and timers, then starts the \r
- * scheduler.  The web documentation provides more details of the standard demo \r
- * application tasks, which provide no particular functionality, but do provide \r
- * a good example of how to use the FreeRTOS API.  \r
+ * main() creates all the demo application tasks and timers, then starts the\r
+ * scheduler.  The web documentation provides more details of the standard demo\r
+ * application tasks, which provide no particular functionality, but do provide\r
+ * a good example of how to use the FreeRTOS API.\r
  *\r
  * In addition to the standard demo tasks, the following tasks and tests are\r
  * defined and/or created within this file:\r
  * http://www.FreeRTOS.org/Free-RTOS-for-Xilinx-MicroBlaze-on-Spartan-6-FPGA.html\r
  * for details on setting up and using the embedded web server.\r
  *\r
- * "Reg test" tasks - These test the task context switch mechanism by first \r
+ * "Reg test" tasks - These test the task context switch mechanism by first\r
  * filling the MicroBlaze registers with known values, before checking that each\r
  * register maintains the value that was written to it as the tasks are switched\r
  * in and out.  The two register test tasks do not use the same values, and\r
  * execute at a very low priority, to ensure they are pre-empted regularly.\r
  *\r
- * "Check" timer - The check timer period is initially set to five seconds.  \r
+ * "Check" timer - The check timer period is initially set to five seconds.\r
  * The check timer callback function checks that all the standard demo tasks,\r
  * and the register check tasks, are not only still executing, but are executing\r
  * without reporting any errors.  If the check timer discovers that a task has\r
 /* The rate at which mainCHECK_LED will toggle when all the tasks are running\r
 without error.  See the description of the check timer in the comments at the\r
 top of this file. */\r
-#define mainNO_ERROR_CHECK_TIMER_PERIOD                ( 5000 / portTICK_RATE_MS )\r
+#define mainNO_ERROR_CHECK_TIMER_PERIOD                ( 5000 / portTICK_PERIOD_MS )\r
 \r
 /* The rate at which mainCHECK_LED will toggle when an error has been reported\r
-by at least one task.  See the description of the check timer in the comments at \r
+by at least one task.  See the description of the check timer in the comments at\r
 the top of this file. */\r
-#define mainERROR_CHECK_TIMER_PERIOD           ( 200 / portTICK_RATE_MS )\r
+#define mainERROR_CHECK_TIMER_PERIOD           ( 200 / portTICK_PERIOD_MS )\r
 \r
 /* A block time of zero simply means "don't block". */\r
-#define mainDONT_BLOCK                                         ( ( portTickType ) 0 )\r
+#define mainDONT_BLOCK                                         ( ( TickType_t ) 0 )\r
 \r
 /* The LED used by the comtest tasks. See the comtest_strings.c file for more\r
 information.  In this case an invalid LED number is provided as all four\r
 available LEDs (LEDs 0 to 3) are already in use. */\r
 #define mainCOM_TEST_LED                       ( 4 )\r
 \r
-/* Baud rate used by the comtest tasks.  The baud rate used is actually fixed in \r
-UARTLite IP when the hardware was built, but the standard serial init function \r
-required a baud rate parameter to be provided - in this case it is just \r
+/* Baud rate used by the comtest tasks.  The baud rate used is actually fixed in\r
+UARTLite IP when the hardware was built, but the standard serial init function\r
+required a baud rate parameter to be provided - in this case it is just\r
 ignored. */\r
 #define mainCOM_TEST_BAUD_RATE                         ( XPAR_RS232_UART_1_BAUDRATE )\r
 \r
-/* The timer test task generates a lot of timers that all use a different \r
+/* The timer test task generates a lot of timers that all use a different\r
 period that is a multiple of the mainTIMER_TEST_PERIOD definition. */\r
 #define mainTIMER_TEST_PERIOD                  ( 20 )\r
 \r
@@ -204,13 +209,13 @@ extern void vRegisterTest1( void *pvParameters );
 extern void vRegisterTest2( void *pvParameters );\r
 \r
 /*\r
- * Defines the 'check' timer functionality as described at the top of this file.  \r
+ * Defines the 'check' timer functionality as described at the top of this file.\r
  * This function is the callback function associated with the 'check' timer.\r
  */\r
-static void vCheckTimerCallback( xTimerHandle xTimer );\r
+static void vCheckTimerCallback( TimerHandle_t xTimer );\r
 \r
-/* \r
- * Configure the interrupt controller, LED outputs and button inputs. \r
+/*\r
+ * Configure the interrupt controller, LED outputs and button inputs.\r
  */\r
 static void prvSetupHardware( void );\r
 \r
@@ -229,7 +234,7 @@ only the timer/counter is used directly within this file. */
 static XTmrCtr xTimer0Instance;\r
 \r
 /* The 'check' timer, as described at the top of this file. */\r
-static xTimerHandle xCheckTimer = NULL;\r
+static TimerHandle_t xCheckTimer = NULL;\r
 \r
 /* Used in the run time stats calculations. */\r
 static unsigned long ulClocksPer10thOfAMilliSecond = 0UL;\r
@@ -243,9 +248,9 @@ static const unsigned long ulCounterReloadValue = ( ( XPAR_AXI_TIMER_0_CLOCK_FRE
 int main( void )\r
 {\r
        /***************************************************************************\r
-       This project includes a lot of demo and test tasks and timers,  and is \r
-       therefore comprehensive, but complex.  If you would prefer a much simpler \r
-       project to get started with, then select the 'Blinky' build configuration \r
+       This project includes a lot of demo and test tasks and timers,  and is\r
+       therefore comprehensive, but complex.  If you would prefer a much simpler\r
+       project to get started with, then select the 'Blinky' build configuration\r
        within the SDK Eclipse IDE.\r
        ***************************************************************************/\r
 \r
@@ -257,8 +262,8 @@ int main( void )
 \r
        /* Start the reg test tasks, as described in the comments at the top of this\r
        file. */\r
-       xTaskCreate( vRegisterTest1, ( const signed char * const ) "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
-       xTaskCreate( vRegisterTest2, ( const signed char * const ) "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( vRegisterTest1, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
+       xTaskCreate( vRegisterTest2, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) 0, tskIDLE_PRIORITY, NULL );\r
 \r
        /* Create the standard demo tasks. */\r
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
@@ -283,37 +288,37 @@ int main( void )
        vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
 \r
        /* The suicide tasks must be created last as they need to know how many\r
-       tasks were running prior to their creation.  This then allows them to \r
-       ascertain whether or not the correct/expected number of tasks are running at \r
+       tasks were running prior to their creation.  This then allows them to\r
+       ascertain whether or not the correct/expected number of tasks are running at\r
        any given time. */\r
        vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
 \r
        /* Create the 'check' timer - the timer that periodically calls the\r
-       check function as described in the comments at the top of this file.  Note \r
+       check function as described in the comments at the top of this file.  Note\r
        that, for reasons stated in the comments within vApplicationIdleHook()\r
-       (defined in this file), the check timer is not actually started until after \r
+       (defined in this file), the check timer is not actually started until after\r
        the scheduler has been started. */\r
-       xCheckTimer = xTimerCreate( ( const signed char * ) "Check timer", mainNO_ERROR_CHECK_TIMER_PERIOD, pdTRUE, ( void * ) 0, vCheckTimerCallback );\r
+       xCheckTimer = xTimerCreate( "Check timer", mainNO_ERROR_CHECK_TIMER_PERIOD, pdTRUE, ( void * ) 0, vCheckTimerCallback );\r
 \r
-       /* Start the scheduler running.  From this point on, only tasks and \r
+       /* Start the scheduler running.  From this point on, only tasks and\r
        interrupts will be executing. */\r
        vTaskStartScheduler();\r
 \r
        /* If all is well then the following line will never be reached.  If\r
        execution does reach here, then it is highly probably that the heap size\r
-       is too small for the idle and/or timer tasks to be created within \r
+       is too small for the idle and/or timer tasks to be created within\r
        vTaskStartScheduler(). */\r
        taskDISABLE_INTERRUPTS();\r
        for( ;; );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void vCheckTimerCallback( xTimerHandle xTimer )\r
+static void vCheckTimerCallback( TimerHandle_t xTimer )\r
 {\r
 extern unsigned long ulRegTest1CycleCount, ulRegTest2CycleCount;\r
 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;\r
 static long lErrorAlreadyLatched = pdFALSE;\r
-portTickType xExecutionRate = mainNO_ERROR_CHECK_TIMER_PERIOD;\r
+TickType_t xExecutionRate = mainNO_ERROR_CHECK_TIMER_PERIOD;\r
 \r
        /* This is the callback function used by the 'check' timer, as described\r
        in the comments at the top of this file. */\r
@@ -428,7 +433,7 @@ will run on lots of different MicroBlaze and FPGA configurations - not all of
 which will have the same timer peripherals defined or available.  This example\r
 uses the AXI Timer 0.  If that is available on your hardware platform then this\r
 example callback implementation should not require modification.   The name of\r
-the interrupt handler that should be installed is vPortTickISR(), which the \r
+the interrupt handler that should be installed is vPortTickISR(), which the\r
 function below declares as an extern. */\r
 void vApplicationSetupTimerInterrupt( void )\r
 {\r
@@ -440,7 +445,7 @@ extern void vPortTickISR( void *pvUnused );
 \r
        if( xStatus == XST_SUCCESS )\r
        {\r
-               /* Install the tick interrupt handler as the timer ISR. \r
+               /* Install the tick interrupt handler as the timer ISR.\r
                *NOTE* The xPortInstallInterruptHandler() API function must be used for\r
                this purpose. */\r
                xStatus = xPortInstallInterruptHandler( XPAR_INTC_0_TMRCTR_0_VEC_ID, vPortTickISR, NULL );\r
@@ -476,11 +481,11 @@ extern void vPortTickISR( void *pvUnused );
 \r
 /* This is an application defined callback function used to clear whichever\r
 interrupt was installed by the the vApplicationSetupTimerInterrupt() callback\r
-function - in this case the interrupt generated by the AXI timer.  It is \r
-provided as an application callback because the kernel will run on lots of \r
-different MicroBlaze and FPGA configurations - not all of which will have the \r
-same timer peripherals defined or available.  This example uses the AXI Timer 0.  \r
-If that is available on your hardware platform then this example callback \r
+function - in this case the interrupt generated by the AXI timer.  It is\r
+provided as an application callback because the kernel will run on lots of\r
+different MicroBlaze and FPGA configurations - not all of which will have the\r
+same timer peripherals defined or available.  This example uses the AXI Timer 0.\r
+If that is available on your hardware platform then this example callback\r
 implementation should not require modification provided the example definition\r
 of vApplicationSetupTimerInterrupt() is also not modified. */\r
 void vApplicationClearTimerInterrupt( void )\r
@@ -497,7 +502,7 @@ void vApplicationMallocFailedHook( void )
 {\r
        /* vApplicationMallocFailedHook() will only be called if\r
        configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook\r
-       function that will get called if a call to pvPortMalloc() fails. \r
+       function that will get called if a call to pvPortMalloc() fails.\r
        pvPortMalloc() is called internally by the kernel whenever a task, queue or\r
        semaphore is created.  It is also called by various parts of the demo\r
        application.  If heap_1.c or heap_2.c are used, then the size of the heap\r
@@ -510,14 +515,14 @@ void vApplicationMallocFailedHook( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
 {\r
        ( void ) pcTaskName;\r
        ( void ) pxTask;\r
 \r
        /* vApplicationStackOverflowHook() will only be called if\r
        configCHECK_FOR_STACK_OVERFLOW is set to either 1 or 2.  The handle and name\r
-       of the offending task will be passed into the hook function via its \r
+       of the offending task will be passed into the hook function via its\r
        parameters.  However, when a stack has overflowed, it is possible that the\r
        parameters will have been corrupted, in which case the pxCurrentTCB variable\r
        can be inspected directly. */\r
@@ -530,14 +535,14 @@ void vApplicationIdleHook( void )
 {\r
 static long lCheckTimerStarted = pdFALSE;\r
 \r
-       /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set \r
-       to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle \r
-       task.  It is essential that code added to this hook function never attempts \r
-       to block in any way (for example, call xQueueReceive() with a block time \r
-       specified, or call vTaskDelay()).  If the application makes use of the \r
-       vTaskDelete() API function (as this demo application does) then it is also \r
-       important that vApplicationIdleHook() is permitted to return to its calling \r
-       function, because it is the responsibility of the idle task to clean up \r
+       /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set\r
+       to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle\r
+       task.  It is essential that code added to this hook function never attempts\r
+       to block in any way (for example, call xQueueReceive() with a block time\r
+       specified, or call vTaskDelay()).  If the application makes use of the\r
+       vTaskDelete() API function (as this demo application does) then it is also\r
+       important that vApplicationIdleHook() is permitted to return to its calling\r
+       function, because it is the responsibility of the idle task to clean up\r
        memory allocated by the kernel to any task that has since been deleted. */\r
 \r
        /* If the check timer has not already been started, then start it now.\r
@@ -549,7 +554,7 @@ static long lCheckTimerStarted = pdFALSE;
        queue will have been drained. */\r
        if( lCheckTimerStarted == pdFALSE )\r
        {\r
-               xTimerStart( xCheckTimer, mainDONT_BLOCK ); \r
+               xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
                lCheckTimerStarted = pdTRUE;\r
        }\r
 }\r
@@ -559,11 +564,11 @@ void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump )
 {\r
        ( void ) xRegisterDump;\r
 \r
-       /* If configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h, then \r
-       the kernel will automatically install its own exception handlers before the \r
-       kernel is started, if the application writer has not already caused them to \r
-       be installed by calling either of the vPortExceptionsInstallHandlers() \r
-       or xPortInstallInterruptHandler() API functions before that time.  The \r
+       /* If configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h, then\r
+       the kernel will automatically install its own exception handlers before the\r
+       kernel is started, if the application writer has not already caused them to\r
+       be installed by calling either of the vPortExceptionsInstallHandlers()\r
+       or xPortInstallInterruptHandler() API functions before that time.  The\r
        kernels exception handler populates an xPortRegisterDump structure with\r
        the processor state at the point that the exception was triggered - and also\r
        includes a strings that say what the exception cause was and which task was\r
@@ -583,7 +588,7 @@ void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump )
 static void prvSetupHardware( void )\r
 {\r
        taskDISABLE_INTERRUPTS();\r
-       \r
+\r
        /* Configure the LED outputs. */\r
        vParTestInitialise();\r
 \r