licensing and training services.\r
*/\r
\r
-/* Standard includes. */\r
-#include <stdlib.h>\r
-#include <string.h>\r
+/*\r
+ *\r
+ * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON\r
+ * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
+ * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!\r
+ *\r
+ *\r
+ * main() creates the demo application tasks and timers, then starts the\r
+ * scheduler.\r
+ *\r
+ * This demo is configured to run on the RL78/G13 Promotion Board, which is\r
+ * fitted with a R5F100LEA microcontroller. The R5F100LEA contains a little\r
+ * under 4K bytes of usable internal RAM. The RAM size restricts the number of\r
+ * demo tasks that can be created, and the demo creates 13 tasks, 4 queues and\r
+ * two timers. The RL78 range does however include parts with up to 32K bytes\r
+ * of RAM (at the time of writing). Using FreeRTOS on such a part will allow an\r
+ * application to make a more comprehensive use of FreeRTOS tasks, and other\r
+ * FreeRTOS features.\r
+ *\r
+ * In addition to the standard demo tasks, the following tasks, tests and timers\r
+ * are created within this file:\r
+ *\r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register still contains its expected value. Each task uses a\r
+ * different set of values. The reg test tasks execute with a very low priority,\r
+ * so get preempted very frequently. A register containing an unexpected value\r
+ * is indicative of an error in the context switching mechanism.\r
+ *\r
+ * The "Demo" Timer and Callback Function:\r
+ * The demo timer callback function does nothing more than increment a variable.\r
+ * The period of the demo timer is set relative to the period of the check timer\r
+ * (described below). This allows the check timer to know how many times the\r
+ * demo timer callback function should execute between each execution of the\r
+ * check timer callback function. The variable incremented in the demo timer\r
+ * callback function is used to determine how many times the callback function\r
+ * has executed.\r
+ *\r
+ * The "Check" Timer and Callback Function:\r
+ * The check timer period is initially set to three seconds. The check timer\r
+ * callback function checks that all the standard demo tasks, the reg test tasks,\r
+ * and the demo timer are not only still executing, but are executing without\r
+ * reporting any errors. If the check timer discovers that a task or timer has\r
+ * stalled, or reported an error, then it changes its own period from the\r
+ * initial three seconds, to just 200ms. The check timer callback function also\r
+ * toggles the user LED each time it is called. This provides a visual\r
+ * indication of the system status: If the LED toggles every three seconds,\r
+ * then no issues have been discovered. If the LED toggles every 200ms, then an\r
+ * issue has been discovered with at least one task.\r
+ *\r
+ */\r
\r
/* Scheduler include files. */\r
#include "FreeRTOS.h"\r
equivalent in ticks using the portTICK_RATE_MS constant. */\r
#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_RATE_MS )\r
\r
-/* These are used to set the period of the demo timer. The demo timer period\r
-is always relative to the check timer period, so the check timer can determine\r
-if the demo timer has expired the expected number of times between its own\r
-executions. */\r
-#define mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT ( 100UL )\r
-#define mainDEMO_TIMER_PERIOD_MS ( mainCHECK_TIMER_PERIOD_MS / mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT )\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_RATE_MS constant. */\r
+reported in one of the standard demo tasks, the check tasks, or the demo timer.\r
+ms are converted to the equivalent in ticks using the portTICK_RATE_MS\r
+constant. */\r
#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_RATE_MS )\r
\r
-/* The LED toggled by the check task. */\r
+/* These two definitions are used to set the period of the demo timer. The demo\r
+timer period is always relative to the check timer period, so the check timer\r
+can determine if the demo timer has expired the expected number of times between\r
+its own executions. */\r
+#define mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT ( 100UL )\r
+#define mainDEMO_TIMER_PERIOD_MS ( mainCHECK_TIMER_PERIOD_MS / mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT )\r
+\r
+/* The LED toggled by the check timer. */\r
#define mainLED_0 P7_bit.no7\r
\r
/* A block time of zero simple means "don't block". */\r
int __low_level_init(void);\r
\r
/*\r
- * Functions that define the RegTest tasks as described at the top of this file.\r
+ * Functions that define the RegTest tasks, as described at the top of this file.\r
*/\r
extern void vRegTest1( void *pvParameters );\r
extern void vRegTest2( void *pvParameters );\r
/*-----------------------------------------------------------*/\r
\r
/* If an error is discovered by one of the RegTest tasks then this flag is set\r
-to pdFAIL. The 'check' task then inspects this flag to detect errors within\r
+to pdFAIL. The 'check' timer then inspects this flag to detect errors within\r
the RegTest tasks. */\r
static short sRegTestStatus = pdPASS;\r
\r
function. */\r
static xTimerHandle xCheckTimer = NULL;\r
\r
-/* This time is just for demo purposes. */\r
+/* The demo timer. This uses prvDemoTimerCallback() as its callback function. */\r
static xTimerHandle xDemoTimer = NULL;\r
\r
/* This variable is incremented each time the demo timer expires. */\r
static portBASE_TYPE xChangedTimerPeriodAlready = pdFALSE, xErrorStatus = pdPASS;\r
static unsigned long ulLastDemoTimerCounter = 0UL;\r
\r
+ /* Inspect the status of the standard demo tasks. */\r
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
{\r
xErrorStatus = pdFAIL;\r
xErrorStatus = pdFAIL;\r
}\r
\r
+ /* Inspect the status of the reg test tasks. */\r
if( sRegTestStatus != pdPASS )\r
{\r
xErrorStatus = pdFAIL;\r
}\r
\r
/* Ensure that the demo timer has expired at\r
- mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT times in between\r
+ mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT times in between\r
each call of this function. */\r
- if( ( ulDemoTimerCounter - ulLastDemoTimerCounter ) < ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEROUT - 1 ) )\r
+ if( ( ulDemoTimerCounter - ulLastDemoTimerCounter ) < ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT - 1 ) )\r
{\r
xErrorStatus = pdFAIL;\r
}\r