/* Co-routines MUST start with a call to crSTART. */\r
crSTART( xHandle );\r
( void ) uxIndex;\r
- \r
+\r
for( ;; )\r
{\r
/* Block to wait for the number of the LED to flash. */\r
- crQUEUE_RECEIVE( xHandle, xFlashQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); \r
+ crQUEUE_RECEIVE( xHandle, xFlashQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );\r
\r
if( xResult != pdPASS )\r
{\r
*/\r
\r
/*\r
- * This demo file demonstrates how to send data between an ISR and a \r
+ * This demo file demonstrates how to send data between an ISR and a\r
* co-routine. A tick hook function is used to periodically pass data between\r
* the RTOS tick and a set of 'hook' co-routines.\r
*\r
* to wait for a character to be received on a queue from the tick ISR, checks\r
* to ensure the character received was that expected, then sends the number\r
* back to the tick ISR on a different queue.\r
- * \r
- * The tick ISR checks the numbers received back from the 'hook' co-routines \r
+ *\r
+ * The tick ISR checks the numbers received back from the 'hook' co-routines\r
* matches the number previously sent.\r
*\r
* If at any time a queue function returns unexpectedly, or an incorrect value\r
- * is received either by the tick hook or a co-routine then an error is \r
+ * is received either by the tick hook or a co-routine then an error is\r
* latched.\r
*\r
- * This demo relies on each 'hook' co-routine to execute between each \r
- * hookTICK_CALLS_BEFORE_POST tick interrupts. This and the heavy use of \r
- * queues from within an interrupt may result in an error being detected on \r
+ * This demo relies on each 'hook' co-routine to execute between each\r
+ * hookTICK_CALLS_BEFORE_POST tick interrupts. This and the heavy use of\r
+ * queues from within an interrupt may result in an error being detected on\r
* slower targets simply due to timing.\r
*/\r
\r
/* The number of 'hook' co-routines that are to be created. */\r
#define hookNUM_HOOK_CO_ROUTINES ( 4 )\r
\r
-/* The number of times the tick hook should be called before a character is \r
+/* The number of times the tick hook should be called before a character is\r
posted to the 'hook' co-routines. */\r
#define hookTICK_CALLS_BEFORE_POST ( 500 )\r
\r
\r
/*\r
* The tick hook function. This receives a number from each 'hook' co-routine\r
- * then sends a number to each co-routine. An error is flagged if a send or \r
+ * then sends a number to each co-routine. An error is flagged if a send or\r
* receive fails, or an unexpected number is received.\r
*/\r
void vApplicationTickHook( void );\r
\r
for( uxIndex = 0; uxIndex < hookNUM_HOOK_CO_ROUTINES; uxIndex++ )\r
{\r
- /* Create a queue to transmit to and receive from each 'hook' \r
+ /* Create a queue to transmit to and receive from each 'hook'\r
co-routine. */\r
xHookRxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) );\r
xHookTxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) );\r
\r
- /* To start things off the tick hook function expects the queue it \r
+ /* To start things off the tick hook function expects the queue it\r
uses to receive data to contain a value. */\r
xQueueSend( xHookRxQueues[ uxIndex ], &uxValueToPost, hookNO_BLOCK_TIME );\r
\r
xCoRoutineWoken = pdFALSE;\r
if( crQUEUE_RECEIVE_FROM_ISR( xHookRxQueues[ xIndex ], &uxReceivedNumber, &xCoRoutineWoken ) != pdPASS )\r
{\r
- /* There is no reason why we would not expect the queue to \r
+ /* There is no reason why we would not expect the queue to\r
contain a value. */\r
xCoRoutineErrorDetected = pdTRUE;\r
}\r
else\r
{\r
- /* Each queue used to receive data from the 'hook' co-routines \r
+ /* Each queue used to receive data from the 'hook' co-routines\r
should contain the number we last posted to the same co-routine. */\r
if( uxReceivedNumber != uxNumberToPost )\r
{\r
{\r
if( crQUEUE_SEND_FROM_ISR( xHookTxQueues[ xIndex ], &uxNumberToPost, pdFALSE ) != pdTRUE )\r
{\r
- /* Posting to the queue should have woken the co-routine that \r
+ /* Posting to the queue should have woken the co-routine that\r
was blocked on the queue. */\r
xCoRoutineErrorDetected = pdTRUE;\r
}\r
crQUEUE_SEND( xHandle, xHookRxQueues[ uxIndex ], &( uxReceivedValue[ uxIndex ] ), hookNO_BLOCK_TIME, &xResult );\r
if( xResult != pdPASS )\r
{\r
- /* There is no reason why we should not have been able to post to \r
+ /* There is no reason why we should not have been able to post to\r
the queue. */\r
xCoRoutineErrorDetected = pdTRUE;\r
}\r
\r
/**\r
* This version of flash .c is for use on systems that have limited stack space\r
- * and no display facilities. The complete version can be found in the \r
+ * and no display facilities. The complete version can be found in the\r
* Demo/Common/Full directory.\r
- * \r
- * Three tasks are created, each of which flash an LED at a different rate. The first \r
+ *\r
+ * Three tasks are created, each of which flash an LED at a different rate. The first\r
* LED flashes every 200ms, the second every 400ms, the third every 600ms.\r
*\r
- * The LED flash tasks provide instant visual feedback. They show that the scheduler \r
+ * The LED flash tasks provide instant visual feedback. They show that the scheduler\r
* is still operational.\r
*\r
*/\r
delay is only half the total period. */\r
xFlashRate /= ( TickType_t ) 2;\r
\r
- /* We need to initialise xLastFlashTime prior to the first call to \r
+ /* We need to initialise xLastFlashTime prior to the first call to\r
vTaskDelayUntil(). */\r
xLastFlashTime = xTaskGetTickCount();\r
\r
\r
/*\r
* Creates one or more tasks that repeatedly perform a set of integer\r
- * calculations. The result of each run-time calculation is compared to the \r
+ * calculations. The result of each run-time calculation is compared to the\r
* known expected result - with a mismatch being indicative of an error in the\r
* context switch mechanism.\r
*/\r
lValue *= intgCONST3;\r
lValue /= intgCONST4;\r
\r
- /* If the calculation is found to be incorrect we stop setting the \r
- TaskHasExecuted variable so the check task can see an error has \r
+ /* If the calculation is found to be incorrect we stop setting the\r
+ TaskHasExecuted variable so the check task can see an error has\r
occurred. */\r
if( lValue != intgEXPECTED_ANSWER ) /*lint !e774 volatile used to prevent this being optimised out. */\r
{\r
BaseType_t xReturn = pdTRUE;\r
short sTask;\r
\r
- /* Check the maths tasks are still running by ensuring their check variables \r
+ /* Check the maths tasks are still running by ensuring their check variables\r
are still being set to true. */\r
for( sTask = 0; sTask < intgNUMBER_OF_TASKS; sTask++ )\r
{\r
if( pxFirstSemaphoreParameters != NULL )\r
{\r
/* Create the semaphore used by the first two tasks. */\r
- pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary(); \r
+ pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();\r
\r
if( pxFirstSemaphoreParameters->xSemaphore != NULL )\r
{\r
xSemaphoreGive( pxFirstSemaphoreParameters->xSemaphore );\r
- \r
+\r
/* Create the variable which is to be shared by the first two tasks. */\r
pxFirstSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );\r
\r
pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );\r
if( pxSecondSemaphoreParameters != NULL )\r
{\r
- pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary(); \r
+ pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();\r
\r
if( pxSecondSemaphoreParameters->xSemaphore != NULL )\r
{\r
xSemaphoreGive( pxSecondSemaphoreParameters->xSemaphore );\r
- \r
+\r
pxSecondSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );\r
*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;\r
pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_PERIOD_MS;\r
*/\r
\r
/*\r
- * Creates eight tasks, each of which loops continuously performing a floating \r
+ * Creates eight tasks, each of which loops continuously performing a floating\r
* point calculation - using single precision variables.\r
*\r
- * All the tasks run at the idle priority and never block or yield. This causes \r
- * all eight tasks to time slice with the idle task. Running at the idle priority \r
+ * All the tasks run at the idle priority and never block or yield. This causes\r
+ * all eight tasks to time slice with the idle task. Running at the idle priority\r
* means that these tasks will get pre-empted any time another task is ready to run\r
- * or a time slice occurs. More often than not the pre-emption will occur mid \r
- * calculation, creating a good test of the schedulers context switch mechanism - a \r
- * calculation producing an unexpected result could be a symptom of a corruption in \r
+ * or a time slice occurs. More often than not the pre-emption will occur mid\r
+ * calculation, creating a good test of the schedulers context switch mechanism - a\r
+ * calculation producing an unexpected result could be a symptom of a corruption in\r
* the context of a task.\r
*/\r
\r
#define mathSTACK_SIZE configMINIMAL_STACK_SIZE\r
#define mathNUMBER_OF_TASKS ( 8 )\r
\r
-/* Four tasks, each of which performs a different floating point calculation. \r
+/* Four tasks, each of which performs a different floating point calculation.\r
Each of the four is created twice. */\r
static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters );\r
static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters );\r
static portTASK_FUNCTION_PROTO( vCompetingMathTask3, pvParameters );\r
static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters );\r
\r
-/* These variables are used to check that all the tasks are still running. If a \r
+/* These variables are used to check that all the tasks are still running. If a\r
task gets a calculation wrong it will\r
stop incrementing its check variable. */\r
static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };\r
\r
fAnswer = ( f1 + f2 ) * f3;\r
\r
- /* The variable this task increments to show it is still running is passed in \r
+ /* The variable this task increments to show it is still running is passed in\r
as the parameter. */\r
pusTaskCheckVariable = ( uint16_t * ) pvParameters;\r
\r
taskYIELD();\r
#endif\r
\r
- /* If the calculation does not match the expected constant, stop the \r
+ /* If the calculation does not match the expected constant, stop the\r
increment of the check variable. */\r
if( fabs( f4 - fAnswer ) > 0.001F )\r
{\r
\r
if( sError == pdFALSE )\r
{\r
- /* If the calculation has always been correct, increment the check \r
+ /* If the calculation has always been correct, increment the check\r
variable so we know this task is still running okay. */\r
( *pusTaskCheckVariable )++;\r
}\r
fAnswer = ( f1 / f2 ) * f3;\r
\r
\r
- /* The variable this task increments to show it is still running is passed in \r
+ /* The variable this task increments to show it is still running is passed in\r
as the parameter. */\r
pusTaskCheckVariable = ( uint16_t * ) pvParameters;\r
\r
#if configUSE_PREEMPTION == 0\r
taskYIELD();\r
#endif\r
- \r
- /* If the calculation does not match the expected constant, stop the \r
+\r
+ /* If the calculation does not match the expected constant, stop the\r
increment of the check variable. */\r
if( fabs( f4 - fAnswer ) > 0.001F )\r
{\r
\r
if( sError == pdFALSE )\r
{\r
- /* If the calculation has always been correct, increment the check \r
+ /* If the calculation has always been correct, increment the check\r
variable so we know\r
this task is still running okay. */\r
( *pusTaskCheckVariable )++;\r
size_t xPosition;\r
short sError = pdFALSE;\r
\r
- /* The variable this task increments to show it is still running is passed in \r
+ /* The variable this task increments to show it is still running is passed in\r
as the parameter. */\r
pusTaskCheckVariable = ( uint16_t * ) pvParameters;\r
\r
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );\r
\r
- /* Keep filling an array, keeping a running total of the values placed in the \r
- array. Then run through the array adding up all the values. If the two totals \r
+ /* Keep filling an array, keeping a running total of the values placed in the\r
+ array. Then run through the array adding up all the values. If the two totals\r
do not match, stop the check variable from incrementing. */\r
for( ;; )\r
{\r
fTotal1 = 0.0F;\r
fTotal2 = 0.0F;\r
fPosition = 0.0F;\r
- \r
+\r
for( xPosition = 0; xPosition < xArraySize; xPosition++ )\r
{\r
pfArray[ xPosition ] = fPosition + 5.5F;\r
- fTotal1 += fPosition + 5.5F; \r
+ fTotal1 += fPosition + 5.5F;\r
}\r
\r
#if configUSE_PREEMPTION == 0\r
\r
if( sError == pdFALSE )\r
{\r
- /* If the calculation has always been correct, increment the check \r
+ /* If the calculation has always been correct, increment the check\r
variable so we know this task is still running okay. */\r
( *pusTaskCheckVariable )++;\r
}\r
size_t xPosition;\r
short sError = pdFALSE;\r
\r
- /* The variable this task increments to show it is still running is passed in \r
+ /* The variable this task increments to show it is still running is passed in\r
as the parameter. */\r
pusTaskCheckVariable = ( uint16_t * ) pvParameters;\r
\r
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );\r
\r
- /* Keep filling an array, keeping a running total of the values placed in the \r
- array. Then run through the array adding up all the values. If the two totals \r
+ /* Keep filling an array, keeping a running total of the values placed in the\r
+ array. Then run through the array adding up all the values. If the two totals\r
do not match, stop the check variable from incrementing. */\r
for( ;; )\r
{\r
for( xPosition = 0; xPosition < xArraySize; xPosition++ )\r
{\r
pfArray[ xPosition ] = fPosition * 12.123F;\r
- fTotal1 += fPosition * 12.123F; \r
+ fTotal1 += fPosition * 12.123F;\r
}\r
\r
#if configUSE_PREEMPTION == 0\r
\r
if( sError == pdFALSE )\r
{\r
- /* If the calculation has always been correct, increment the check \r
+ /* If the calculation has always been correct, increment the check\r
variable so we know this task is still running okay. */\r
( *pusTaskCheckVariable )++;\r
}\r
}\r
-} \r
+}\r
/*-----------------------------------------------------------*/\r
\r
/* This is called to check that all the created tasks are still running. */\r
BaseType_t xAreMathsTaskStillRunning( void )\r
{\r
-/* Keep a history of the check variables so we know if they have been incremented \r
+/* Keep a history of the check variables so we know if they have been incremented\r
since the last call. */\r
static uint16_t usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };\r
BaseType_t xReturn = pdTRUE, xTask;\r
\r
- /* Check the maths tasks are still running by ensuring their check variables \r
+ /* Check the maths tasks are still running by ensuring their check variables\r
are still incrementing. */\r
for( xTask = 0; xTask < mathNUMBER_OF_TASKS; xTask++ )\r
{\r