]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/H8S/RTOSDemo/main.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Demo / H8S / RTOSDemo / main.c
index 0a56fc1a6b0fc9b67b1764716458f3e5c71db1fc..1776d15eac7ce01ada34eacc5d99b231af97274f 100644 (file)
@@ -1,59 +1,64 @@
 /*\r
-    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0rc2 - Copyright (C) 2016 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
+    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
 /*\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
@@ -124,11 +129,11 @@ and mainCOM_TEST_LED + 1 is toggles on each character Rx. */
 \r
 /* LED that is toggled by the check task.  The check task periodically checks\r
 that all the other tasks are operating without error.  If no errors are found\r
-the LED is toggled with mainCHECK_PERIOD frequency.  If an error is found \r
+the LED is toggled with mainCHECK_PERIOD frequency.  If an error is found\r
 the the toggle rate increases to mainERROR_CHECK_PERIOD. */\r
 #define mainCHECK_TASK_LED                             ( 5 )\r
-#define mainCHECK_PERIOD                               ( ( portTickType ) 3000 / portTICK_RATE_MS  )\r
-#define mainERROR_CHECK_PERIOD                 ( ( portTickType ) 500 / portTICK_RATE_MS )\r
+#define mainCHECK_PERIOD                               ( ( TickType_t ) 3000 / portTICK_PERIOD_MS  )\r
+#define mainERROR_CHECK_PERIOD                 ( ( TickType_t ) 500 / portTICK_PERIOD_MS )\r
 \r
 /* Constants used by the vMemCheckTask() task. */\r
 #define mainCOUNT_INITIAL_VALUE                ( ( unsigned long ) 0 )\r
@@ -177,10 +182,10 @@ int main( void )
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
 \r
        /* Start the 'Check' task. */\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
-       /* In this port, to use preemptive scheduler define configUSE_PREEMPTION \r
-       as 1 in portmacro.h.  To use the cooperative scheduler define \r
+       /* In this port, to use preemptive scheduler define configUSE_PREEMPTION\r
+       as 1 in portmacro.h.  To use the cooperative scheduler define\r
        configUSE_PREEMPTION as 0. */\r
        vTaskStartScheduler();\r
 \r
@@ -193,21 +198,21 @@ int main( void )
  * 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 mainCHECK_PERIOD to mainERROR_CHECK_PERIOD so\r
- * the on board LED flash rate will increase. \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.   In addition the\r
- * dynamically created task allocates and frees memory while it runs. \r
+ * dynamically created task allocates and frees memory while it runs.\r
  */\r
 static void vErrorChecks( void *pvParameters )\r
 {\r
-portTickType xDelayPeriod = mainCHECK_PERIOD;\r
+TickType_t xDelayPeriod = mainCHECK_PERIOD;\r
 volatile unsigned long ulMemCheckTaskRunningCount;\r
-xTaskHandle xCreatedTask;\r
-portTickType xLastWakeTime;\r
+TaskHandle_t xCreatedTask;\r
+TickType_t xLastWakeTime;\r
 \r
        /* Initialise xLastWakeTime to ensure the first call to vTaskDelayUntil()\r
        functions correctly. */\r
@@ -219,28 +224,28 @@ portTickType xLastWakeTime;
                later that it has changed. */\r
                ulMemCheckTaskRunningCount = mainCOUNT_INITIAL_VALUE;\r
 \r
-               /* Dynamically create a task - passing ulMemCheckTaskRunningCount as a \r
-               parameter. */           \r
+               /* Dynamically create a task - passing ulMemCheckTaskRunningCount as a\r
+               parameter. */\r
                xCreatedTask = mainNO_TASK;\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_CHECK_PERIOD;\r
                }\r
 \r
 \r
-               /* Delay until it is time to execute again.  The delay period is \r
+               /* Delay until it is time to execute again.  The delay period is\r
                shorter following an error. */\r
                vTaskDelayUntil( &xLastWakeTime, xDelayPeriod );\r
 \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
@@ -256,7 +261,7 @@ portTickType xLastWakeTime;
 \r
 /*\r
  *     Check each set of tasks in turn to see if they have experienced any\r
- *     error conditions. \r
+ *     error conditions.\r
  */\r
 static long prvCheckOtherTasksAreStillRunning( unsigned long ulMemCheckTaskCount )\r
 {\r
@@ -318,10 +323,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
@@ -336,12 +341,12 @@ static long lErrorOccurred = pdFALSE;
                }\r
                else\r
                {\r
-                       /* Reset the count so an error is detected by the \r
+                       /* Reset the count so an error is detected by the\r
                        prvCheckOtherTasksAreStillRunning() function. */\r
                        *pulMemCheckTaskRunningCounter = mainCOUNT_INITIAL_VALUE;\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