Cosmetic changes only.

This commit is contained in:
Richard Barry 2017-04-26 00:23:57 +00:00
parent a99cd32208
commit 2e89c13c1c
6 changed files with 59 additions and 59 deletions

View file

@ -218,11 +218,11 @@ UBaseType_t uxLEDToFlash;
/* Co-routines MUST start with a call to crSTART. */ /* Co-routines MUST start with a call to crSTART. */
crSTART( xHandle ); crSTART( xHandle );
( void ) uxIndex; ( void ) uxIndex;
for( ;; ) for( ;; )
{ {
/* Block to wait for the number of the LED to flash. */ /* Block to wait for the number of the LED to flash. */
crQUEUE_RECEIVE( xHandle, xFlashQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); crQUEUE_RECEIVE( xHandle, xFlashQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
if( xResult != pdPASS ) if( xResult != pdPASS )
{ {

View file

@ -68,7 +68,7 @@
*/ */
/* /*
* This demo file demonstrates how to send data between an ISR and a * This demo file demonstrates how to send data between an ISR and a
* co-routine. A tick hook function is used to periodically pass data between * co-routine. A tick hook function is used to periodically pass data between
* the RTOS tick and a set of 'hook' co-routines. * the RTOS tick and a set of 'hook' co-routines.
* *
@ -76,17 +76,17 @@
* to wait for a character to be received on a queue from the tick ISR, checks * to wait for a character to be received on a queue from the tick ISR, checks
* to ensure the character received was that expected, then sends the number * to ensure the character received was that expected, then sends the number
* back to the tick ISR on a different queue. * back to the tick ISR on a different queue.
* *
* The tick ISR checks the numbers received back from the 'hook' co-routines * The tick ISR checks the numbers received back from the 'hook' co-routines
* matches the number previously sent. * matches the number previously sent.
* *
* If at any time a queue function returns unexpectedly, or an incorrect value * If at any time a queue function returns unexpectedly, or an incorrect value
* is received either by the tick hook or a co-routine then an error is * is received either by the tick hook or a co-routine then an error is
* latched. * latched.
* *
* This demo relies on each 'hook' co-routine to execute between each * This demo relies on each 'hook' co-routine to execute between each
* hookTICK_CALLS_BEFORE_POST tick interrupts. This and the heavy use of * hookTICK_CALLS_BEFORE_POST tick interrupts. This and the heavy use of
* queues from within an interrupt may result in an error being detected on * queues from within an interrupt may result in an error being detected on
* slower targets simply due to timing. * slower targets simply due to timing.
*/ */
@ -101,7 +101,7 @@
/* The number of 'hook' co-routines that are to be created. */ /* The number of 'hook' co-routines that are to be created. */
#define hookNUM_HOOK_CO_ROUTINES ( 4 ) #define hookNUM_HOOK_CO_ROUTINES ( 4 )
/* The number of times the tick hook should be called before a character is /* The number of times the tick hook should be called before a character is
posted to the 'hook' co-routines. */ posted to the 'hook' co-routines. */
#define hookTICK_CALLS_BEFORE_POST ( 500 ) #define hookTICK_CALLS_BEFORE_POST ( 500 )
@ -124,7 +124,7 @@ static void prvHookCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex );
/* /*
* The tick hook function. This receives a number from each 'hook' co-routine * The tick hook function. This receives a number from each 'hook' co-routine
* then sends a number to each co-routine. An error is flagged if a send or * then sends a number to each co-routine. An error is flagged if a send or
* receive fails, or an unexpected number is received. * receive fails, or an unexpected number is received.
*/ */
void vApplicationTickHook( void ); void vApplicationTickHook( void );
@ -152,12 +152,12 @@ UBaseType_t uxIndex, uxValueToPost = 0;
for( uxIndex = 0; uxIndex < hookNUM_HOOK_CO_ROUTINES; uxIndex++ ) for( uxIndex = 0; uxIndex < hookNUM_HOOK_CO_ROUTINES; uxIndex++ )
{ {
/* Create a queue to transmit to and receive from each 'hook' /* Create a queue to transmit to and receive from each 'hook'
co-routine. */ co-routine. */
xHookRxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) ); xHookRxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) );
xHookTxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) ); xHookTxQueues[ uxIndex ] = xQueueCreate( hookHOOK_QUEUE_LENGTH, sizeof( UBaseType_t ) );
/* To start things off the tick hook function expects the queue it /* To start things off the tick hook function expects the queue it
uses to receive data to contain a value. */ uses to receive data to contain a value. */
xQueueSend( xHookRxQueues[ uxIndex ], &uxValueToPost, hookNO_BLOCK_TIME ); xQueueSend( xHookRxQueues[ uxIndex ], &uxValueToPost, hookNO_BLOCK_TIME );
@ -184,13 +184,13 @@ BaseType_t xIndex, xCoRoutineWoken;
xCoRoutineWoken = pdFALSE; xCoRoutineWoken = pdFALSE;
if( crQUEUE_RECEIVE_FROM_ISR( xHookRxQueues[ xIndex ], &uxReceivedNumber, &xCoRoutineWoken ) != pdPASS ) if( crQUEUE_RECEIVE_FROM_ISR( xHookRxQueues[ xIndex ], &uxReceivedNumber, &xCoRoutineWoken ) != pdPASS )
{ {
/* There is no reason why we would not expect the queue to /* There is no reason why we would not expect the queue to
contain a value. */ contain a value. */
xCoRoutineErrorDetected = pdTRUE; xCoRoutineErrorDetected = pdTRUE;
} }
else else
{ {
/* Each queue used to receive data from the 'hook' co-routines /* Each queue used to receive data from the 'hook' co-routines
should contain the number we last posted to the same co-routine. */ should contain the number we last posted to the same co-routine. */
if( uxReceivedNumber != uxNumberToPost ) if( uxReceivedNumber != uxNumberToPost )
{ {
@ -212,7 +212,7 @@ BaseType_t xIndex, xCoRoutineWoken;
{ {
if( crQUEUE_SEND_FROM_ISR( xHookTxQueues[ xIndex ], &uxNumberToPost, pdFALSE ) != pdTRUE ) if( crQUEUE_SEND_FROM_ISR( xHookTxQueues[ xIndex ], &uxNumberToPost, pdFALSE ) != pdTRUE )
{ {
/* Posting to the queue should have woken the co-routine that /* Posting to the queue should have woken the co-routine that
was blocked on the queue. */ was blocked on the queue. */
xCoRoutineErrorDetected = pdTRUE; xCoRoutineErrorDetected = pdTRUE;
} }
@ -247,7 +247,7 @@ BaseType_t xResult;
crQUEUE_SEND( xHandle, xHookRxQueues[ uxIndex ], &( uxReceivedValue[ uxIndex ] ), hookNO_BLOCK_TIME, &xResult ); crQUEUE_SEND( xHandle, xHookRxQueues[ uxIndex ], &( uxReceivedValue[ uxIndex ] ), hookNO_BLOCK_TIME, &xResult );
if( xResult != pdPASS ) if( xResult != pdPASS )
{ {
/* There is no reason why we should not have been able to post to /* There is no reason why we should not have been able to post to
the queue. */ the queue. */
xCoRoutineErrorDetected = pdTRUE; xCoRoutineErrorDetected = pdTRUE;
} }

View file

@ -69,13 +69,13 @@
/** /**
* This version of flash .c is for use on systems that have limited stack space * This version of flash .c is for use on systems that have limited stack space
* and no display facilities. The complete version can be found in the * and no display facilities. The complete version can be found in the
* Demo/Common/Full directory. * Demo/Common/Full directory.
* *
* Three tasks are created, each of which flash an LED at a different rate. The first * Three tasks are created, each of which flash an LED at a different rate. The first
* LED flashes every 200ms, the second every 400ms, the third every 600ms. * LED flashes every 200ms, the second every 400ms, the third every 600ms.
* *
* The LED flash tasks provide instant visual feedback. They show that the scheduler * The LED flash tasks provide instant visual feedback. They show that the scheduler
* is still operational. * is still operational.
* *
*/ */
@ -143,7 +143,7 @@ UBaseType_t uxLED;
delay is only half the total period. */ delay is only half the total period. */
xFlashRate /= ( TickType_t ) 2; xFlashRate /= ( TickType_t ) 2;
/* We need to initialise xLastFlashTime prior to the first call to /* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */ vTaskDelayUntil(). */
xLastFlashTime = xTaskGetTickCount(); xLastFlashTime = xTaskGetTickCount();

View file

@ -69,7 +69,7 @@
/* /*
* Creates one or more tasks that repeatedly perform a set of integer * Creates one or more tasks that repeatedly perform a set of integer
* calculations. The result of each run-time calculation is compared to the * calculations. The result of each run-time calculation is compared to the
* known expected result - with a mismatch being indicative of an error in the * known expected result - with a mismatch being indicative of an error in the
* context switch mechanism. * context switch mechanism.
*/ */
@ -151,8 +151,8 @@ volatile BaseType_t *pxTaskHasExecuted;
lValue *= intgCONST3; lValue *= intgCONST3;
lValue /= intgCONST4; lValue /= intgCONST4;
/* If the calculation is found to be incorrect we stop setting the /* If the calculation is found to be incorrect we stop setting the
TaskHasExecuted variable so the check task can see an error has TaskHasExecuted variable so the check task can see an error has
occurred. */ occurred. */
if( lValue != intgEXPECTED_ANSWER ) /*lint !e774 volatile used to prevent this being optimised out. */ if( lValue != intgEXPECTED_ANSWER ) /*lint !e774 volatile used to prevent this being optimised out. */
{ {
@ -185,7 +185,7 @@ BaseType_t xAreIntegerMathsTaskStillRunning( void )
BaseType_t xReturn = pdTRUE; BaseType_t xReturn = pdTRUE;
short sTask; short sTask;
/* Check the maths tasks are still running by ensuring their check variables /* Check the maths tasks are still running by ensuring their check variables
are still being set to true. */ are still being set to true. */
for( sTask = 0; sTask < intgNUMBER_OF_TASKS; sTask++ ) for( sTask = 0; sTask < intgNUMBER_OF_TASKS; sTask++ )
{ {

View file

@ -139,12 +139,12 @@ const TickType_t xBlockTime = ( TickType_t ) 100;
if( pxFirstSemaphoreParameters != NULL ) if( pxFirstSemaphoreParameters != NULL )
{ {
/* Create the semaphore used by the first two tasks. */ /* Create the semaphore used by the first two tasks. */
pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary(); pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
if( pxFirstSemaphoreParameters->xSemaphore != NULL ) if( pxFirstSemaphoreParameters->xSemaphore != NULL )
{ {
xSemaphoreGive( pxFirstSemaphoreParameters->xSemaphore ); xSemaphoreGive( pxFirstSemaphoreParameters->xSemaphore );
/* Create the variable which is to be shared by the first two tasks. */ /* Create the variable which is to be shared by the first two tasks. */
pxFirstSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) ); pxFirstSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );
@ -173,12 +173,12 @@ const TickType_t xBlockTime = ( TickType_t ) 100;
pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) ); pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
if( pxSecondSemaphoreParameters != NULL ) if( pxSecondSemaphoreParameters != NULL )
{ {
pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary(); pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
if( pxSecondSemaphoreParameters->xSemaphore != NULL ) if( pxSecondSemaphoreParameters->xSemaphore != NULL )
{ {
xSemaphoreGive( pxSecondSemaphoreParameters->xSemaphore ); xSemaphoreGive( pxSecondSemaphoreParameters->xSemaphore );
pxSecondSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) ); pxSecondSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );
*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE; *( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;
pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_PERIOD_MS; pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_PERIOD_MS;

View file

@ -68,15 +68,15 @@
*/ */
/* /*
* Creates eight tasks, each of which loops continuously performing a floating * Creates eight tasks, each of which loops continuously performing a floating
* point calculation - using single precision variables. * point calculation - using single precision variables.
* *
* All the tasks run at the idle priority and never block or yield. This causes * All the tasks run at the idle priority and never block or yield. This causes
* all eight tasks to time slice with the idle task. Running at the idle priority * all eight tasks to time slice with the idle task. Running at the idle priority
* means that these tasks will get pre-empted any time another task is ready to run * means that these tasks will get pre-empted any time another task is ready to run
* or a time slice occurs. More often than not the pre-emption will occur mid * or a time slice occurs. More often than not the pre-emption will occur mid
* calculation, creating a good test of the schedulers context switch mechanism - a * calculation, creating a good test of the schedulers context switch mechanism - a
* calculation producing an unexpected result could be a symptom of a corruption in * calculation producing an unexpected result could be a symptom of a corruption in
* the context of a task. * the context of a task.
*/ */
@ -93,14 +93,14 @@
#define mathSTACK_SIZE configMINIMAL_STACK_SIZE #define mathSTACK_SIZE configMINIMAL_STACK_SIZE
#define mathNUMBER_OF_TASKS ( 8 ) #define mathNUMBER_OF_TASKS ( 8 )
/* Four tasks, each of which performs a different floating point calculation. /* Four tasks, each of which performs a different floating point calculation.
Each of the four is created twice. */ Each of the four is created twice. */
static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters );
static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters );
static portTASK_FUNCTION_PROTO( vCompetingMathTask3, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask3, pvParameters );
static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters ); static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters );
/* These variables are used to check that all the tasks are still running. If a /* These variables are used to check that all the tasks are still running. If a
task gets a calculation wrong it will task gets a calculation wrong it will
stop incrementing its check variable. */ stop incrementing its check variable. */
static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };
@ -133,7 +133,7 @@ short sError = pdFALSE;
fAnswer = ( f1 + f2 ) * f3; fAnswer = ( f1 + f2 ) * f3;
/* The variable this task increments to show it is still running is passed in /* The variable this task increments to show it is still running is passed in
as the parameter. */ as the parameter. */
pusTaskCheckVariable = ( uint16_t * ) pvParameters; pusTaskCheckVariable = ( uint16_t * ) pvParameters;
@ -150,7 +150,7 @@ short sError = pdFALSE;
taskYIELD(); taskYIELD();
#endif #endif
/* If the calculation does not match the expected constant, stop the /* If the calculation does not match the expected constant, stop the
increment of the check variable. */ increment of the check variable. */
if( fabs( f4 - fAnswer ) > 0.001F ) if( fabs( f4 - fAnswer ) > 0.001F )
{ {
@ -159,7 +159,7 @@ short sError = pdFALSE;
if( sError == pdFALSE ) if( sError == pdFALSE )
{ {
/* If the calculation has always been correct, increment the check /* If the calculation has always been correct, increment the check
variable so we know this task is still running okay. */ variable so we know this task is still running okay. */
( *pusTaskCheckVariable )++; ( *pusTaskCheckVariable )++;
} }
@ -186,7 +186,7 @@ short sError = pdFALSE;
fAnswer = ( f1 / f2 ) * f3; fAnswer = ( f1 / f2 ) * f3;
/* The variable this task increments to show it is still running is passed in /* The variable this task increments to show it is still running is passed in
as the parameter. */ as the parameter. */
pusTaskCheckVariable = ( uint16_t * ) pvParameters; pusTaskCheckVariable = ( uint16_t * ) pvParameters;
@ -202,8 +202,8 @@ short sError = pdFALSE;
#if configUSE_PREEMPTION == 0 #if configUSE_PREEMPTION == 0
taskYIELD(); taskYIELD();
#endif #endif
/* If the calculation does not match the expected constant, stop the /* If the calculation does not match the expected constant, stop the
increment of the check variable. */ increment of the check variable. */
if( fabs( f4 - fAnswer ) > 0.001F ) if( fabs( f4 - fAnswer ) > 0.001F )
{ {
@ -212,7 +212,7 @@ short sError = pdFALSE;
if( sError == pdFALSE ) if( sError == pdFALSE )
{ {
/* If the calculation has always been correct, increment the check /* If the calculation has always been correct, increment the check
variable so we know variable so we know
this task is still running okay. */ this task is still running okay. */
( *pusTaskCheckVariable )++; ( *pusTaskCheckVariable )++;
@ -233,25 +233,25 @@ const size_t xArraySize = 10;
size_t xPosition; size_t xPosition;
short sError = pdFALSE; short sError = pdFALSE;
/* The variable this task increments to show it is still running is passed in /* The variable this task increments to show it is still running is passed in
as the parameter. */ as the parameter. */
pusTaskCheckVariable = ( uint16_t * ) pvParameters; pusTaskCheckVariable = ( uint16_t * ) pvParameters;
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) ); pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );
/* Keep filling an array, keeping a running total of the values placed in the /* Keep filling an array, keeping a running total of the values placed in the
array. Then run through the array adding up all the values. If the two totals array. Then run through the array adding up all the values. If the two totals
do not match, stop the check variable from incrementing. */ do not match, stop the check variable from incrementing. */
for( ;; ) for( ;; )
{ {
fTotal1 = 0.0F; fTotal1 = 0.0F;
fTotal2 = 0.0F; fTotal2 = 0.0F;
fPosition = 0.0F; fPosition = 0.0F;
for( xPosition = 0; xPosition < xArraySize; xPosition++ ) for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{ {
pfArray[ xPosition ] = fPosition + 5.5F; pfArray[ xPosition ] = fPosition + 5.5F;
fTotal1 += fPosition + 5.5F; fTotal1 += fPosition + 5.5F;
} }
#if configUSE_PREEMPTION == 0 #if configUSE_PREEMPTION == 0
@ -275,7 +275,7 @@ short sError = pdFALSE;
if( sError == pdFALSE ) if( sError == pdFALSE )
{ {
/* If the calculation has always been correct, increment the check /* If the calculation has always been correct, increment the check
variable so we know this task is still running okay. */ variable so we know this task is still running okay. */
( *pusTaskCheckVariable )++; ( *pusTaskCheckVariable )++;
} }
@ -291,14 +291,14 @@ const size_t xArraySize = 10;
size_t xPosition; size_t xPosition;
short sError = pdFALSE; short sError = pdFALSE;
/* The variable this task increments to show it is still running is passed in /* The variable this task increments to show it is still running is passed in
as the parameter. */ as the parameter. */
pusTaskCheckVariable = ( uint16_t * ) pvParameters; pusTaskCheckVariable = ( uint16_t * ) pvParameters;
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) ); pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );
/* Keep filling an array, keeping a running total of the values placed in the /* Keep filling an array, keeping a running total of the values placed in the
array. Then run through the array adding up all the values. If the two totals array. Then run through the array adding up all the values. If the two totals
do not match, stop the check variable from incrementing. */ do not match, stop the check variable from incrementing. */
for( ;; ) for( ;; )
{ {
@ -309,7 +309,7 @@ short sError = pdFALSE;
for( xPosition = 0; xPosition < xArraySize; xPosition++ ) for( xPosition = 0; xPosition < xArraySize; xPosition++ )
{ {
pfArray[ xPosition ] = fPosition * 12.123F; pfArray[ xPosition ] = fPosition * 12.123F;
fTotal1 += fPosition * 12.123F; fTotal1 += fPosition * 12.123F;
} }
#if configUSE_PREEMPTION == 0 #if configUSE_PREEMPTION == 0
@ -333,23 +333,23 @@ short sError = pdFALSE;
if( sError == pdFALSE ) if( sError == pdFALSE )
{ {
/* If the calculation has always been correct, increment the check /* If the calculation has always been correct, increment the check
variable so we know this task is still running okay. */ variable so we know this task is still running okay. */
( *pusTaskCheckVariable )++; ( *pusTaskCheckVariable )++;
} }
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* This is called to check that all the created tasks are still running. */ /* This is called to check that all the created tasks are still running. */
BaseType_t xAreMathsTaskStillRunning( void ) BaseType_t xAreMathsTaskStillRunning( void )
{ {
/* Keep a history of the check variables so we know if they have been incremented /* Keep a history of the check variables so we know if they have been incremented
since the last call. */ since the last call. */
static uint16_t usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; static uint16_t usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };
BaseType_t xReturn = pdTRUE, xTask; BaseType_t xReturn = pdTRUE, xTask;
/* Check the maths tasks are still running by ensuring their check variables /* Check the maths tasks are still running by ensuring their check variables
are still incrementing. */ are still incrementing. */
for( xTask = 0; xTask < mathNUMBER_OF_TASKS; xTask++ ) for( xTask = 0; xTask < mathNUMBER_OF_TASKS; xTask++ )
{ {