+static void prvPendedFunctionCall( void *pvParameter1, uint32_t ulParameter2 )\r
+{\r
+uint32_t *pulCounter = ( uint32_t * ) pvParameter1;\r
+\r
+ /* Increment the paramater to show the pended function has executed. */\r
+ ( *pulCounter )++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvTestTimerCallback( TimerHandle_t xTimer )\r
+{\r
+uint32_t ulTimerID;\r
+\r
+ /* Increment the timer's ID to show the callback has executed. */\r
+ ulTimerID = ( uint32_t ) pvTimerGetTimerID( xTimer );\r
+ ulTimerID++;\r
+ vTimerSetTimerID( xTimer, ( void * ) ulTimerID );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExerciseTimerAPI( void )\r
+{\r
+TimerHandle_t xTimer;\r
+const char * const pcTimerName = "TestTimer";\r
+const TickType_t x3ms = pdMS_TO_TICKS( 3 );\r
+uint32_t ulValueForTesting = 0;\r
+\r
+ xTimer = xTimerCreate( pcTimerName,\r
+ x3ms,\r
+ pdFALSE, /* Created as a one-shot timer. */\r
+ 0,\r
+ prvTestTimerCallback );\r
+ configASSERT( xTimer );\r
+ configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );\r
+ configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );\r
+ configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );\r
+ configASSERT( xTimerGetPeriod( xTimer ) == x3ms );\r
+\r
+ /* Pend a function then wait for it to execute. All it does is increment\r
+ its parameter. */\r
+ xTimerPendFunctionCall( prvPendedFunctionCall, &ulValueForTesting, 0, 0 );\r
+ vTaskDelay( x3ms );\r
+ configASSERT( ulValueForTesting == 1 );\r
+\r
+ /* Timer was created as a one-shot timer. Its callback just increments the\r
+ timer's ID - so set the ID to 0, let the timer run for a number of timeout\r
+ periods, then check the timer has only executed once. */\r
+ vTimerSetTimerID( xTimer, ( void * ) 0 );\r
+ xTimerStart( xTimer, 0 );\r
+ vTaskDelay( 3UL * x3ms );\r
+ configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );\r
+\r
+ /* Now change the timer to be an auto-reload timer and check it executes\r
+ the expected number of times. */\r
+ vTimerSetReloadMode( xTimer, pdTRUE );\r
+ xTimerStart( xTimer, 0 );\r
+ vTaskDelay( 3UL * x3ms );\r
+ configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) > 3UL );\r
+ configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );\r
+\r
+ /* Clean up at the end. */\r
+ xTimerDelete( xTimer, portMAX_DELAY );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvExerciseStreamBufferAPI( void )\r
+{\r
+uint8_t ucBuffer[ 10 ];\r
+BaseType_t x, xRead;\r
+size_t xReturned;\r
+StreamBufferHandle_t xStreamBuffer;\r
+\r
+ /* Just makes API calls to ensure the MPU versions are used. */\r
+\r
+ xStreamBuffer = xStreamBufferCreate( sizeof( ucBuffer ) , 1 );\r
+ configASSERT( xStreamBuffer );\r
+\r
+ for( x = 0; x < ( sizeof( ucBuffer ) * 2 ); x++ )\r
+ {\r
+ /* Write and check the value is written, then read and check the value\r
+ read is expected. */\r
+ xReturned = xStreamBufferSend( xStreamBuffer,\r
+ ( void * ) &x,\r
+ sizeof( x ),\r
+ 0 );\r
+ configASSERT( xReturned == sizeof( x ) );\r
+\r
+ xReturned = xStreamBufferReceive( xStreamBuffer,\r
+ ( void * ) &xRead,\r
+ sizeof( xRead ),\r
+ 0 );\r
+ configASSERT( xReturned == sizeof( xRead ) );\r
+ configASSERT( xRead == x );\r
+ configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE );\r
+ configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE );\r
+ configASSERT( xStreamBufferSpacesAvailable( xStreamBuffer ) == sizeof( ucBuffer ) );\r
+ configASSERT( xStreamBufferBytesAvailable( xStreamBuffer ) == 0 );\r
+ }\r
+\r
+ /* Call the functions that have not been exercised yet before finishing by\r
+ deleting the stream buffer. */\r
+ configASSERT( xStreamBufferSetTriggerLevel( xStreamBuffer, 0 ) == pdTRUE );\r
+ configASSERT( xStreamBufferReset( xStreamBuffer ) == pdPASS );\r
+ vStreamBufferDelete( xStreamBuffer );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r