|
|
|
@ -129,11 +129,11 @@
|
|
|
|
|
extern BaseType_t xRunCodeCoverageTestAdditions( void );
|
|
|
|
|
|
|
|
|
|
/* Task function prototypes. */
|
|
|
|
|
static void prvCheckTask( void *pvParameters );
|
|
|
|
|
static void prvCheckTask( void * pvParameters );
|
|
|
|
|
|
|
|
|
|
/* A task that is created from the idle task to test the functionality of
|
|
|
|
|
eTaskStateGet(). */
|
|
|
|
|
static void prvTestTask( void *pvParameters );
|
|
|
|
|
* eTaskStateGet(). */
|
|
|
|
|
static void prvTestTask( void * pvParameters );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Called from the idle task hook function to demonstrate a few utility
|
|
|
|
@ -151,7 +151,8 @@ static void prvDemonstratePendingFunctionCall( void );
|
|
|
|
|
/*
|
|
|
|
|
* The function that is pended by prvDemonstratePendingFunctionCall().
|
|
|
|
|
*/
|
|
|
|
|
static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );
|
|
|
|
|
static void prvPendedFunction( void * pvParameter1,
|
|
|
|
|
uint32_t ulParameter2 );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* prvDemonstrateTimerQueryFunctions() is called from the idle task hook
|
|
|
|
@ -165,28 +166,28 @@ static void prvTestTimerCallback( TimerHandle_t xTimer );
|
|
|
|
|
/*
|
|
|
|
|
* A task to demonstrate the use of the xQueueSpacesAvailable() function.
|
|
|
|
|
*/
|
|
|
|
|
static void prvDemoQueueSpaceFunctions( void *pvParameters );
|
|
|
|
|
static void prvDemoQueueSpaceFunctions( void * pvParameters );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tasks that ensure indefinite delays are truly indefinite.
|
|
|
|
|
*/
|
|
|
|
|
static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters );
|
|
|
|
|
static void prvPermanentlyBlockingNotificationTask( void *pvParameters );
|
|
|
|
|
static void prvPermanentlyBlockingSemaphoreTask( void * pvParameters );
|
|
|
|
|
static void prvPermanentlyBlockingNotificationTask( void * pvParameters );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The test function and callback function used when exercising the timer AP
|
|
|
|
|
* function that changes the timer's auto-reload mode.
|
|
|
|
|
*/
|
|
|
|
|
static void prvDemonstrateChangingTimerReloadMode( void *pvParameters );
|
|
|
|
|
static void prvDemonstrateChangingTimerReloadMode( void * pvParameters );
|
|
|
|
|
static void prvReloadModeTestTimerCallback( TimerHandle_t xTimer );
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/* The variable into which error messages are latched. */
|
|
|
|
|
static char *pcStatusMessage = "OK: No errors";
|
|
|
|
|
static char * pcStatusMessage = "OK: No errors";
|
|
|
|
|
|
|
|
|
|
/* This semaphore is created purely to test using the vSemaphoreDelete() and
|
|
|
|
|
semaphore tracing API functions. It has no other purpose. */
|
|
|
|
|
* semaphore tracing API functions. It has no other purpose. */
|
|
|
|
|
static SemaphoreHandle_t xMutexToDelete = NULL;
|
|
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
@ -198,7 +199,7 @@ int main_full( void )
|
|
|
|
|
|
|
|
|
|
/* Create the standard demo tasks. */
|
|
|
|
|
vStartTaskNotifyTask();
|
|
|
|
|
// vStartTaskNotifyArrayTask();
|
|
|
|
|
/* vStartTaskNotifyArrayTask(); */
|
|
|
|
|
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
|
|
|
|
|
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
|
|
|
|
|
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
|
|
|
|
@ -223,20 +224,20 @@ int main_full( void )
|
|
|
|
|
vStartStreamBufferInterruptDemo();
|
|
|
|
|
vStartMessageBufferAMPTasks( configMINIMAL_STACK_SIZE );
|
|
|
|
|
|
|
|
|
|
#if( configUSE_QUEUE_SETS == 1 )
|
|
|
|
|
#if ( configUSE_QUEUE_SETS == 1 )
|
|
|
|
|
{
|
|
|
|
|
vStartQueueSetTasks();
|
|
|
|
|
vStartQueueSetPollingTask();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
|
|
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
|
|
|
{
|
|
|
|
|
vStartStaticallyAllocatedTasks();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if( configUSE_PREEMPTION != 0 )
|
|
|
|
|
#if ( configUSE_PREEMPTION != 0 )
|
|
|
|
|
{
|
|
|
|
|
/* Don't expect these tasks to pass when preemption is not used. */
|
|
|
|
|
vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
|
|
|
|
@ -244,29 +245,29 @@ int main_full( void )
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* The suicide tasks must be created last as they need to know how many
|
|
|
|
|
tasks were running prior to their creation. This then allows them to
|
|
|
|
|
ascertain whether or not the correct/expected number of tasks are running at
|
|
|
|
|
any given time. */
|
|
|
|
|
* tasks were running prior to their creation. This then allows them to
|
|
|
|
|
* ascertain whether or not the correct/expected number of tasks are running at
|
|
|
|
|
* any given time. */
|
|
|
|
|
vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
|
|
|
|
|
|
|
|
|
|
/* Create the semaphore that will be deleted in the idle task hook. This
|
|
|
|
|
is done purely to test the use of vSemaphoreDelete(). */
|
|
|
|
|
* is done purely to test the use of vSemaphoreDelete(). */
|
|
|
|
|
xMutexToDelete = xSemaphoreCreateMutex();
|
|
|
|
|
|
|
|
|
|
/* Start the scheduler itself. */
|
|
|
|
|
vTaskStartScheduler();
|
|
|
|
|
|
|
|
|
|
/* Should never get here unless there was not enough heap space to create
|
|
|
|
|
the idle and other system tasks. */
|
|
|
|
|
* the idle and other system tasks. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvCheckTask( void *pvParameters )
|
|
|
|
|
static void prvCheckTask( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
TickType_t xNextWakeTime;
|
|
|
|
|
const TickType_t xCycleFrequency = pdMS_TO_TICKS( 10000UL );
|
|
|
|
|
HeapStats_t xHeapStats;
|
|
|
|
|
TickType_t xNextWakeTime;
|
|
|
|
|
const TickType_t xCycleFrequency = pdMS_TO_TICKS( 10000UL );
|
|
|
|
|
HeapStats_t xHeapStats;
|
|
|
|
|
|
|
|
|
|
/* Just to remove compiler warning. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
@ -274,13 +275,13 @@ HeapStats_t xHeapStats;
|
|
|
|
|
/* Initialise xNextWakeTime - this only needs to be done once. */
|
|
|
|
|
xNextWakeTime = xTaskGetTickCount();
|
|
|
|
|
|
|
|
|
|
for( ;; )
|
|
|
|
|
for( ; ; )
|
|
|
|
|
{
|
|
|
|
|
/* Place this task in the blocked state until it is time to run again. */
|
|
|
|
|
vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
|
|
|
|
|
|
|
|
|
|
/* Check the standard demo tasks are running without error. */
|
|
|
|
|
#if( configUSE_PREEMPTION != 0 )
|
|
|
|
|
#if ( configUSE_PREEMPTION != 0 )
|
|
|
|
|
{
|
|
|
|
|
/* These tasks are only created when preemption is used. */
|
|
|
|
|
if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )
|
|
|
|
@ -302,10 +303,10 @@ HeapStats_t xHeapStats;
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Notification";
|
|
|
|
|
}
|
|
|
|
|
// else if( xAreTaskNotificationArrayTasksStillRunning() != pdTRUE )
|
|
|
|
|
// {
|
|
|
|
|
// pcStatusMessage = "Error: NotificationArray";
|
|
|
|
|
// }
|
|
|
|
|
/* else if( xAreTaskNotificationArrayTasksStillRunning() != pdTRUE ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* pcStatusMessage = "Error: NotificationArray"; */
|
|
|
|
|
/* } */
|
|
|
|
|
else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: IntSem";
|
|
|
|
@ -379,7 +380,7 @@ HeapStats_t xHeapStats;
|
|
|
|
|
pcStatusMessage = "Error: Message buffer AMP";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if( configUSE_QUEUE_SETS == 1 )
|
|
|
|
|
#if ( configUSE_QUEUE_SETS == 1 )
|
|
|
|
|
else if( xAreQueueSetTasksStillRunning() != pdPASS )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Queue set";
|
|
|
|
@ -390,7 +391,7 @@ HeapStats_t xHeapStats;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
|
|
|
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
|
|
|
else if( xAreStaticAllocationTasksStillRunning() != pdPASS )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Static allocation";
|
|
|
|
@ -401,25 +402,25 @@ HeapStats_t xHeapStats;
|
|
|
|
|
pcStatusMessage,
|
|
|
|
|
xTaskGetTickCount() );
|
|
|
|
|
|
|
|
|
|
// Reset the error condition
|
|
|
|
|
/* Reset the error condition */
|
|
|
|
|
pcStatusMessage = "OK: No errors";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvTestTask( void *pvParameters )
|
|
|
|
|
static void prvTestTask( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
const unsigned long ulMSToSleep = 5;
|
|
|
|
|
const unsigned long ulMSToSleep = 5;
|
|
|
|
|
|
|
|
|
|
/* Just to remove compiler warnings. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
|
|
|
|
|
|
/* This task is just used to test the eTaskStateGet() function. It
|
|
|
|
|
does not have anything to do. */
|
|
|
|
|
for( ;; )
|
|
|
|
|
* does not have anything to do. */
|
|
|
|
|
for( ; ; )
|
|
|
|
|
{
|
|
|
|
|
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
|
|
|
|
|
tasks waiting to be terminated by the idle task. */
|
|
|
|
|
* tasks waiting to be terminated by the idle task. */
|
|
|
|
|
struct timespec ts;
|
|
|
|
|
ts.tv_sec = ulMSToSleep / 1000;
|
|
|
|
|
ts.tv_nsec = ulMSToSleep % 1000l * 1000000l;
|
|
|
|
@ -431,38 +432,39 @@ const unsigned long ulMSToSleep = 5;
|
|
|
|
|
/* Called from vApplicationIdleHook(), which is defined in main.c. */
|
|
|
|
|
void vFullDemoIdleFunction( void )
|
|
|
|
|
{
|
|
|
|
|
const unsigned long ulMSToSleep = 15;
|
|
|
|
|
void *pvAllocated;
|
|
|
|
|
const unsigned long ulMSToSleep = 15;
|
|
|
|
|
void * pvAllocated;
|
|
|
|
|
|
|
|
|
|
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
|
|
|
|
|
tasks waiting to be terminated by the idle task. */
|
|
|
|
|
* tasks waiting to be terminated by the idle task. */
|
|
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
|
|
ts.tv_sec = ulMSToSleep / 1000;
|
|
|
|
|
ts.tv_nsec = ulMSToSleep % 1000l * 1000000l;
|
|
|
|
|
nanosleep( &ts, NULL );
|
|
|
|
|
|
|
|
|
|
/* Demonstrate a few utility functions that are not demonstrated by any of
|
|
|
|
|
the standard demo tasks. */
|
|
|
|
|
* the standard demo tasks. */
|
|
|
|
|
prvDemonstrateTaskStateAndHandleGetFunctions();
|
|
|
|
|
|
|
|
|
|
/* Demonstrate the use of xTimerPendFunctionCall(), which is not
|
|
|
|
|
demonstrated by any of the standard demo tasks. */
|
|
|
|
|
* demonstrated by any of the standard demo tasks. */
|
|
|
|
|
prvDemonstratePendingFunctionCall();
|
|
|
|
|
|
|
|
|
|
/* Demonstrate the use of functions that query information about a software
|
|
|
|
|
timer. */
|
|
|
|
|
* timer. */
|
|
|
|
|
prvDemonstrateTimerQueryFunctions();
|
|
|
|
|
|
|
|
|
|
/* If xMutexToDelete has not already been deleted, then delete it now.
|
|
|
|
|
This is done purely to demonstrate the use of, and test, the
|
|
|
|
|
vSemaphoreDelete() macro. Care must be taken not to delete a semaphore
|
|
|
|
|
that has tasks blocked on it. */
|
|
|
|
|
* This is done purely to demonstrate the use of, and test, the
|
|
|
|
|
* vSemaphoreDelete() macro. Care must be taken not to delete a semaphore
|
|
|
|
|
* that has tasks blocked on it. */
|
|
|
|
|
if( xMutexToDelete != NULL )
|
|
|
|
|
{
|
|
|
|
|
/* For test purposes, add the mutex to the registry, then remove it
|
|
|
|
|
again, before it is deleted - checking its name is as expected before
|
|
|
|
|
and after the assertion into the registry and its removal from the
|
|
|
|
|
registry. */
|
|
|
|
|
* again, before it is deleted - checking its name is as expected before
|
|
|
|
|
* and after the assertion into the registry and its removal from the
|
|
|
|
|
* registry. */
|
|
|
|
|
configASSERT( pcQueueGetName( xMutexToDelete ) == NULL );
|
|
|
|
|
vQueueAddToRegistry( xMutexToDelete, "Test_Mutex" );
|
|
|
|
|
configASSERT( strcmp( pcQueueGetName( xMutexToDelete ), "Test_Mutex" ) == 0 );
|
|
|
|
@ -474,13 +476,13 @@ void *pvAllocated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Exercise heap_5 a bit. The malloc failed hook will trap failed
|
|
|
|
|
allocations so there is no need to test here. */
|
|
|
|
|
* allocations so there is no need to test here. */
|
|
|
|
|
pvAllocated = pvPortMalloc( ( rand() % 500 ) + 1 );
|
|
|
|
|
vPortFree( pvAllocated );
|
|
|
|
|
|
|
|
|
|
/* Exit after a fixed time so code coverage results are written to the
|
|
|
|
|
disk. */
|
|
|
|
|
#if( projCOVERAGE_TEST == 1 )
|
|
|
|
|
* disk. */
|
|
|
|
|
#if ( projCOVERAGE_TEST == 1 )
|
|
|
|
|
{
|
|
|
|
|
const TickType_t xMaxRunTime = pdMS_TO_TICKS( 30000UL );
|
|
|
|
|
|
|
|
|
@ -495,18 +497,18 @@ void *pvAllocated;
|
|
|
|
|
vTaskEndScheduler();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#endif /* if ( projCOVERAGE_TEST == 1 ) */
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/* Called by vApplicationTickHook(), which is defined in main.c. */
|
|
|
|
|
void vFullDemoTickHookFunction( void )
|
|
|
|
|
{
|
|
|
|
|
TaskHandle_t xTimerTask;
|
|
|
|
|
TaskHandle_t xTimerTask;
|
|
|
|
|
|
|
|
|
|
/* Call the periodic timer test, which tests the timer API functions that
|
|
|
|
|
can be called from an ISR. */
|
|
|
|
|
#if( configUSE_PREEMPTION != 0 )
|
|
|
|
|
* can be called from an ISR. */
|
|
|
|
|
#if ( configUSE_PREEMPTION != 0 )
|
|
|
|
|
{
|
|
|
|
|
/* Only created when preemption is used. */
|
|
|
|
|
vTimerPeriodicISRTests();
|
|
|
|
@ -516,10 +518,10 @@ TaskHandle_t xTimerTask;
|
|
|
|
|
/* Call the periodic queue overwrite from ISR demo. */
|
|
|
|
|
vQueueOverwritePeriodicISRDemo();
|
|
|
|
|
|
|
|
|
|
#if( configUSE_QUEUE_SETS == 1 ) /* Remove the tests if queue sets are not defined. */
|
|
|
|
|
#if ( configUSE_QUEUE_SETS == 1 ) /* Remove the tests if queue sets are not defined. */
|
|
|
|
|
{
|
|
|
|
|
/* Write to a queue that is in use as part of the queue set demo to
|
|
|
|
|
demonstrate using queue sets from an ISR. */
|
|
|
|
|
* demonstrate using queue sets from an ISR. */
|
|
|
|
|
vQueueSetAccessQueueSetFromISR();
|
|
|
|
|
vQueueSetPollingInterruptAccess();
|
|
|
|
|
}
|
|
|
|
@ -533,14 +535,14 @@ TaskHandle_t xTimerTask;
|
|
|
|
|
|
|
|
|
|
/* Exercise using task notifications from an interrupt. */
|
|
|
|
|
xNotifyTaskFromISR();
|
|
|
|
|
// xNotifyArrayTaskFromISR();
|
|
|
|
|
/* xNotifyArrayTaskFromISR(); */
|
|
|
|
|
|
|
|
|
|
/* Writes to stream buffer byte by byte to test the stream buffer trigger
|
|
|
|
|
level functionality. */
|
|
|
|
|
* level functionality. */
|
|
|
|
|
vPeriodicStreamBufferProcessing();
|
|
|
|
|
|
|
|
|
|
/* Writes a string to a string buffer four bytes at a time to demonstrate
|
|
|
|
|
a stream being sent from an interrupt to a task. */
|
|
|
|
|
* a stream being sent from an interrupt to a task. */
|
|
|
|
|
vBasicStreamBufferSendFromISR();
|
|
|
|
|
|
|
|
|
|
/* For code coverage purposes. */
|
|
|
|
@ -549,10 +551,11 @@ TaskHandle_t xTimerTask;
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 )
|
|
|
|
|
static void prvPendedFunction( void * pvParameter1,
|
|
|
|
|
uint32_t ulParameter2 )
|
|
|
|
|
{
|
|
|
|
|
static intptr_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
|
|
|
|
|
intptr_t ulParameter1;
|
|
|
|
|
static intptr_t ulLastParameter1 = 1000UL, ulLastParameter2 = 0UL;
|
|
|
|
|
intptr_t ulParameter1;
|
|
|
|
|
|
|
|
|
|
ulParameter1 = ( intptr_t ) pvParameter1;
|
|
|
|
|
|
|
|
|
@ -573,17 +576,17 @@ intptr_t ulParameter1;
|
|
|
|
|
static void prvTestTimerCallback( TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
/* This is the callback function for the timer accessed by
|
|
|
|
|
prvDemonstrateTimerQueryFunctions(). The callback does not do anything. */
|
|
|
|
|
* prvDemonstrateTimerQueryFunctions(). The callback does not do anything. */
|
|
|
|
|
( void ) xTimer;
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvDemonstrateTimerQueryFunctions( void )
|
|
|
|
|
{
|
|
|
|
|
static TimerHandle_t xTimer = NULL;
|
|
|
|
|
const char *pcTimerName = "TestTimer";
|
|
|
|
|
volatile TickType_t xExpiryTime;
|
|
|
|
|
const TickType_t xDontBlock = 0;
|
|
|
|
|
static TimerHandle_t xTimer = NULL;
|
|
|
|
|
const char * pcTimerName = "TestTimer";
|
|
|
|
|
volatile TickType_t xExpiryTime;
|
|
|
|
|
const TickType_t xDontBlock = 0;
|
|
|
|
|
|
|
|
|
|
if( xTimer == NULL )
|
|
|
|
|
{
|
|
|
|
@ -592,7 +595,7 @@ const TickType_t xDontBlock = 0;
|
|
|
|
|
if( xTimer != NULL )
|
|
|
|
|
{
|
|
|
|
|
/* Called from the idle task so a block time must not be
|
|
|
|
|
specified. */
|
|
|
|
|
* specified. */
|
|
|
|
|
xTimerStart( xTimer, xDontBlock );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -606,11 +609,11 @@ const TickType_t xDontBlock = 0;
|
|
|
|
|
configASSERT( xTimerGetPeriod( xTimer ) == portMAX_DELAY );
|
|
|
|
|
|
|
|
|
|
/* Demonstrate querying a timer's next expiry time, although nothing is
|
|
|
|
|
done with the returned value. Note if the expiry time is less than the
|
|
|
|
|
maximum tick count then the expiry time has overflowed from the current
|
|
|
|
|
time. In this case the expiry time was set to portMAX_DELAY, so it is
|
|
|
|
|
expected to be less than the current time until the current time has
|
|
|
|
|
itself overflowed. */
|
|
|
|
|
* done with the returned value. Note if the expiry time is less than the
|
|
|
|
|
* maximum tick count then the expiry time has overflowed from the current
|
|
|
|
|
* time. In this case the expiry time was set to portMAX_DELAY, so it is
|
|
|
|
|
* expected to be less than the current time until the current time has
|
|
|
|
|
* itself overflowed. */
|
|
|
|
|
xExpiryTime = xTimerGetExpiryTime( xTimer );
|
|
|
|
|
( void ) xExpiryTime;
|
|
|
|
|
}
|
|
|
|
@ -619,11 +622,12 @@ const TickType_t xDontBlock = 0;
|
|
|
|
|
|
|
|
|
|
static void prvDemonstratePendingFunctionCall( void )
|
|
|
|
|
{
|
|
|
|
|
static intptr_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
|
|
|
|
|
const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
|
|
|
|
|
static intptr_t ulParameter1 = 1000UL, ulParameter2 = 0UL;
|
|
|
|
|
const TickType_t xDontBlock = 0; /* This is called from the idle task so must *not* attempt to block. */
|
|
|
|
|
|
|
|
|
|
/* prvPendedFunction() just expects the parameters to be incremented by one
|
|
|
|
|
each time it is called. */
|
|
|
|
|
* each time it is called. */
|
|
|
|
|
|
|
|
|
|
ulParameter1++;
|
|
|
|
|
ulParameter2++;
|
|
|
|
|
|
|
|
|
@ -634,28 +638,28 @@ const TickType_t xDontBlock = 0; /* This is called from the idle task so must *n
|
|
|
|
|
|
|
|
|
|
static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
|
|
|
|
|
{
|
|
|
|
|
TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
|
|
|
|
|
char *pcTaskName;
|
|
|
|
|
static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
|
|
|
|
|
TaskHandle_t xTestTask;
|
|
|
|
|
TaskStatus_t xTaskInfo;
|
|
|
|
|
extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
TaskHandle_t xIdleTaskHandle, xTimerTaskHandle;
|
|
|
|
|
char * pcTaskName;
|
|
|
|
|
static portBASE_TYPE xPerformedOneShotTests = pdFALSE;
|
|
|
|
|
TaskHandle_t xTestTask;
|
|
|
|
|
TaskStatus_t xTaskInfo;
|
|
|
|
|
extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
|
|
|
|
|
/* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and
|
|
|
|
|
xTaskGetIdleTaskHandle() functions. Also try using the function that sets
|
|
|
|
|
the task number. */
|
|
|
|
|
* xTaskGetIdleTaskHandle() functions. Also try using the function that sets
|
|
|
|
|
* the task number. */
|
|
|
|
|
xIdleTaskHandle = xTaskGetIdleTaskHandle();
|
|
|
|
|
xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle();
|
|
|
|
|
|
|
|
|
|
/* This is the idle hook, so the current task handle should equal the
|
|
|
|
|
returned idle task handle. */
|
|
|
|
|
* returned idle task handle. */
|
|
|
|
|
if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Returned idle task handle was incorrect";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check the same handle is obtained using the idle task's name. First try
|
|
|
|
|
with the wrong name, then the right name. */
|
|
|
|
|
* with the wrong name, then the right name. */
|
|
|
|
|
if( xTaskGetHandle( "Idle" ) == xIdleTaskHandle )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Returned handle for name Idle was incorrect";
|
|
|
|
@ -668,6 +672,7 @@ extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
|
|
|
|
|
/* Check the timer task handle was returned correctly. */
|
|
|
|
|
pcTaskName = pcTaskGetName( xTimerTaskHandle );
|
|
|
|
|
|
|
|
|
|
if( strcmp( pcTaskName, "Tmr Svc" ) != 0 )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Returned timer task handle was incorrect";
|
|
|
|
@ -707,8 +712,8 @@ extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Other tests that should only be performed once follow. The test task
|
|
|
|
|
is not created on each iteration because to do so would cause the death
|
|
|
|
|
task to report an error (too many tasks running). */
|
|
|
|
|
* is not created on each iteration because to do so would cause the death
|
|
|
|
|
* task to report an error (too many tasks running). */
|
|
|
|
|
if( xPerformedOneShotTests == pdFALSE )
|
|
|
|
|
{
|
|
|
|
|
/* Don't run this part of the test again. */
|
|
|
|
@ -725,6 +730,7 @@ extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
|
|
|
|
|
/* Now suspend the test task and check its state is reported correctly. */
|
|
|
|
|
vTaskSuspend( xTestTask );
|
|
|
|
|
|
|
|
|
|
if( eTaskStateGet( xTestTask ) != eSuspended )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Returned test task state was incorrect 2";
|
|
|
|
@ -732,6 +738,7 @@ extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
|
|
|
|
|
/* Now delete the task and check its state is reported correctly. */
|
|
|
|
|
vTaskDelete( xTestTask );
|
|
|
|
|
|
|
|
|
|
if( eTaskStateGet( xTestTask ) != eDeleted )
|
|
|
|
|
{
|
|
|
|
|
pcStatusMessage = "Error: Returned test task state was incorrect 3";
|
|
|
|
@ -741,21 +748,21 @@ extern StackType_t uxTimerTaskStack[];
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvDemoQueueSpaceFunctions( void *pvParameters )
|
|
|
|
|
static void prvDemoQueueSpaceFunctions( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
QueueHandle_t xQueue = NULL;
|
|
|
|
|
const unsigned portBASE_TYPE uxQueueLength = 10;
|
|
|
|
|
unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
QueueHandle_t xQueue = NULL;
|
|
|
|
|
const unsigned portBASE_TYPE uxQueueLength = 10;
|
|
|
|
|
unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
|
|
|
|
|
/* Remove compiler warnings. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
|
|
|
|
|
|
/* Create the queue that will be used. Nothing is actually going to be
|
|
|
|
|
sent or received so the queue item size is set to 0. */
|
|
|
|
|
* sent or received so the queue item size is set to 0. */
|
|
|
|
|
xQueue = xQueueCreate( uxQueueLength, 0 );
|
|
|
|
|
configASSERT( xQueue );
|
|
|
|
|
|
|
|
|
|
for( ;; )
|
|
|
|
|
for( ; ; )
|
|
|
|
|
{
|
|
|
|
|
for( x = 0; x < uxQueueLength; x++ )
|
|
|
|
|
{
|
|
|
|
@ -763,11 +770,11 @@ unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
uxReturn = uxQueueMessagesWaiting( xQueue );
|
|
|
|
|
|
|
|
|
|
/* Check the number of messages being reported as being available
|
|
|
|
|
is as expected, and force an assert if not. */
|
|
|
|
|
* is as expected, and force an assert if not. */
|
|
|
|
|
if( uxReturn != x )
|
|
|
|
|
{
|
|
|
|
|
/* xQueue cannot be NULL so this is deliberately causing an
|
|
|
|
|
assert to be triggered as there is an error. */
|
|
|
|
|
* assert to be triggered as there is an error. */
|
|
|
|
|
configASSERT( xQueue == NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -775,11 +782,11 @@ unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
uxReturn = uxQueueSpacesAvailable( xQueue );
|
|
|
|
|
|
|
|
|
|
/* Check the number of spaces being reported as being available
|
|
|
|
|
is as expected, and force an assert if not. */
|
|
|
|
|
* is as expected, and force an assert if not. */
|
|
|
|
|
if( uxReturn != ( uxQueueLength - x ) )
|
|
|
|
|
{
|
|
|
|
|
/* xQueue cannot be NULL so this is deliberately causing an
|
|
|
|
|
assert to be triggered as there is an error. */
|
|
|
|
|
* assert to be triggered as there is an error. */
|
|
|
|
|
configASSERT( xQueue == NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -789,6 +796,7 @@ unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
|
|
|
|
|
/* Perform the same check while the queue is full. */
|
|
|
|
|
uxReturn = uxQueueMessagesWaiting( xQueue );
|
|
|
|
|
|
|
|
|
|
if( uxReturn != uxQueueLength )
|
|
|
|
|
{
|
|
|
|
|
configASSERT( xQueue == NULL );
|
|
|
|
@ -804,19 +812,19 @@ unsigned portBASE_TYPE uxReturn, x;
|
|
|
|
|
/* The queue is full, start again. */
|
|
|
|
|
xQueueReset( xQueue );
|
|
|
|
|
|
|
|
|
|
#if( configUSE_PREEMPTION == 0 )
|
|
|
|
|
#if ( configUSE_PREEMPTION == 0 )
|
|
|
|
|
taskYIELD();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvPermanentlyBlockingSemaphoreTask( void *pvParameters )
|
|
|
|
|
static void prvPermanentlyBlockingSemaphoreTask( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
SemaphoreHandle_t xSemaphore;
|
|
|
|
|
SemaphoreHandle_t xSemaphore;
|
|
|
|
|
|
|
|
|
|
/* Prevent compiler warning about unused parameter in the case that
|
|
|
|
|
configASSERT() is not defined. */
|
|
|
|
|
* configASSERT() is not defined. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
|
|
|
|
|
|
/* This task should block on a semaphore, and never return. */
|
|
|
|
@ -826,23 +834,23 @@ SemaphoreHandle_t xSemaphore;
|
|
|
|
|
xSemaphoreTake( xSemaphore, portMAX_DELAY );
|
|
|
|
|
|
|
|
|
|
/* The above xSemaphoreTake() call should never return, force an assert if
|
|
|
|
|
it does. */
|
|
|
|
|
* it does. */
|
|
|
|
|
configASSERT( pvParameters != NULL );
|
|
|
|
|
vTaskDelete( NULL );
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvPermanentlyBlockingNotificationTask( void *pvParameters )
|
|
|
|
|
static void prvPermanentlyBlockingNotificationTask( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
/* Prevent compiler warning about unused parameter in the case that
|
|
|
|
|
configASSERT() is not defined. */
|
|
|
|
|
* configASSERT() is not defined. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
|
|
|
|
|
|
/* This task should block on a task notification, and never return. */
|
|
|
|
|
ulTaskNotifyTake( pdTRUE, portMAX_DELAY );
|
|
|
|
|
|
|
|
|
|
/* The above ulTaskNotifyTake() call should never return, force an assert
|
|
|
|
|
if it does. */
|
|
|
|
|
* if it does. */
|
|
|
|
|
configASSERT( pvParameters != NULL );
|
|
|
|
|
vTaskDelete( NULL );
|
|
|
|
|
}
|
|
|
|
@ -850,7 +858,7 @@ static void prvPermanentlyBlockingNotificationTask( void *pvParameters )
|
|
|
|
|
|
|
|
|
|
static void prvReloadModeTestTimerCallback( TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
intptr_t ulTimerID;
|
|
|
|
|
intptr_t ulTimerID;
|
|
|
|
|
|
|
|
|
|
/* Increment the timer's ID to show the callback has executed. */
|
|
|
|
|
ulTimerID = ( intptr_t ) pvTimerGetTimerID( xTimer );
|
|
|
|
@ -859,11 +867,11 @@ intptr_t ulTimerID;
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
static void prvDemonstrateChangingTimerReloadMode( void *pvParameters )
|
|
|
|
|
static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
|
|
|
|
{
|
|
|
|
|
TimerHandle_t xTimer;
|
|
|
|
|
const char * const pcTimerName = "TestTimer";
|
|
|
|
|
const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
|
|
|
|
TimerHandle_t xTimer;
|
|
|
|
|
const char * const pcTimerName = "TestTimer";
|
|
|
|
|
const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
|
|
|
|
|
|
|
|
|
/* Avoid compiler warnings about unused parameter. */
|
|
|
|
|
( void ) pvParameters;
|
|
|
|
@ -880,15 +888,15 @@ const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
|
|
|
|
configASSERT( xTimerGetPeriod( xTimer ) == x100ms );
|
|
|
|
|
|
|
|
|
|
/* Timer was created as a one-shot timer. Its callback just increments the
|
|
|
|
|
timer's ID - so set the ID to 0, let the timer run for a number of timeout
|
|
|
|
|
periods, then check the timer has only executed once. */
|
|
|
|
|
* timer's ID - so set the ID to 0, let the timer run for a number of timeout
|
|
|
|
|
* periods, then check the timer has only executed once. */
|
|
|
|
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
|
|
|
|
xTimerStart( xTimer, portMAX_DELAY );
|
|
|
|
|
vTaskDelay( 3UL * x100ms );
|
|
|
|
|
configASSERT( ( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
|
|
|
|
|
|
|
|
|
/* Now change the timer to be an auto-reload timer and check it executes
|
|
|
|
|
the expected number of times. */
|
|
|
|
|
* the expected number of times. */
|
|
|
|
|
vTimerSetReloadMode( xTimer, pdTRUE );
|
|
|
|
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
|
|
|
|
xTimerStart( xTimer, 0 );
|
|
|
|
@ -897,7 +905,7 @@ const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
|
|
|
|
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
|
|
|
|
|
|
|
|
|
/* Now change the timer back to be a one-shot timer and check it only
|
|
|
|
|
executes once. */
|
|
|
|
|
* executes once. */
|
|
|
|
|
vTimerSetReloadMode( xTimer, pdFALSE );
|
|
|
|
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
|
|
|
|
xTimerStart( xTimer, 0 );
|
|
|
|
|