]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RX100_RX113-RSK_GCC_e2studio_IAR/src/Full_Demo/main_full.c
Update version number ready for the V8.2.3 release.
[freertos] / FreeRTOS / Demo / RX100_RX113-RSK_GCC_e2studio_IAR / src / Full_Demo / main_full.c
index bae60b1d335df716470e8cccb4abcdadff9ce0cc..6975a1a7e0d868bb4fcd3f30a9838d207f27b1ae 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+    FreeRTOS V8.2.3 - 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
@@ -8,7 +8,7 @@
 \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
     ***************************************************************************\r
     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
@@ -81,7 +81,7 @@
  *\r
  ******************************************************************************\r
  *\r
- * main_full() creates all the demo application tasks and software timers, then\r
+ * main_full() creates a set of demo application tasks and software timers, then\r
  * starts the scheduler.  The web documentation provides more details of the\r
  * standard demo application tasks, which provide no particular functionality,\r
  * but do provide a good example of how to use the FreeRTOS API.\r
  * In addition to the standard demo tasks, the following tasks and tests are\r
  * defined and/or created within this file:\r
  *\r
+ * "FreeRTOS+CLI command console" -  The command console uses SCI1 for its\r
+ * input and output.  The baud rate is set to 19200.  Type "help" to see a list\r
+ * of registered commands.  The FreeRTOS+CLI license is different to the\r
+ * FreeRTOS license, see http://www.FreeRTOS.org/cli for license and usage\r
+ * details.\r
+ *\r
  * "Reg test" tasks - These fill both the core and floating point registers with\r
  * known values, then check that each register maintains its expected value for\r
  * the lifetime of the task.  Each task uses a different set of values.  The reg\r
  * error in the context switching mechanism.\r
  *\r
  * "Check" task - The check task period is initially set to three seconds.  The\r
- * task checks that all the standard demo tasks, and the register check tasks,\r
- * are not only still executing, but are executing without reporting any errors.\r
- * If the check task discovers that a task has either stalled, or reported an\r
- * error, then it changes its own execution period from the initial three\r
- * seconds, to just 200ms.  The check task also toggles an LED each time it is\r
- * called.  This provides a visual indication of the system status:  If the LED\r
- * toggles every three seconds, then no issues have been discovered.  If the LED\r
- * toggles every 200ms, then an issue has been discovered with at least one\r
- * task.\r
+ * task checks that all the standard demo tasks are not only still executing,\r
+ * but are executing without reporting any errors.  If the check task discovers\r
+ * that a task has either stalled, or reported an error, then it changes its own\r
+ * execution period from the initial three seconds, to just 200ms.  The check\r
+ * task also toggles an LED on each iteration of its loop.  This provides a\r
+ * visual indication of the system status:  If the LED toggles every three\r
+ * seconds, then no issues have been discovered.  If the LED toggles every\r
+ * 200ms, then an issue has been discovered with at least one task.\r
  */\r
 \r
 /* Standard includes. */\r
 #include "partest.h"\r
 #include "comtest2.h"\r
 #include "serial.h"\r
-#include "TimerDemo.h"\r
 #include "QueueOverwrite.h"\r
 #include "IntQueue.h"\r
 #include "EventGroupsDemo.h"\r
 #define mainCREATOR_TASK_PRIORITY                      ( tskIDLE_PRIORITY + 3UL )\r
 #define mainFLOP_TASK_PRIORITY                         ( tskIDLE_PRIORITY )\r
 #define mainUART_COMMAND_CONSOLE_STACK_SIZE    ( configMINIMAL_STACK_SIZE * 3UL )\r
-#define mainCOM_TEST_TASK_PRIORITY                     ( tskIDLE_PRIORITY + 2 )\r
 #define mainCHECK_TASK_PRIORITY                                ( configMAX_PRIORITIES - 1 )\r
 #define mainQUEUE_OVERWRITE_PRIORITY           ( tskIDLE_PRIORITY )\r
 \r
 /* The priority used by the UART command console task. */\r
-#define mainUART_COMMAND_CONSOLE_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )\r
-\r
-/* A block time of zero simply means "don't block". */\r
-#define mainDONT_BLOCK                                         ( 0UL )\r
+#define mainUART_COMMAND_CONSOLE_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
 \r
 /* The period after which the check timer will expire, in ms, provided no errors\r
 have been reported by any of the standard demo tasks.  ms are converted to the\r
 equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainNO_ERROR_CHECK_TASK_PERIOD         ( 3000UL / portTICK_PERIOD_MS )\r
+#define mainNO_ERROR_CHECK_TASK_PERIOD         pdMS_TO_TICKS( 3000UL )\r
 \r
 /* The period at which the check timer will expire, in ms, if an error has been\r
 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
 in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainERROR_CHECK_TASK_PERIOD            ( 200UL / portTICK_PERIOD_MS )\r
+#define mainERROR_CHECK_TASK_PERIOD            pdMS_TO_TICKS( 200UL )\r
 \r
 /* Parameters that are passed into the register check tasks solely for the\r
 purpose of ensuring parameters are passed into tasks correctly. */\r
-#define mainREG_TEST_1_PARAMETER       ( ( void * ) 0x12121212UL )\r
-#define mainREG_TEST_2_PARAMETER       ( ( void * ) 0x12345678UL )\r
+#define mainREG_TEST_1_PARAMETER                       ( ( void * ) 0x12121212UL )\r
+#define mainREG_TEST_2_PARAMETER                       ( ( void * ) 0x12345678UL )\r
 \r
 /* The base period used by the timer test tasks. */\r
 #define mainTIMER_TEST_PERIOD                          ( 50 )\r
@@ -212,6 +212,17 @@ void vRegTest2Implementation( void );
  */\r
 static void prvPseudoRandomiser( void *pvParameters );\r
 \r
+/*\r
+ * Register commands that can be used with FreeRTOS+CLI.  The commands are\r
+ * defined in CLI-Commands.c and File-Related-CLI-Command.c respectively.\r
+ */\r
+extern void vRegisterSampleCLICommands( void );\r
+\r
+/*\r
+ * The task that manages the FreeRTOS+CLI input and output.\r
+ */\r
+extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* The following two variables are used to communicate the status of the\r
@@ -220,9 +231,6 @@ then the register check tasks have not discovered any errors.  If a variable
 stops incrementing, then an error has been found. */\r
 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
 \r
-/* String for display in the web server.  It is set to an error message if the\r
-check task detects an error.  */\r
-const char *pcStatusMessage = "All tasks running without error";\r
 /*-----------------------------------------------------------*/\r
 \r
 void main_full( void )\r
@@ -238,8 +246,7 @@ void main_full( void )
        vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
        vStartRecursiveMutexTasks();\r
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
-//_RB_ vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
-       vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+       vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
        vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
        vStartEventGroupTasks();\r
        vStartTaskNotifyTask();\r
@@ -250,7 +257,14 @@ void main_full( void )
        xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
 \r
        /* Create the task that just adds a little random behaviour. */\r
-       xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
+       xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 2, NULL );\r
+\r
+       /* Start the tasks that implements the command console on the UART, as\r
+       described above. */\r
+       vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
+\r
+       /* Register the standard CLI commands. */\r
+       vRegisterSampleCLICommands();\r
 \r
        /* Create the task that performs the 'check' functionality,     as described at\r
        the top of this file. */\r
@@ -308,12 +322,11 @@ unsigned long ulErrorFound = pdFALSE;
                        ulErrorFound |= 1UL << 0UL;\r
                }\r
 \r
-#ifdef _RB_\r
                if( xAreMathsTaskStillRunning() != pdTRUE )\r
                {\r
                        ulErrorFound |= 1UL << 1UL;\r
                }\r
-#endif\r
+\r
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
                {\r
                        ulErrorFound |= 1UL << 2UL;\r
@@ -349,11 +362,6 @@ unsigned long ulErrorFound = pdFALSE;
                        ulErrorFound |= 1UL << 8UL;\r
                }\r
 \r
-               if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS )\r
-               {\r
-                       ulErrorFound |= 1UL << 9UL;\r
-               }\r
-\r
                if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
                {\r
                        ulErrorFound |= 1UL << 10UL;\r
@@ -405,7 +413,6 @@ unsigned long ulErrorFound = pdFALSE;
                        gone wrong (it might just be that the loop back connector required\r
                        by the comtest tasks has not been fitted). */\r
                        xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;\r
-                       pcStatusMessage = "Error found in at least one task.";\r
                }\r
        }\r
 }\r
@@ -413,7 +420,7 @@ unsigned long ulErrorFound = pdFALSE;
 \r
 static void prvPseudoRandomiser( void *pvParameters )\r
 {\r
-const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = ( 35 / portTICK_PERIOD_MS );\r
+const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = pdMS_TO_TICKS( 35 );\r
 volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;\r
 \r
        /* This task does nothing other than ensure there is a little bit of\r
@@ -440,7 +447,7 @@ volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;
                        __asm volatile( "NOP" );\r
                        __asm volatile( "NOP" );\r
                        __asm volatile( "NOP" );\r
-\r
+                       vTaskDelay( 2 );\r
                        ulValue--;\r
                }\r
        }\r
@@ -449,10 +456,6 @@ volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;
 \r
 void vFullDemoTickHook( void )\r
 {\r
-       /* The full demo includes a software timer demo/test that requires\r
-       prodding periodically from the tick interrupt. */\r
-       vTimerPeriodicISRTests();\r
-\r
        /* Call the periodic queue overwrite from ISR demo. */\r
        vQueueOverwritePeriodicISRDemo();\r
 \r