* In addition to the standard demo tasks, the following tasks and timer are\r
* defined and/or created within this file:\r
*\r
+ * "Command console task" - This uses the Atmel USART driver to provide the\r
+ * input and output to FreeRTOS+CLI - the FreeRTOS Command Line Interface. To\r
+ * use the CLI:\r
+ * - Power the SAMD20 XPlained board through the USB debugger connector. This\r
+ * will create a virtual COM port through the USB.\r
+ * - Build and run the demo application. \r
+ * - Start a dumb terminal program such as TerraTerm or Hyper Terminal.\r
+ * - In the dumb terminal select the UART port associated with the XPlained\r
+ * debugger connection, using 19200 baud.\r
+ * - Type 'help' in the terminal window to see a lit of command registered by\r
+ * the demo.\r
+ *\r
* "Reg test" tasks - These fill the registers with known values, then check\r
* that each register maintains its expected value for the lifetime of the\r
* task. Each task uses a different set of values. The reg test tasks execute\r
extern void vRegTest2Task( void *pvParameters );\r
\r
/*\r
- * Function that starts the command console.\r
+ * Function that starts the command console task.\r
*/\r
extern void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority );\r
\r
actually start running until the scheduler starts. A block time of\r
zero is used in this call, although any value could be used as the block\r
time will be ignored because the scheduler has not started yet. */\r
+ configASSERT( xTimer );\r
if( xTimer != NULL )\r
{\r
xTimerStart( xTimer, mainDONT_BLOCK );\r
running, and that none have detected an error. */\r
if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 0UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xAreBlockTimeTestTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 1UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xAreCountingSemaphoreTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 2UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xAreRecursiveMutexTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 3UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
/* Check that the register test 1 task is still running. */\r
if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
{\r
- ulErrorFound |= ( 0x01UL << 4UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
ulLastRegTest1Value = ulRegTest1LoopCounter;\r
\r
/* Check that the register test 2 task is still running. */\r
if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
{\r
- ulErrorFound |= ( 0x01UL << 5UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
ulLastRegTest2Value = ulRegTest2LoopCounter;\r
\r
+ \r
if( xAreQueueSetTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 6UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 7UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xAreGenericQueueTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 8UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
\r
if( xAreQueuePeekTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound |= ( 0x01UL << 9UL );\r
+ ulErrorFound = pdTRUE;\r
}\r
- \r
+\r
/* Toggle the check LED to give an indication of the system status. If\r
the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
everything is ok. A faster toggle indicates an error. */\r
/*-----------------------------------------------------------*/\r
\r
/*\r
- * Perform any application specific hardware configuration. The clocks,\r
- * memory, etc. are configured before main() is called.\r
+ * Perform any application specific hardware configuration. \r
*/\r
static void prvSetupHardware( void );\r
\r
configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be\r
added here, but the tick hook is called from an interrupt context, so\r
code must not attempt to block, and only the interrupt safe FreeRTOS API\r
- functions can be used (those that end in FromISR()). The code in this\r
- tick hook implementation is for demonstration only - it has no real\r
- purpose. It just gives a semaphore every 50ms. The semaphore unblocks a\r
- task that then toggles an LED. Additionally, the call to\r
- vQueueSetAccessQueueSetFromISR() is part of the "standard demo tasks"\r
- functionality. */\r
+ functions can be used (those that end in FromISR()). */\r
\r
/* The semaphore and associated task are not created when the simple blinky\r
demo is used. */\r
\r
void vMainConfigureTimerForRunTimeStats( void )\r
{\r
+ /* Used by the optional run-time stats gathering functionality. */\r
+ \r
/* How many clocks are there per tenth of a millisecond? */\r
ulClocksPer10thOfAMilliSecond = configCPU_CLOCK_HZ / 10000UL;\r
}\r
volatile unsigned long * const pulInterruptCTRLState = ( ( volatile unsigned long *) 0xe000ed04 );\r
const unsigned long ulSysTickPendingBit = 0x04000000UL;\r
\r
+ /* Used by the optional run-time stats gathering functionality. */\r
+\r
+\r
/* NOTE: There are potentially race conditions here. However, it is used\r
anyway to keep the examples simple, and to avoid reliance on a separate\r
timer peripheral. */\r
\r
return ulReturn; \r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+#ifdef JUST_AN_EXAMPLE_ISR\r
+\r
+void Dummy_IRQHandler(void)\r
+{\r
+long lHigherPriorityTaskWoken = pdFALSE;\r
+\r
+ /* Clear the interrupt if necessary. */\r
+ Dummy_ClearITPendingBit();\r
+\r
+ /* This interrupt does nothing more than demonstrate how to synchronise a\r
+ task with an interrupt. A semaphore is used for this purpose. Note\r
+ lHigherPriorityTaskWoken is initialised to zero. Only FreeRTOS API functions\r
+ that end in "FromISR" can be called from an ISR. */\r
+ xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken );\r
+\r
+ /* If there was a task that was blocked on the semaphore, and giving the\r
+ semaphore caused the task to unblock, and the unblocked task has a priority\r
+ higher than the current Running state task (the task that this interrupt\r
+ interrupted), then lHigherPriorityTaskWoken will have been set to pdTRUE\r
+ internally within xSemaphoreGiveFromISR(). Passing pdTRUE into the\r
+ portEND_SWITCHING_ISR() macro will result in a context switch being pended to\r
+ ensure this interrupt returns directly to the unblocked, higher priority,\r
+ task. Passing pdFALSE into portEND_SWITCHING_ISR() has no effect. */\r
+ portEND_SWITCHING_ISR( lHigherPriorityTaskWoken );\r
+}\r
+\r
+#endif /* JUST_AN_EXAMPLE_ISR */\r
\r