mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Cosmetic changes only.
This commit is contained in:
parent
a99cd32208
commit
2e89c13c1c
|
@ -218,11 +218,11 @@ UBaseType_t uxLEDToFlash;
|
|||
/* Co-routines MUST start with a call to crSTART. */
|
||||
crSTART( xHandle );
|
||||
( void ) uxIndex;
|
||||
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
/* 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 )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
* 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 ensure the character received was that expected, then sends the number
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This demo relies on each 'hook' co-routine to execute between each
|
||||
* 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
|
||||
* This demo relies on each 'hook' co-routine to execute between each
|
||||
* 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
|
||||
* slower targets simply due to timing.
|
||||
*/
|
||||
|
||||
|
@ -101,7 +101,7 @@
|
|||
/* The number of 'hook' co-routines that are to be created. */
|
||||
#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. */
|
||||
#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
|
||||
* 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.
|
||||
*/
|
||||
void vApplicationTickHook( void );
|
||||
|
@ -152,12 +152,12 @@ UBaseType_t uxIndex, uxValueToPost = 0;
|
|||
|
||||
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. */
|
||||
xHookRxQueues[ 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. */
|
||||
xQueueSend( xHookRxQueues[ uxIndex ], &uxValueToPost, hookNO_BLOCK_TIME );
|
||||
|
||||
|
@ -184,13 +184,13 @@ BaseType_t xIndex, xCoRoutineWoken;
|
|||
xCoRoutineWoken = pdFALSE;
|
||||
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. */
|
||||
xCoRoutineErrorDetected = pdTRUE;
|
||||
}
|
||||
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. */
|
||||
if( uxReceivedNumber != uxNumberToPost )
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ BaseType_t xIndex, xCoRoutineWoken;
|
|||
{
|
||||
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. */
|
||||
xCoRoutineErrorDetected = pdTRUE;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ BaseType_t xResult;
|
|||
crQUEUE_SEND( xHandle, xHookRxQueues[ uxIndex ], &( uxReceivedValue[ uxIndex ] ), hookNO_BLOCK_TIME, &xResult );
|
||||
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. */
|
||||
xCoRoutineErrorDetected = pdTRUE;
|
||||
}
|
||||
|
|
|
@ -69,13 +69,13 @@
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
@ -143,7 +143,7 @@ UBaseType_t uxLED;
|
|||
delay is only half the total period. */
|
||||
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(). */
|
||||
xLastFlashTime = xTaskGetTickCount();
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
/*
|
||||
* 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
|
||||
* context switch mechanism.
|
||||
*/
|
||||
|
@ -151,8 +151,8 @@ volatile BaseType_t *pxTaskHasExecuted;
|
|||
lValue *= intgCONST3;
|
||||
lValue /= intgCONST4;
|
||||
|
||||
/* If the calculation is found to be incorrect we stop setting the
|
||||
TaskHasExecuted variable so the check task can see an error has
|
||||
/* If the calculation is found to be incorrect we stop setting the
|
||||
TaskHasExecuted variable so the check task can see an error has
|
||||
occurred. */
|
||||
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;
|
||||
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. */
|
||||
for( sTask = 0; sTask < intgNUMBER_OF_TASKS; sTask++ )
|
||||
{
|
||||
|
|
|
@ -139,12 +139,12 @@ const TickType_t xBlockTime = ( TickType_t ) 100;
|
|||
if( pxFirstSemaphoreParameters != NULL )
|
||||
{
|
||||
/* Create the semaphore used by the first two tasks. */
|
||||
pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
|
||||
pxFirstSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
|
||||
|
||||
if( pxFirstSemaphoreParameters->xSemaphore != NULL )
|
||||
{
|
||||
xSemaphoreGive( pxFirstSemaphoreParameters->xSemaphore );
|
||||
|
||||
|
||||
/* Create the variable which is to be shared by the first two tasks. */
|
||||
pxFirstSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );
|
||||
|
||||
|
@ -173,12 +173,12 @@ const TickType_t xBlockTime = ( TickType_t ) 100;
|
|||
pxSecondSemaphoreParameters = ( xSemaphoreParameters * ) pvPortMalloc( sizeof( xSemaphoreParameters ) );
|
||||
if( pxSecondSemaphoreParameters != NULL )
|
||||
{
|
||||
pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
|
||||
pxSecondSemaphoreParameters->xSemaphore = xSemaphoreCreateBinary();
|
||||
|
||||
if( pxSecondSemaphoreParameters->xSemaphore != NULL )
|
||||
{
|
||||
xSemaphoreGive( pxSecondSemaphoreParameters->xSemaphore );
|
||||
|
||||
|
||||
pxSecondSemaphoreParameters->pulSharedVariable = ( uint32_t * ) pvPortMalloc( sizeof( uint32_t ) );
|
||||
*( pxSecondSemaphoreParameters->pulSharedVariable ) = semtstBLOCKING_EXPECTED_VALUE;
|
||||
pxSecondSemaphoreParameters->xBlockTime = xBlockTime / portTICK_PERIOD_MS;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* 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 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
|
||||
* 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
|
||||
* 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
|
||||
* 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 producing an unexpected result could be a symptom of a corruption in
|
||||
* the context of a task.
|
||||
*/
|
||||
|
||||
|
@ -93,14 +93,14 @@
|
|||
#define mathSTACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#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. */
|
||||
static portTASK_FUNCTION_PROTO( vCompetingMathTask1, pvParameters );
|
||||
static portTASK_FUNCTION_PROTO( vCompetingMathTask2, pvParameters );
|
||||
static portTASK_FUNCTION_PROTO( vCompetingMathTask3, 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
|
||||
stop incrementing its check variable. */
|
||||
static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };
|
||||
|
@ -133,7 +133,7 @@ short sError = pdFALSE;
|
|||
|
||||
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. */
|
||||
pusTaskCheckVariable = ( uint16_t * ) pvParameters;
|
||||
|
||||
|
@ -150,7 +150,7 @@ short sError = pdFALSE;
|
|||
taskYIELD();
|
||||
#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. */
|
||||
if( fabs( f4 - fAnswer ) > 0.001F )
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ short 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. */
|
||||
( *pusTaskCheckVariable )++;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ short sError = pdFALSE;
|
|||
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. */
|
||||
pusTaskCheckVariable = ( uint16_t * ) pvParameters;
|
||||
|
||||
|
@ -202,8 +202,8 @@ short sError = pdFALSE;
|
|||
#if configUSE_PREEMPTION == 0
|
||||
taskYIELD();
|
||||
#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. */
|
||||
if( fabs( f4 - fAnswer ) > 0.001F )
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ short 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. */
|
||||
( *pusTaskCheckVariable )++;
|
||||
|
@ -233,25 +233,25 @@ const size_t xArraySize = 10;
|
|||
size_t xPosition;
|
||||
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. */
|
||||
pusTaskCheckVariable = ( uint16_t * ) pvParameters;
|
||||
|
||||
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );
|
||||
|
||||
/* 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
|
||||
/* 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
|
||||
do not match, stop the check variable from incrementing. */
|
||||
for( ;; )
|
||||
{
|
||||
fTotal1 = 0.0F;
|
||||
fTotal2 = 0.0F;
|
||||
fPosition = 0.0F;
|
||||
|
||||
|
||||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||
{
|
||||
pfArray[ xPosition ] = fPosition + 5.5F;
|
||||
fTotal1 += fPosition + 5.5F;
|
||||
fTotal1 += fPosition + 5.5F;
|
||||
}
|
||||
|
||||
#if configUSE_PREEMPTION == 0
|
||||
|
@ -275,7 +275,7 @@ short 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. */
|
||||
( *pusTaskCheckVariable )++;
|
||||
}
|
||||
|
@ -291,14 +291,14 @@ const size_t xArraySize = 10;
|
|||
size_t xPosition;
|
||||
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. */
|
||||
pusTaskCheckVariable = ( uint16_t * ) pvParameters;
|
||||
|
||||
pfArray = ( float * ) pvPortMalloc( xArraySize * sizeof( float ) );
|
||||
|
||||
/* 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
|
||||
/* 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
|
||||
do not match, stop the check variable from incrementing. */
|
||||
for( ;; )
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ short sError = pdFALSE;
|
|||
for( xPosition = 0; xPosition < xArraySize; xPosition++ )
|
||||
{
|
||||
pfArray[ xPosition ] = fPosition * 12.123F;
|
||||
fTotal1 += fPosition * 12.123F;
|
||||
fTotal1 += fPosition * 12.123F;
|
||||
}
|
||||
|
||||
#if configUSE_PREEMPTION == 0
|
||||
|
@ -333,23 +333,23 @@ short 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. */
|
||||
( *pusTaskCheckVariable )++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* This is called to check that all the created tasks are still running. */
|
||||
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. */
|
||||
static uint16_t usLastTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 };
|
||||
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. */
|
||||
for( xTask = 0; xTask < mathNUMBER_OF_TASKS; xTask++ )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue