* check task 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
+ * The "Register Check" tasks. These tasks fill the CPU registers with known\r
+ * values, then check that each register still contains the expected value, the\r
+ * discovery of an unexpected value being indicative of an error in the RTOS\r
+ * context switch mechanism. The register check tasks operate at low priority\r
+ * so are switched in and out frequently.\r
+ *\r
*/\r
\r
\r
/* Scheduler includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
+\r
+/* Xilinx library includes. */\r
+#include "xcache_l.h"\r
+#include "xintc.h"\r
+\r
+/* Demo application includes. */\r
#include "flash.h"\r
#include "integer.h"\r
#include "comtest2.h"\r
#include "blocktim.h"\r
#include "death.h"\r
#include "partest.h"\r
-#include "xcache_l.h"\r
-#include "xintc.h"\r
\r
+/* Priorities assigned to the demo tasks. */\r
#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 4 )\r
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 3 )\r
#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
#define mainGENERIC_QUEUE_PRIORITY ( tskIDLE_PRIORITY )\r
\r
-#define mainCOM_TEST_BAUD_RATE ( 115200UL )\r
+/* The first LED used by the COM test and check tasks respectively. */\r
#define mainCOM_TEST_LED ( 4 )\r
+#define mainCHECK_TEST_LED ( 3 )\r
\r
+/* The baud rate used by the comtest tasks is set by the hardware, so the\r
+baud rate parameters passed into the comtest initialisation has no effect. */\r
+#define mainBAUD_SET_IN_HARDWARE ( 0 )\r
+\r
+/* Delay periods used by the check task. If no errors have been found then\r
+the check LED will toggle every mainNO_ERROR_CHECK_DELAY milliseconds. If an\r
+error has been found at any time then the toggle rate will increase to \r
+mainERROR_CHECK_DELAY milliseconds. */\r
#define mainNO_ERROR_CHECK_DELAY ( ( portTickType ) 3000 / portTICK_RATE_MS )\r
#define mainERROR_CHECK_DELAY ( ( portTickType ) 500 / portTICK_RATE_MS )\r
\r
-#define mainCHECK_TEST_LED ( 3 )\r
\r
+/* \r
+ * The tasks defined within this file - described within the comments at the\r
+ * head of this page. \r
+ */\r
static void prvRegTestTask1( void *pvParameters );\r
static void prvRegTestTask2( void *pvParameters );\r
-static void prvFlashTask( void *pvParameters );\r
static void prvErrorChecks( void *pvParameters );\r
\r
-static unsigned portBASE_TYPE xRegTestStatus = pdPASS;\r
+/*\r
+ * Called by the 'check' task to inspect all the standard demo tasks within\r
+ * the system, as described within the comments at the head of this page.\r
+ */\r
static portSHORT prvCheckOtherTasksAreStillRunning( void );\r
\r
-XIntc xInterruptController;\r
-extern void vPortISRWrapper( void );\r
+/*\r
+ * Perform any hardware initialisation required by the demo application.\r
+ */\r
+static void prvSetupHardware( void );\r
\r
-int main( void )\r
-{\r
- XCache_EnableICache( 0x80000000 );\r
- XCache_EnableDCache( 0x80000000 );\r
+/*-----------------------------------------------------------*/\r
\r
- XExc_Init();\r
- XExc_mDisableExceptions( XEXC_NON_CRITICAL );\r
- XExc_RegisterHandler( XEXC_ID_NON_CRITICAL_INT, (XExceptionHandler)vPortISRWrapper, &xInterruptController );\r
+/* xRegTestStatus will geet set to pdFAIL by the regtest tasks if they\r
+discover an unexpected value. */\r
+static unsigned portBASE_TYPE xRegTestStatus = pdPASS;\r
\r
- XIntc_Initialize( &xInterruptController, XPAR_OPB_INTC_0_DEVICE_ID );\r
- XIntc_Start( &xInterruptController, XIN_REAL_MODE );\r
+/*-----------------------------------------------------------*/\r
\r
- vParTestInitialise();\r
+int main( void )\r
+{\r
+ /* Must be called prior to installing any interrupt handlers! */\r
+ vPortSetupInterruptController();\r
\r
- /* Start the standard demo application tasks. */\r
+ /* In this case prvSetupHardware() just enables the caches and and\r
+ configures the IO ports for the LED outputs. */\r
+ prvSetupHardware();\r
+\r
+ /* Start the standard demo application tasks. Note that the baud rate used\r
+ by the comtest tasks is set by the hardware, so the baud rate paramter\r
+ passed has no effect. */\r
vStartLEDFlashTasks( mainLED_TASK_PRIORITY ); \r
vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
- vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
+ vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainBAUD_SET_IN_HARDWARE, mainCOM_TEST_LED );\r
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
vStartBlockingQueueTasks ( mainQUEUE_BLOCK_PRIORITY ); \r
vStartDynamicPriorityTasks(); \r
vStartQueuePeekTasks();\r
vCreateBlockTimeTasks();\r
\r
+ /* Create the tasks defined within this file. */\r
xTaskCreate( prvRegTestTask1, "Regtest1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
xTaskCreate( prvRegTestTask2, "Regtest2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
xTaskCreate( prvErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
/* Now start the scheduler. Following this call the created tasks should\r
be executing. */ \r
vTaskStartScheduler( );\r
- \r
+\r
/* vTaskStartScheduler() will only return if an error occurs while the \r
idle task is being created. */\r
for( ;; );\r
\r
return 0;\r
}\r
+/*-----------------------------------------------------------*/\r
\r
static portSHORT prvCheckOtherTasksAreStillRunning( void )\r
{\r
}\r
/*-----------------------------------------------------------*/\r
\r
+static void prvSetupHardware( void )\r
+{\r
+ XCache_EnableICache( 0x80000000 );\r
+ XCache_EnableDCache( 0x80000000 );\r
+\r
+ vParTestInitialise();\r
+}\r
\r
static void prvRegTestTask1( void *pvParameters )\r
{\r