IntQueue.c File Reference

#include <string.h>
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#include "IntQueue.h"
#include "IntQueueTimer.h"

Go to the source code of this file.

Defines

#define intqFIRST_INTERRUPT   ( ( unsigned portBASE_TYPE ) 4 )
#define intqHIGH_PRIORITY_TASK1   ( ( unsigned portBASE_TYPE ) 1 )
#define intqHIGH_PRIORITY_TASK2   ( ( unsigned portBASE_TYPE ) 2 )
#define intqHIGHER_PRIORITY   ( configMAX_PRIORITIES - 2 )
#define intqLOW_PRIORITY_TASK   ( ( unsigned portBASE_TYPE ) 3 )
#define intqLOWER_PRIORITY   ( tskIDLE_PRIORITY )
#define intqMIN_ACCEPTABLE_TASK_COUNT   ( 5 )
#define intqNUM_VALUES_TO_LOG   ( 200 )
#define intqONE_TICK_DELAY   ( 1 )
#define intqQUEUE_LENGTH   ( ( unsigned portBASE_TYPE ) 10 )
#define intqSECOND_INTERRUPT   ( ( unsigned portBASE_TYPE ) 5 )
#define intqSHORT_DELAY   ( 75 )
#define intqVALUE_OVERRUN   ( 50 )
#define timerNORMALLY_EMPTY_RX()
#define timerNORMALLY_EMPTY_TX()
#define timerNORMALLY_FULL_RX()
#define timerNORMALLY_FULL_TX()

Functions

static void prv1stHigherPriorityNormallyFullTask (void *pvParameters)
static void prv2ndHigherPriorityNormallyFullTask (void *pvParameters)
static void prvHigherPriorityNormallyEmptyTask (void *pvParameters)
static void prvLowerPriorityNormallyEmptyTask (void *pvParameters)
static void prvLowerPriorityNormallyFullTask (void *pvParameters)
static void prvQueueAccessLogError (unsigned portBASE_TYPE uxLine)
static void prvRecordValue_NormallyEmpty (unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource)
static void prvRecordValue_NormallyFull (unsigned portBASE_TYPE uxValue, unsigned portBASE_TYPE uxSource)
void vStartInterruptQueueTasks (void)
portBASE_TYPE xAreIntQueueTasksStillRunning (void)
portBASE_TYPE xFirstTimerHandler (void)
portBASE_TYPE xSecondTimerHandler (void)

Variables

static unsigned portCHAR ucNormallyEmptyReceivedValues [intqNUM_VALUES_TO_LOG] = { 0 }
static unsigned portCHAR ucNormallyFullReceivedValues [intqNUM_VALUES_TO_LOG] = { 0 }
static unsigned portBASE_TYPE uxHighPriorityLoops1 = 0
static unsigned portBASE_TYPE uxHighPriorityLoops2 = 0
static unsigned portBASE_TYPE uxLowPriorityLoops1 = 0
static unsigned portBASE_TYPE uxLowPriorityLoops2 = 0
volatile unsigned portBASE_TYPE uxValueForNormallyEmptyQueue = 0
volatile unsigned portBASE_TYPE uxValueForNormallyFullQueue = 0
static unsigned portBASE_TYPE xErrorLine = ( unsigned portBASE_TYPE ) 0
static portBASE_TYPE xErrorStatus = pdPASS
xTaskHandle xHighPriorityNormallyEmptyTask1
xTaskHandle xHighPriorityNormallyEmptyTask2
xTaskHandle xHighPriorityNormallyFullTask1
xTaskHandle xHighPriorityNormallyFullTask2
static xQueueHandle xNormallyEmptyQueue
static xQueueHandle xNormallyFullQueue
static portBASE_TYPE xWasSuspended = pdFALSE


Define Documentation

#define intqFIRST_INTERRUPT   ( ( unsigned portBASE_TYPE ) 4 )

Definition at line 107 of file IntQueue.c.

#define intqHIGH_PRIORITY_TASK1   ( ( unsigned portBASE_TYPE ) 1 )

Definition at line 104 of file IntQueue.c.

Referenced by prvHigherPriorityNormallyEmptyTask(), and vStartInterruptQueueTasks().

#define intqHIGH_PRIORITY_TASK2   ( ( unsigned portBASE_TYPE ) 2 )

Definition at line 105 of file IntQueue.c.

Referenced by prvHigherPriorityNormallyEmptyTask(), and vStartInterruptQueueTasks().

#define intqHIGHER_PRIORITY   ( configMAX_PRIORITIES - 2 )

#define intqLOW_PRIORITY_TASK   ( ( unsigned portBASE_TYPE ) 3 )

#define intqLOWER_PRIORITY   ( tskIDLE_PRIORITY )

#define intqMIN_ACCEPTABLE_TASK_COUNT   ( 5 )

Definition at line 113 of file IntQueue.c.

Referenced by prvHigherPriorityNormallyEmptyTask().

#define intqNUM_VALUES_TO_LOG   ( 200 )

#define intqONE_TICK_DELAY   ( 1 )

#define intqQUEUE_LENGTH   ( ( unsigned portBASE_TYPE ) 10 )

Definition at line 109 of file IntQueue.c.

Referenced by vStartInterruptQueueTasks().

#define intqSECOND_INTERRUPT   ( ( unsigned portBASE_TYPE ) 5 )

Definition at line 108 of file IntQueue.c.

#define intqSHORT_DELAY   ( 75 )

#define intqVALUE_OVERRUN   ( 50 )

 
#define timerNORMALLY_EMPTY_RX (  ) 

Value:

if( xQueueReceiveFromISR( xNormallyEmptyQueue, &uxRxedValue, &xHigherPriorityTaskWoken ) != pdPASS )    \
    {                                                                                                       \
        prvQueueAccessLogError( __LINE__ );                                                                 \
    }                                                                                                       \
    else                                                                                                    \
    {                                                                                                       \
        prvRecordValue_NormallyEmpty( uxRxedValue, intqSECOND_INTERRUPT );                                  \
    }

Definition at line 145 of file IntQueue.c.

Referenced by xSecondTimerHandler().

 
#define timerNORMALLY_EMPTY_TX (  ) 

Value:

if( xQueueIsQueueFullFromISR( xNormallyEmptyQueue ) != pdTRUE )                                                         \
    {                                                                                                                       \
    unsigned portBASE_TYPE uxSavedInterruptStatus;                                                                          \
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();                                                         \
        {                                                                                                                   \
            uxValueForNormallyEmptyQueue++;                                                                                 \
            xQueueSendFromISR( xNormallyEmptyQueue, ( void * ) &uxValueForNormallyEmptyQueue, &xHigherPriorityTaskWoken );  \
        }                                                                                                                   \
        portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );                                                        \
    }                                                                                                                       \

Definition at line 117 of file IntQueue.c.

Referenced by xFirstTimerHandler(), and xSecondTimerHandler().

 
#define timerNORMALLY_FULL_RX (  ) 

Value:

if( xQueueReceiveFromISR( xNormallyFullQueue, &uxRxedValue, &xHigherPriorityTaskWoken ) == pdPASS )     \
    {                                                                                                       \
        prvRecordValue_NormallyFull( uxRxedValue, intqSECOND_INTERRUPT );                                   \
    }                                                                                                       \

Definition at line 157 of file IntQueue.c.

Referenced by xFirstTimerHandler(), and xSecondTimerHandler().

 
#define timerNORMALLY_FULL_TX (  ) 

Value:

if( xQueueIsQueueFullFromISR( xNormallyFullQueue ) != pdTRUE )                                                          \
    {                                                                                                                       \
    unsigned portBASE_TYPE uxSavedInterruptStatus;                                                                          \
        uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();                                                         \
        {                                                                                                                   \
            uxValueForNormallyFullQueue++;                                                                                  \
            xQueueSendFromISR( xNormallyFullQueue, ( void * ) &uxValueForNormallyFullQueue, &xHigherPriorityTaskWoken );    \
        }                                                                                                                   \
        portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );                                                        \
    }                                                                                                                       \

Definition at line 131 of file IntQueue.c.

Referenced by xSecondTimerHandler().


Function Documentation

static void prv1stHigherPriorityNormallyFullTask ( void *  pvParameters  )  [static]

Definition at line 441 of file IntQueue.c.

References intqNUM_VALUES_TO_LOG, intqSHORT_DELAY, intqVALUE_OVERRUN, pdPASS, pdTRUE, portBASE_TYPE, portENTER_CRITICAL, portEXIT_CRITICAL, prvQueueAccessLogError(), taskYIELD, ucNormallyFullReceivedValues, uxHighPriorityLoops2, uxValueForNormallyFullQueue, vTaskDelay(), vTaskResume(), vTaskSuspend(), xHighPriorityNormallyFullTask2, xNormallyFullQueue, xQueueSend, and xWasSuspended.

Referenced by vStartInterruptQueueTasks().

00442 {
00443 unsigned portBASE_TYPE uxValueToTx, ux;
00444 portBASE_TYPE xQueueStatus;
00445 
00446     /* The parameters are not being used so avoid compiler warnings. */
00447     ( void ) pvParameters;
00448 
00449     /* Make sure the queue starts full or near full.  >> 1 as there are two
00450     high priority tasks. */
00451     for( ux = 0; ux < ( intqQUEUE_LENGTH >> 1 ); ux++ )
00452     {
00453         portENTER_CRITICAL();
00454         {
00455             uxValueForNormallyFullQueue++;
00456             uxValueToTx = uxValueForNormallyFullQueue;
00457         }
00458         portEXIT_CRITICAL();
00459 
00460         xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY );
00461     }
00462 
00463     for( ;; )
00464     {
00465         portENTER_CRITICAL();
00466         {
00467             uxValueForNormallyFullQueue++;
00468             uxValueToTx = uxValueForNormallyFullQueue;
00469         }
00470         portEXIT_CRITICAL();
00471 
00472         if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY ) ) != pdPASS )
00473         {
00474             /* intqHIGH_PRIORITY_TASK2 is never suspended so we would not
00475             expect it to ever time out. */
00476             prvQueueAccessLogError( __LINE__ );
00477         }
00478 
00479         /* Allow the other task running this code to run. */
00480         taskYIELD();
00481 
00482         /* Have all the expected values been sent to the queue? */
00483         if( uxValueToTx > ( intqNUM_VALUES_TO_LOG + intqVALUE_OVERRUN ) )
00484         {
00485             /* Make sure the other high priority task completes its send of
00486             any values below intqNUM_VALUE_TO_LOG. */
00487             vTaskDelay( intqSHORT_DELAY );
00488 
00489             vTaskSuspend( xHighPriorityNormallyFullTask2 );
00490 
00491             if( xWasSuspended == pdTRUE )
00492             {
00493                 /* We would have expected the other high priority task to have
00494                 set this back to false by now. */
00495                 prvQueueAccessLogError( __LINE__ );
00496             }
00497 
00498             /* Set the suspended flag so an error is not logged if the other
00499             task recognises a time out when it is unsuspended. */
00500             xWasSuspended = pdTRUE;
00501 
00502             /* Start at 1 as we expect position 0 to be unused. */
00503             for( ux = 1; ux < intqNUM_VALUES_TO_LOG; ux++ )
00504             {
00505                 if( ucNormallyFullReceivedValues[ ux ] == 0 )
00506                 {
00507                     /* A value was missing. */
00508                     prvQueueAccessLogError( __LINE__ );
00509                 }
00510             }
00511 
00512             /* Reset the array ready for the next cycle. */
00513             memset( ucNormallyFullReceivedValues, 0x00, sizeof( ucNormallyFullReceivedValues ) );
00514 
00515             uxHighPriorityLoops2++;
00516             uxValueForNormallyFullQueue = 0;
00517 
00518             /* Suspend ourselves, allowing the lower priority task to
00519             actually receive something from the queue.  Until now it
00520             will have been prevented from doing so by the higher
00521             priority tasks.  The lower priority task will resume us
00522             if it receives something.  We will then resume the other
00523             higher priority task. */
00524             vTaskSuspend( NULL );
00525             vTaskResume( xHighPriorityNormallyFullTask2 );
00526         }
00527     }
00528 }

static void prv2ndHigherPriorityNormallyFullTask ( void *  pvParameters  )  [static]

Definition at line 531 of file IntQueue.c.

References intqSHORT_DELAY, pdFALSE, pdPASS, pdTRUE, portBASE_TYPE, portENTER_CRITICAL, portEXIT_CRITICAL, prvQueueAccessLogError(), taskYIELD, uxValueForNormallyFullQueue, xNormallyFullQueue, xQueueSend, and xWasSuspended.

Referenced by vStartInterruptQueueTasks().

00532 {
00533 unsigned portBASE_TYPE uxValueToTx, ux;
00534 portBASE_TYPE xQueueStatus;
00535 
00536     /* The parameters are not being used so avoid compiler warnings. */
00537     ( void ) pvParameters;
00538 
00539     /* Make sure the queue starts full or near full.  >> 1 as there are two
00540     high priority tasks. */
00541     for( ux = 0; ux < ( intqQUEUE_LENGTH >> 1 ); ux++ )
00542     {
00543         portENTER_CRITICAL();
00544         {
00545             uxValueForNormallyFullQueue++;
00546             uxValueToTx = uxValueForNormallyFullQueue;
00547         }
00548         portEXIT_CRITICAL();
00549 
00550         xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY );
00551     }
00552 
00553     for( ;; )
00554     {
00555         portENTER_CRITICAL();
00556         {
00557             uxValueForNormallyFullQueue++;
00558             uxValueToTx = uxValueForNormallyFullQueue;
00559         }
00560         portEXIT_CRITICAL();
00561 
00562         if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxValueToTx, intqSHORT_DELAY ) ) != pdPASS )
00563         {
00564             if( xWasSuspended != pdTRUE )
00565             {
00566                 /* It is ok to time out if the task has been suspended. */
00567                 prvQueueAccessLogError( __LINE__ );
00568             }
00569         }
00570 
00571         xWasSuspended = pdFALSE;
00572 
00573         taskYIELD();
00574     }
00575 }

static void prvHigherPriorityNormallyEmptyTask ( void *  pvParameters  )  [static]

Definition at line 279 of file IntQueue.c.

References intqHIGH_PRIORITY_TASK1, intqHIGH_PRIORITY_TASK2, intqMIN_ACCEPTABLE_TASK_COUNT, intqNUM_VALUES_TO_LOG, intqSHORT_DELAY, intqVALUE_OVERRUN, pdPASS, portBASE_TYPE, prvQueueAccessLogError(), prvRecordValue_NormallyEmpty(), taskYIELD, ucNormallyEmptyReceivedValues, uxHighPriorityLoops1, uxValueForNormallyEmptyQueue, vTaskResume(), vTaskSuspend(), xHighPriorityNormallyEmptyTask2, xNormallyEmptyQueue, and xQueueReceive.

Referenced by vStartInterruptQueueTasks().

00280 {
00281 unsigned portBASE_TYPE uxRxed, ux, uxTask1, uxTask2, uxErrorCount1 = 0, uxErrorCount2 = 0;
00282 
00283     /* The timer should not be started until after the scheduler has started.
00284     More than one task is running this code so we check the parameter value
00285     to determine which task should start the timer. */
00286     if( ( unsigned portBASE_TYPE ) pvParameters == intqHIGH_PRIORITY_TASK1 )
00287     {
00288         vInitialiseTimerForIntQueueTest();
00289     }
00290 
00291     for( ;; )
00292     {
00293         /* Block waiting to receive a value from the normally empty queue.
00294         Interrupts will write to the queue so we should receive a value. */
00295         if( xQueueReceive( xNormallyEmptyQueue, &uxRxed, intqSHORT_DELAY ) != pdPASS )
00296         {
00297             prvQueueAccessLogError( __LINE__ );
00298         }
00299         else
00300         {
00301             /* Note which value was received so we can check all expected
00302             values are received and no values are duplicated. */
00303             prvRecordValue_NormallyEmpty( uxRxed, ( unsigned portBASE_TYPE ) pvParameters );
00304         }
00305 
00306         /* Ensure the other task running this code gets a chance to execute. */
00307         taskYIELD();
00308 
00309         if( ( unsigned portBASE_TYPE ) pvParameters == intqHIGH_PRIORITY_TASK1 )
00310         {
00311             /* Have we received all the expected values? */
00312             if( uxValueForNormallyEmptyQueue > ( intqNUM_VALUES_TO_LOG + intqVALUE_OVERRUN ) )
00313             {
00314                 vTaskSuspend( xHighPriorityNormallyEmptyTask2 );
00315 
00316                 uxTask1 = 0;
00317                 uxTask2 = 0;
00318 
00319                 /* Loop through the array, checking that both tasks have
00320                 placed values into the array, and that no values are missing.
00321                 Start at 1 as we expect position 0 to be unused. */
00322                 for( ux = 1; ux < intqNUM_VALUES_TO_LOG; ux++ )
00323                 {
00324                     if( ucNormallyEmptyReceivedValues[ ux ] == 0 )
00325                     {
00326                         /* A value is missing. */
00327                         prvQueueAccessLogError( __LINE__ );
00328                     }
00329                     else
00330                     {
00331                         if( ucNormallyEmptyReceivedValues[ ux ] == intqHIGH_PRIORITY_TASK1 )
00332                         {
00333                             /* Value was placed into the array by task 1. */
00334                             uxTask1++;
00335                         }
00336                         else if( ucNormallyEmptyReceivedValues[ ux ] == intqHIGH_PRIORITY_TASK2 )
00337                         {
00338                             /* Value was placed into the array by task 2. */
00339                             uxTask2++;
00340                         }
00341                     }
00342                 }
00343 
00344                 if( uxTask1 < intqMIN_ACCEPTABLE_TASK_COUNT )
00345                 {
00346                     /* Only task 2 seemed to log any values. */
00347                     uxErrorCount1++;
00348                     if( uxErrorCount1 > 2 )
00349                     {
00350                         prvQueueAccessLogError( __LINE__ );
00351                     }
00352                 }
00353                 else
00354                 {
00355                     uxErrorCount1 = 0;
00356                 }
00357 
00358                 if( uxTask2 < intqMIN_ACCEPTABLE_TASK_COUNT  )
00359                 {
00360                     /* Only task 1 seemed to log any values. */
00361                     uxErrorCount2++;
00362                     if( uxErrorCount2 > 2 )
00363                     {
00364                         prvQueueAccessLogError( __LINE__ );
00365                     }
00366                 }
00367                 else
00368                 {
00369                     uxErrorCount2 = 0;
00370                 }
00371 
00372                 /* Clear the array again, ready to start a new cycle. */
00373                 memset( ucNormallyEmptyReceivedValues, 0x00, sizeof( ucNormallyEmptyReceivedValues ) );
00374 
00375                 uxHighPriorityLoops1++;
00376                 uxValueForNormallyEmptyQueue = 0;
00377 
00378                 /* Suspend ourselves, allowing the lower priority task to
00379                 actually receive something from the queue.  Until now it
00380                 will have been prevented from doing so by the higher
00381                 priority tasks.  The lower priority task will resume us
00382                 if it receives something.  We will then resume the other
00383                 higher priority task. */
00384                 vTaskSuspend( NULL );
00385                 vTaskResume( xHighPriorityNormallyEmptyTask2 );
00386             }
00387         }
00388     }
00389 }

static void prvLowerPriorityNormallyEmptyTask ( void *  pvParameters  )  [static]

Definition at line 392 of file IntQueue.c.

References errQUEUE_EMPTY, intqHIGHER_PRIORITY, intqLOW_PRIORITY_TASK, intqLOWER_PRIORITY, intqONE_TICK_DELAY, pdFALSE, pdPASS, portBASE_TYPE, portENTER_CRITICAL, portEXIT_CRITICAL, portMAX_DELAY, prvQueueAccessLogError(), prvRecordValue_NormallyEmpty(), uxLowPriorityLoops1, uxValueForNormallyEmptyQueue, vTaskPrioritySet(), vTaskResume(), xHighPriorityNormallyEmptyTask1, xNormallyEmptyQueue, xQueueReceive, xQueueSend, and xTaskIsTaskSuspended().

Referenced by vStartInterruptQueueTasks().

00393 {
00394 unsigned portBASE_TYPE uxValue, uxRxed;
00395 portBASE_TYPE xQueueStatus;
00396 
00397     /* The parameters are not being used so avoid compiler warnings. */
00398     ( void ) pvParameters;
00399 
00400     for( ;; )
00401     {
00402         if( ( xQueueStatus = xQueueReceive( xNormallyEmptyQueue, &uxRxed, intqONE_TICK_DELAY ) ) != errQUEUE_EMPTY )
00403         {
00404             /* We should only obtain a value when the high priority task is
00405             suspended. */
00406             if( xTaskIsTaskSuspended( xHighPriorityNormallyEmptyTask1 ) == pdFALSE )
00407             {
00408                 prvQueueAccessLogError( __LINE__ );
00409             }
00410 
00411             prvRecordValue_NormallyEmpty( uxRxed, intqLOW_PRIORITY_TASK );
00412 
00413             /* Wake the higher priority task again. */
00414             vTaskResume( xHighPriorityNormallyEmptyTask1 );
00415             uxLowPriorityLoops1++;
00416         }
00417         else
00418         {
00419             /* Raise our priority while we send so we can preempt the higher
00420             priority task, and ensure we get the Tx value into the queue. */
00421             vTaskPrioritySet( NULL, intqHIGHER_PRIORITY + 1 );
00422 
00423             portENTER_CRITICAL();
00424             {
00425                 uxValueForNormallyEmptyQueue++;
00426                 uxValue = uxValueForNormallyEmptyQueue;
00427             }
00428             portEXIT_CRITICAL();
00429 
00430             if( xQueueSend( xNormallyEmptyQueue, &uxValue, portMAX_DELAY ) != pdPASS )
00431             {
00432                 prvQueueAccessLogError( __LINE__ );
00433             }
00434 
00435             vTaskPrioritySet( NULL, intqLOWER_PRIORITY );
00436         }
00437     }
00438 }

static void prvLowerPriorityNormallyFullTask ( void *  pvParameters  )  [static]

Definition at line 578 of file IntQueue.c.

References errQUEUE_FULL, intqHIGHER_PRIORITY, intqLOW_PRIORITY_TASK, intqLOWER_PRIORITY, intqONE_TICK_DELAY, pdFALSE, pdPASS, portBASE_TYPE, portMAX_DELAY, prvQueueAccessLogError(), prvRecordValue_NormallyFull(), uxLowPriorityLoops2, vTaskPrioritySet(), vTaskResume(), xHighPriorityNormallyFullTask1, xNormallyFullQueue, xQueueReceive, xQueueSend, and xTaskIsTaskSuspended().

Referenced by vStartInterruptQueueTasks().

00579 {
00580 unsigned portBASE_TYPE uxValue, uxTxed = 9999;
00581 portBASE_TYPE xQueueStatus;
00582 
00583     /* The parameters are not being used so avoid compiler warnings. */
00584     ( void ) pvParameters;
00585 
00586     for( ;; )
00587     {
00588         if( ( xQueueStatus = xQueueSend( xNormallyFullQueue, &uxTxed, intqONE_TICK_DELAY ) ) != errQUEUE_FULL )
00589         {
00590             /* We would only expect to succeed when the higher priority task
00591             is suspended. */
00592             if( xTaskIsTaskSuspended( xHighPriorityNormallyFullTask1 ) == pdFALSE )
00593             {
00594                 prvQueueAccessLogError( __LINE__ );
00595             }
00596 
00597             vTaskResume( xHighPriorityNormallyFullTask1 );
00598             uxLowPriorityLoops2++;
00599         }
00600         else
00601         {
00602             /* Raise our priority while we receive so we can preempt the higher
00603             priority task, and ensure we get the value from the queue. */
00604             vTaskPrioritySet( NULL, intqHIGHER_PRIORITY + 1 );
00605 
00606             if( xQueueReceive( xNormallyFullQueue, &uxValue, portMAX_DELAY ) != pdPASS )
00607             {
00608                 prvQueueAccessLogError( __LINE__ );
00609             }
00610             else
00611             {
00612                 prvRecordValue_NormallyFull( uxValue, intqLOW_PRIORITY_TASK );
00613             }
00614 
00615             vTaskPrioritySet( NULL, intqLOWER_PRIORITY );
00616         }
00617     }
00618 }

static void prvQueueAccessLogError ( unsigned portBASE_TYPE  uxLine  )  [static]

static void prvRecordValue_NormallyEmpty ( unsigned portBASE_TYPE  uxValue,
unsigned portBASE_TYPE  uxSource 
) [static]

Definition at line 254 of file IntQueue.c.

References intqNUM_VALUES_TO_LOG, prvQueueAccessLogError(), and ucNormallyEmptyReceivedValues.

Referenced by prvHigherPriorityNormallyEmptyTask(), and prvLowerPriorityNormallyEmptyTask().

00255 {
00256     if( uxValue < intqNUM_VALUES_TO_LOG )
00257     {
00258         /* We don't expect to receive the same value twice, so if the value
00259         has already been marked as received an error has occurred. */
00260         if( ucNormallyEmptyReceivedValues[ uxValue ] != 0x00 )
00261         {
00262             prvQueueAccessLogError( __LINE__ );
00263         }
00264 
00265         /* Log that this value has been received. */
00266         ucNormallyEmptyReceivedValues[ uxValue ] = uxSource;
00267     }
00268 }

static void prvRecordValue_NormallyFull ( unsigned portBASE_TYPE  uxValue,
unsigned portBASE_TYPE  uxSource 
) [static]

Definition at line 237 of file IntQueue.c.

References intqNUM_VALUES_TO_LOG, prvQueueAccessLogError(), and ucNormallyFullReceivedValues.

Referenced by prvLowerPriorityNormallyFullTask().

00238 {
00239     if( uxValue < intqNUM_VALUES_TO_LOG )
00240     {
00241         /* We don't expect to receive the same value twice, so if the value
00242         has already been marked as received an error has occurred. */
00243         if( ucNormallyFullReceivedValues[ uxValue ] != 0x00 )
00244         {
00245             prvQueueAccessLogError( __LINE__ );
00246         }
00247 
00248         /* Log that this value has been received. */
00249         ucNormallyFullReceivedValues[ uxValue ] = uxSource;
00250     }
00251 }

void vStartInterruptQueueTasks ( void   ) 

Definition at line 211 of file IntQueue.c.

References configMINIMAL_STACK_SIZE, intqHIGH_PRIORITY_TASK1, intqHIGH_PRIORITY_TASK2, intqHIGHER_PRIORITY, intqLOWER_PRIORITY, intqQUEUE_LENGTH, portBASE_TYPE, portCHAR, prv1stHigherPriorityNormallyFullTask(), prv2ndHigherPriorityNormallyFullTask(), prvHigherPriorityNormallyEmptyTask(), prvLowerPriorityNormallyEmptyTask(), prvLowerPriorityNormallyFullTask(), vQueueAddToRegistry, xHighPriorityNormallyEmptyTask1, xHighPriorityNormallyEmptyTask2, xHighPriorityNormallyFullTask1, xHighPriorityNormallyFullTask2, xNormallyEmptyQueue, xNormallyFullQueue, xQueueCreate(), and xTaskCreate.

00212 {
00213     /* Start the test tasks. */
00214     xTaskCreate( prvHigherPriorityNormallyEmptyTask, ( signed portCHAR * ) "H1QRx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIORITY_TASK1, intqHIGHER_PRIORITY, &xHighPriorityNormallyEmptyTask1 );
00215     xTaskCreate( prvHigherPriorityNormallyEmptyTask, ( signed portCHAR * ) "H2QRx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIORITY_TASK2, intqHIGHER_PRIORITY, &xHighPriorityNormallyEmptyTask2 );
00216     xTaskCreate( prvLowerPriorityNormallyEmptyTask, ( signed portCHAR * ) "LQRx", configMINIMAL_STACK_SIZE, NULL, intqLOWER_PRIORITY, NULL );
00217     xTaskCreate( prv1stHigherPriorityNormallyFullTask, ( signed portCHAR * ) "H1QTx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIORITY_TASK1, intqHIGHER_PRIORITY, &xHighPriorityNormallyFullTask1 );
00218     xTaskCreate( prv2ndHigherPriorityNormallyFullTask, ( signed portCHAR * ) "H1QTx", configMINIMAL_STACK_SIZE, ( void * ) intqHIGH_PRIORITY_TASK2, intqHIGHER_PRIORITY, &xHighPriorityNormallyFullTask2 );
00219     xTaskCreate( prvLowerPriorityNormallyFullTask, ( signed portCHAR * ) "LQRx", configMINIMAL_STACK_SIZE, NULL, intqLOWER_PRIORITY, NULL );
00220 
00221     /* Create the queues that are accessed by multiple tasks and multiple
00222     interrupts. */
00223     xNormallyFullQueue = xQueueCreate( intqQUEUE_LENGTH, ( unsigned portBASE_TYPE ) sizeof( unsigned portBASE_TYPE ) );
00224     xNormallyEmptyQueue = xQueueCreate( intqQUEUE_LENGTH, ( unsigned portBASE_TYPE ) sizeof( unsigned portBASE_TYPE ) );
00225 
00226     /* vQueueAddToRegistry() adds the queue to the queue registry, if one is
00227     in use.  The queue registry is provided as a means for kernel aware
00228     debuggers to locate queues and has no purpose if a kernel aware debugger
00229     is not being used.  The call to vQueueAddToRegistry() will be removed
00230     by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is
00231     defined to be less than 1. */
00232     vQueueAddToRegistry( xNormallyFullQueue, ( signed portCHAR * ) "NormallyFull" );
00233     vQueueAddToRegistry( xNormallyEmptyQueue, ( signed portCHAR * ) "NormallyEmpty" );
00234 }

portBASE_TYPE xAreIntQueueTasksStillRunning ( void   ) 

Definition at line 681 of file IntQueue.c.

References portBASE_TYPE, prvQueueAccessLogError(), uxHighPriorityLoops1, uxHighPriorityLoops2, uxLowPriorityLoops1, uxLowPriorityLoops2, and xErrorStatus.

00682 {
00683 static unsigned portBASE_TYPE uxLastHighPriorityLoops1 = 0, uxLastHighPriorityLoops2 = 0, uxLastLowPriorityLoops1 = 0, uxLastLowPriorityLoops2 = 0;
00684 
00685     /* xErrorStatus can be set outside of this function.  This function just
00686     checks that all the tasks are still cycling. */
00687 
00688     if( uxHighPriorityLoops1 == uxLastHighPriorityLoops1 )
00689     {
00690         /* The high priority 1 task has stalled. */
00691         prvQueueAccessLogError( __LINE__ );
00692     }
00693 
00694     uxLastHighPriorityLoops1 = uxHighPriorityLoops1;
00695 
00696     if( uxHighPriorityLoops2 == uxLastHighPriorityLoops2 )
00697     {
00698         /* The high priority 2 task has stalled. */
00699         prvQueueAccessLogError( __LINE__ );
00700     }
00701 
00702     uxLastHighPriorityLoops2 = uxHighPriorityLoops2;
00703 
00704     if( uxLowPriorityLoops1 == uxLastLowPriorityLoops1 )
00705     {
00706         /* The low priority 1 task has stalled. */
00707         prvQueueAccessLogError( __LINE__ );
00708     }
00709 
00710     uxLastLowPriorityLoops1 = uxLowPriorityLoops1;
00711 
00712     if( uxLowPriorityLoops2 == uxLastLowPriorityLoops2 )
00713     {
00714         /* The low priority 2 task has stalled. */
00715         prvQueueAccessLogError( __LINE__ );
00716     }
00717 
00718     uxLastLowPriorityLoops2 = uxLowPriorityLoops2;
00719 
00720     return xErrorStatus;
00721 }

portBASE_TYPE xFirstTimerHandler ( void   ) 

Definition at line 621 of file IntQueue.c.

References pdFALSE, portBASE_TYPE, timerNORMALLY_EMPTY_TX, and timerNORMALLY_FULL_RX.

00622 {
00623 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE, uxRxedValue;
00624 static unsigned portBASE_TYPE uxNextOperation = 0;
00625 
00626     /* Called from a timer interrupt.  Perform various read and write
00627     accesses on the queues. */
00628 
00629     uxNextOperation++;
00630 
00631     if( uxNextOperation & ( unsigned portBASE_TYPE ) 0x01 )
00632     {
00633         timerNORMALLY_EMPTY_TX();
00634         timerNORMALLY_EMPTY_TX();
00635         timerNORMALLY_EMPTY_TX();
00636     }
00637     else
00638     {
00639         timerNORMALLY_FULL_RX();
00640         timerNORMALLY_FULL_RX();
00641         timerNORMALLY_FULL_RX();
00642     }
00643 
00644     return xHigherPriorityTaskWoken;
00645 }

portBASE_TYPE xSecondTimerHandler ( void   ) 

Definition at line 648 of file IntQueue.c.

References pdFALSE, portBASE_TYPE, timerNORMALLY_EMPTY_RX, timerNORMALLY_EMPTY_TX, timerNORMALLY_FULL_RX, and timerNORMALLY_FULL_TX.

00649 {
00650 unsigned portBASE_TYPE uxRxedValue;
00651 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
00652 static unsigned portBASE_TYPE uxNextOperation = 0;
00653 
00654     /* Called from a timer interrupt.  Perform various read and write
00655     accesses on the queues. */
00656 
00657     uxNextOperation++;
00658 
00659     if( uxNextOperation & ( unsigned portBASE_TYPE ) 0x01 )
00660     {
00661         timerNORMALLY_EMPTY_TX();
00662         timerNORMALLY_EMPTY_TX();
00663 
00664         timerNORMALLY_EMPTY_RX();
00665         timerNORMALLY_EMPTY_RX();
00666     }
00667     else
00668     {
00669         timerNORMALLY_FULL_RX();
00670         timerNORMALLY_FULL_TX();
00671         timerNORMALLY_FULL_TX();
00672         timerNORMALLY_FULL_TX();
00673         timerNORMALLY_FULL_TX();
00674     }
00675 
00676     return xHigherPriorityTaskWoken;
00677 }


Variable Documentation

unsigned portCHAR ucNormallyEmptyReceivedValues[intqNUM_VALUES_TO_LOG] = { 0 } [static]

Definition at line 191 of file IntQueue.c.

Referenced by prvHigherPriorityNormallyEmptyTask(), and prvRecordValue_NormallyEmpty().

unsigned portCHAR ucNormallyFullReceivedValues[intqNUM_VALUES_TO_LOG] = { 0 } [static]

unsigned portBASE_TYPE uxHighPriorityLoops1 = 0 [static]

unsigned portBASE_TYPE uxHighPriorityLoops2 = 0 [static]

unsigned portBASE_TYPE uxLowPriorityLoops1 = 0 [static]

Definition at line 170 of file IntQueue.c.

Referenced by prvLowerPriorityNormallyEmptyTask(), and xAreIntQueueTasksStillRunning().

unsigned portBASE_TYPE uxLowPriorityLoops2 = 0 [static]

Definition at line 170 of file IntQueue.c.

Referenced by prvLowerPriorityNormallyFullTask(), and xAreIntQueueTasksStillRunning().

volatile unsigned portBASE_TYPE uxValueForNormallyEmptyQueue = 0

volatile unsigned portBASE_TYPE uxValueForNormallyFullQueue = 0

unsigned portBASE_TYPE xErrorLine = ( unsigned portBASE_TYPE ) 0 [static]

Definition at line 175 of file IntQueue.c.

Referenced by prvQueueAccessLogError().

portBASE_TYPE xErrorStatus = pdPASS [static]

Definition at line 174 of file IntQueue.c.

Referenced by prvQueueAccessLogError(), and xAreIntQueueTasksStillRunning().

Definition at line 185 of file IntQueue.c.

Referenced by prvLowerPriorityNormallyEmptyTask(), and vStartInterruptQueueTasks().

Definition at line 185 of file IntQueue.c.

Referenced by prvHigherPriorityNormallyEmptyTask(), and vStartInterruptQueueTasks().

Definition at line 185 of file IntQueue.c.

Referenced by prvLowerPriorityNormallyFullTask(), and vStartInterruptQueueTasks().

Definition at line 185 of file IntQueue.c.

Referenced by prv1stHigherPriorityNormallyFullTask(), and vStartInterruptQueueTasks().

portBASE_TYPE xWasSuspended = pdFALSE [static]


Generated on Thu Dec 17 20:02:01 2009 for AVR32 UC3 - FreeRTOS Real Time Kernel by  doxygen 1.5.5