static void prvISROneShotTimerCallback( TimerHandle_t pxExpiredTimer );\r
\r
/* The test functions used by the timer test task. These manipulate the auto\r
-reload and one shot timers in various ways, then delay, then inspect the timers\r
+reload and one-shot timers in various ways, then delay, then inspect the timers\r
to ensure they have behaved as expected. */\r
static void prvTest1_CreateTimersWithoutSchedulerRunning( void );\r
static void prvTest2_CheckTaskAndTimersInitialState( void );\r
detect a stalled task - a test that is no longer running. */\r
static volatile uint32_t ulLoopCounter = 0;\r
\r
-/* A set of auto reload timers - each of which use the same callback function.\r
+/* A set of auto-reload timers - each of which use the same callback function.\r
The callback function uses the timer ID to index into, and then increment, a\r
-counter in the ucAutoReloadTimerCounters[] array. The auto reload timers\r
+counter in the ucAutoReloadTimerCounters[] array. The auto-reload timers\r
referenced from xAutoReloadTimers[] are used by the prvTimerTestTask task. */\r
static TimerHandle_t xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
static uint8_t ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
\r
-/* The one shot timer is configured to use a callback function that increments\r
+/* The one-shot timer is configured to use a callback function that increments\r
ucOneShotTimerCounter each time it gets called. */\r
static TimerHandle_t xOneShotTimer = NULL;\r
static uint8_t ucOneShotTimerCounter = ( uint8_t ) 0;\r
static TimerHandle_t xISRAutoReloadTimer = NULL;\r
static uint8_t ucISRAutoReloadTimerCounter = ( uint8_t ) 0;\r
\r
-/* The ISR one shot timer is controlled from the tick hook to exercise the timer\r
+/* The ISR one-shot timer is controlled from the tick hook to exercise the timer\r
API functions that can be used from an ISR. It is configured to increment\r
ucISRReloadTimerCounter each time its callback function is executed. */\r
static TimerHandle_t xISROneShotTimer = NULL;\r
{\r
( void ) pvParameters;\r
\r
- /* Create a one-shot timer for use later on in this test. */\r
+ /* Create a one-shot timer for use later on in this test. For test purposes it\r
+ is created as an auto-reload timer then converted to a one-shot timer. */\r
xOneShotTimer = xTimerCreate( "Oneshot Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */\r
tmrdemoONE_SHOT_TIMER_PERIOD, /* The period for the timer. */\r
- pdFALSE, /* Don't auto-reload - hence a one shot timer. */\r
+ pdFALSE, /* Autorealod is false, so created as a one-shot timer. */\r
( void * ) 0, /* The timer identifier. Initialise to 0, then increment each time it is called. */\r
prvOneShotTimerCallback ); /* The callback to be called when the timer expires. */\r
\r
configASSERT( xTestStatus );\r
}\r
\r
+ /* Purely for test coverage purposes - change and query the reload mode to\r
+ auto-reload then back to one-shot. */\r
+\r
+ /* Change timer to auto-reload. */\r
+ vTimerSetReloadMode( xOneShotTimer, pdTRUE );\r
+\r
+ /* Timer should now be auto-reload. */\r
+ configASSERT( uxTimerGetReloadMode( xOneShotTimer ) == pdTRUE );\r
+\r
+ /* Change timer to one-shot, which is what is needed for this test. */\r
+ vTimerSetReloadMode( xOneShotTimer, pdFALSE );\r
+\r
+ /* Check change to one-shot was successful. */\r
+ configASSERT( uxTimerGetReloadMode( xOneShotTimer ) == pdFALSE );\r
\r
/* Ensure all the timers are in their expected initial state. This\r
depends on the timer service task having a higher priority than this task. */\r
\r
for( ;; )\r
{\r
- /* Check the auto reload timers expire at the expected/correct rates. */\r
+ /* Check the auto-reload timers expire at the expected/correct rates. */\r
prvTest3_CheckAutoReloadExpireRates();\r
\r
- /* Check the auto reload timers can be stopped correctly, and correctly\r
+ /* Check the auto-reload timers can be stopped correctly, and correctly\r
report their state. */\r
prvTest4_CheckAutoReloadTimersCanBeStopped();\r
\r
- /* Check the one shot timer only calls its callback once after it has been\r
+ /* Check the one-shot timer only calls its callback once after it has been\r
started, and that it reports its state correctly. */\r
prvTest5_CheckBasicOneShotTimerBehaviour();\r
\r
xAutoReloadTimers[ xTimer ] = xTimerCreate( "FR Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */\r
( ( xTimer + ( TickType_t ) 1 ) * xBasePeriod ),/* The period for the timer. The plus 1 ensures a period of zero is not specified. */\r
pdTRUE, /* Auto-reload is set to true. */\r
- ( void * ) xTimer, /* An identifier for the timer as all the auto reload timers use the same callback. */\r
+ ( void * ) xTimer, /* An identifier for the timer as all the auto-reload timers use the same callback. */\r
prvAutoReloadTimerCallback ); /* The callback to be called when the timer expires. */\r
\r
if( xAutoReloadTimers[ xTimer ] == NULL )\r
xAutoReloadTimers[ configTIMER_QUEUE_LENGTH ] = xTimerCreate( "FR Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */\r
( configTIMER_QUEUE_LENGTH * xBasePeriod ), /* The period for the timer. */\r
pdTRUE, /* Auto-reload is set to true. */\r
- ( void * ) xTimer, /* An identifier for the timer as all the auto reload timers use the same callback. */\r
+ ( void * ) xTimer, /* An identifier for the timer as all the auto-reload timers use the same callback. */\r
prvAutoReloadTimerCallback ); /* The callback executed when the timer expires. */\r
\r
if( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH ] == NULL )\r
API functions that can be called from an ISR. */\r
xISRAutoReloadTimer = xTimerCreate( "ISR AR", /* The text name given to the timer. */\r
0xffff, /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */\r
- pdTRUE, /* This is an auto reload timer. */\r
+ pdTRUE, /* This is an auto-reload timer. */\r
( void * ) NULL, /* The identifier is not required. */\r
prvISRAutoReloadTimerCallback ); /* The callback that is executed when the timer expires. */\r
\r
xISROneShotTimer = xTimerCreate( "ISR OS", /* The text name given to the timer. */\r
0xffff, /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */\r
- pdFALSE, /* This is a one shot timer. */\r
+ pdFALSE, /* This is a one-shot timer. */\r
( void * ) NULL, /* The identifier is not required. */\r
prvISROneShotTimerCallback ); /* The callback that is executed when the timer expires. */\r
\r
/* Ensure all the timers are in their expected initial state. This depends\r
on the timer service task having a higher priority than this task.\r
\r
- auto reload timers 0 to ( configTIMER_QUEUE_LENGTH - 1 ) should now be active,\r
- and auto reload timer configTIMER_QUEUE_LENGTH should not yet be active (it\r
+ auto-reload timers 0 to ( configTIMER_QUEUE_LENGTH - 1 ) should now be active,\r
+ and auto-reload timer configTIMER_QUEUE_LENGTH should not yet be active (it\r
could not be started prior to the scheduler being started when it was\r
created). */\r
for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;\r
UBaseType_t uxOriginalPriority;\r
\r
- /* Check the auto reload timers expire at the expected rates. Do this at a\r
+ /* Check the auto-reload timers expire at the expected rates. Do this at a\r
high priority for maximum accuracy. This is ok as most of the time is spent\r
in the Blocked state. */\r
uxOriginalPriority = uxTaskPriorityGet( NULL );\r
vTaskPrioritySet( NULL, ( configMAX_PRIORITIES - 1 ) );\r
\r
/* Delaying for configTIMER_QUEUE_LENGTH * xBasePeriod ticks should allow\r
- all the auto reload timers to expire at least once. */\r
+ all the auto-reload timers to expire at least once. */\r
xBlockPeriod = ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\r
vTaskDelay( xBlockPeriod );\r
\r
- /* Check that all the auto reload timers have called their callback\r
+ /* Check that all the auto-reload timers have called their callback\r
function the expected number of times. */\r
for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
{\r
{\r
uint8_t ucTimer;\r
\r
- /* Check the auto reload timers can be stopped correctly, and correctly\r
+ /* Check the auto-reload timers can be stopped correctly, and correctly\r
report their state. */\r
\r
/* Stop all the active timers. */\r
\r
static void prvTest5_CheckBasicOneShotTimerBehaviour( void )\r
{\r
- /* Check the one shot timer only calls its callback once after it has been\r
+ /* Check the one-shot timer only calls its callback once after it has been\r
started, and that it reports its state correctly. */\r
\r
- /* The one shot timer should not be active yet. */\r
+ /* The one-shot timer should not be active yet. */\r
if( xTimerIsTimerActive( xOneShotTimer ) != pdFALSE )\r
{\r
xTestStatus = pdFAIL;\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Start the one shot timer and check that it reports its state correctly. */\r
+ /* Start the one-shot timer and check that it reports its state correctly. */\r
xTimerStart( xOneShotTimer, tmrdemoDONT_BLOCK );\r
if( xTimerIsTimerActive( xOneShotTimer ) == pdFALSE )\r
{\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Delay for three times as long as the one shot timer period, then check\r
+ /* Delay for three times as long as the one-shot timer period, then check\r
to ensure it has only called its callback once, and is now not in the\r
active state. */\r
vTaskDelay( tmrdemoONE_SHOT_TIMER_PERIOD * ( TickType_t ) 3 );\r
}\r
else\r
{\r
- /* Reset the one shot timer callback count. */\r
+ /* Reset the one-shot timer callback count. */\r
ucOneShotTimerCounter = ( uint8_t ) 0;\r
}\r
\r
\r
/* Check timer reset behaviour. */\r
\r
- /* Restart the one shot timer and check it reports its status correctly. */\r
+ /* Restart the one-shot timer and check it reports its status correctly. */\r
xTimerStart( xOneShotTimer, tmrdemoDONT_BLOCK );\r
if( xTimerIsTimerActive( xOneShotTimer ) == pdFALSE )\r
{\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Restart one of the auto reload timers and check that it reports its\r
+ /* Restart one of the auto-reload timers and check that it reports its\r
status correctly. */\r
xTimerStart( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ], tmrdemoDONT_BLOCK );\r
if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) == pdFALSE )\r
\r
for( ucTimer = 0; ucTimer < tmrdemoNUM_TIMER_RESETS; ucTimer++ )\r
{\r
- /* Delay for half as long as the one shot timer period, then reset it.\r
+ /* Delay for half as long as the one-shot timer period, then reset it.\r
It should never expire while this is done, so its callback count should\r
never increment. */\r
vTaskDelay( tmrdemoONE_SHOT_TIMER_PERIOD / 2 );\r
configASSERT( xTestStatus );\r
}\r
\r
- /* The one shot timer should no longer be active, while the auto reload\r
+ /* The one-shot timer should no longer be active, while the auto-reload\r
timer should still be active. */\r
if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) == pdFALSE )\r
{\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Stop the auto reload timer again. */\r
+ /* Stop the auto-reload timer again. */\r
xTimerStop( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ], tmrdemoDONT_BLOCK );\r
\r
if( xTimerIsTimerActive( xAutoReloadTimers[ configTIMER_QUEUE_LENGTH - 1 ] ) != pdFALSE )\r
}\r
else if( uxTick == ( xBasePeriod + xMargin ) )\r
{\r
- /* Both timers should now have expired once. The auto reload timer will\r
- still be active, but the one shot timer should now have stopped. */\r
+ /* Both timers should now have expired once. The auto-reload timer will\r
+ still be active, but the one-shot timer should now have stopped. */\r
if( ( ucISRAutoReloadTimerCounter != 1 ) || ( ucISROneShotTimerCounter != 1 ) )\r
{\r
xTestStatus = pdFAIL;\r
}\r
else if( uxTick == ( ( 2 * xBasePeriod ) - xMargin ) )\r
{\r
- /* The auto reload timer will still be active, but the one shot timer\r
+ /* The auto-reload timer will still be active, but the one-shot timer\r
should now have stopped - however, at this time neither of the timers\r
should have expired again since the last test. */\r
if( ( ucISRAutoReloadTimerCounter != 1 ) || ( ucISROneShotTimerCounter != 1 ) )\r
}\r
else if( uxTick == ( ( 2 * xBasePeriod ) + xMargin ) )\r
{\r
- /* The auto reload timer will still be active, but the one shot timer\r
- should now have stopped. At this time the auto reload timer should have\r
- expired again, but the one shot timer count should not have changed. */\r
+ /* The auto-reload timer will still be active, but the one-shot timer\r
+ should now have stopped. At this time the auto-reload timer should have\r
+ expired again, but the one-shot timer count should not have changed. */\r
if( ucISRAutoReloadTimerCounter != 2 )\r
{\r
xTestStatus = pdFAIL;\r
}\r
else if( uxTick == ( ( 2 * xBasePeriod ) + ( xBasePeriod >> ( TickType_t ) 2U ) ) )\r
{\r
- /* The auto reload timer will still be active, but the one shot timer\r
+ /* The auto-reload timer will still be active, but the one-shot timer\r
should now have stopped. Again though, at this time, neither timer call\r
back should have been called since the last test. */\r
if( ucISRAutoReloadTimerCounter != 2 )\r
}\r
else if( uxTick == ( 3 * xBasePeriod ) )\r
{\r
- /* Start the one shot timer again. */\r
+ /* Start the one-shot timer again. */\r
xTimerStartFromISR( xISROneShotTimer, NULL );\r
}\r
else if( uxTick == ( ( 3 * xBasePeriod ) + xMargin ) )\r
{\r
- /* The auto reload timer and one shot timer will be active. At\r
- this time the auto reload timer should have expired again, but the one\r
+ /* The auto-reload timer and one-shot timer will be active. At\r
+ this time the auto-reload timer should have expired again, but the one\r
shot timer count should not have changed yet. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Now stop the auto reload timer. The one shot timer was started\r
+ /* Now stop the auto-reload timer. The one-shot timer was started\r
a few ticks ago. */\r
xTimerStopFromISR( xISRAutoReloadTimer, NULL );\r
}\r
else if( uxTick == ( 4 * ( xBasePeriod - xMargin ) ) )\r
{\r
- /* The auto reload timer is now stopped, and the one shot timer is\r
+ /* The auto-reload timer is now stopped, and the one-shot timer is\r
active, but at this time neither timer should have expired since the\r
last test. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
}\r
else if( uxTick == ( ( 4 * xBasePeriod ) + xMargin ) )\r
{\r
- /* The auto reload timer is now stopped, and the one shot timer is\r
- active. The one shot timer should have expired again, but the auto\r
+ /* The auto-reload timer is now stopped, and the one-shot timer is\r
+ active. The one-shot timer should have expired again, but the auto\r
reload timer should not have executed its callback. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r
}\r
else if( uxTick == ( 8 * xBasePeriod ) )\r
{\r
- /* The auto reload timer is now stopped, and the one shot timer has\r
+ /* The auto-reload timer is now stopped, and the one-shot timer has\r
already expired and then stopped itself. Both callback counters should\r
not have incremented since the last test. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
configASSERT( xTestStatus );\r
}\r
\r
- /* Now reset the one shot timer. */\r
+ /* Now reset the one-shot timer. */\r
xTimerResetFromISR( xISROneShotTimer, NULL );\r
}\r
else if( uxTick == ( ( 9 * xBasePeriod ) - xMargin ) )\r
{\r
- /* Only the one shot timer should be running, but it should not have\r
+ /* Only the one-shot timer should be running, but it should not have\r
expired since the last test. Check the callback counters have not\r
- incremented, then reset the one shot timer again. */\r
+ incremented, then reset the one-shot timer again. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r
xTestStatus = pdFAIL;\r
}\r
else if( uxTick == ( ( 10 * xBasePeriod ) - ( 2 * xMargin ) ) )\r
{\r
- /* Only the one shot timer should be running, but it should not have\r
+ /* Only the one-shot timer should be running, but it should not have\r
expired since the last test. Check the callback counters have not\r
- incremented, then reset the one shot timer again. */\r
+ incremented, then reset the one-shot timer again. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r
xTestStatus = pdFAIL;\r
}\r
else if( uxTick == ( ( 11 * xBasePeriod ) - ( 3 * xMargin ) ) )\r
{\r
- /* Only the one shot timer should be running, but it should not have\r
+ /* Only the one-shot timer should be running, but it should not have\r
expired since the last test. Check the callback counters have not\r
- incremented, then reset the one shot timer once again. */\r
+ incremented, then reset the one-shot timer once again. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r
xTestStatus = pdFAIL;\r
}\r
else if( uxTick == ( ( 12 * xBasePeriod ) - ( 2 * xMargin ) ) )\r
{\r
- /* Only the one shot timer should have been running and this time it\r
+ /* Only the one-shot timer should have been running and this time it\r
should have expired. Check its callback count has been incremented.\r
- The auto reload timer is still not running so should still have the same\r
- count value. This time the one shot timer is not reset so should not\r
+ The auto-reload timer is still not running so should still have the same\r
+ count value. This time the one-shot timer is not reset so should not\r
restart from its expiry period again. */\r
if( ucISRAutoReloadTimerCounter != 3 )\r
{\r