summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2011-02-28 16:14:49 +0000
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2011-02-28 16:14:49 +0000
commita418756c947321cc15439ce0e6053da0e6df5013 (patch)
tree1218f811e48aa986b5998afeddb23f8f759f5966
parent0c59cbf74df33a0e186497a97da044b7db117eed (diff)
downloadfreertos-a418756c947321cc15439ce0e6053da0e6df5013.tar.gz
Check in the timer module test/demo task.
git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@1311 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
-rw-r--r--Demo/Common/Minimal/TimerDemo.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/Demo/Common/Minimal/TimerDemo.c b/Demo/Common/Minimal/TimerDemo.c
index 1915ff3c0..18b0381a9 100644
--- a/Demo/Common/Minimal/TimerDemo.c
+++ b/Demo/Common/Minimal/TimerDemo.c
@@ -260,7 +260,7 @@ static portTickType xIterationsWithoutCounterIncrement = ( portTickType ) 0, xLa
static void prvTest1_CreateTimersWithoutSchedulerRunning( void )
{
-portBASE_TYPE xTimer;
+unsigned portBASE_TYPE xTimer;
for( xTimer = 0; xTimer < configTIMER_QUEUE_LENGTH; xTimer++ )
{
@@ -269,7 +269,7 @@ portBASE_TYPE xTimer;
been started, so their block times should get set to zero within the timer
API itself. */
xAutoReloadTimers[ xTimer ] = xTimerCreate( "FR Timer", /* Text name to facilitate debugging. The kernel does not use this itself. */
- ( ( xTimer + 1 ) * xBasePeriod ),/* The period for the timer. The plus 1 ensures a period of zero is not specified. */
+ ( ( xTimer + ( portTickType ) 1 ) * xBasePeriod ),/* The period for the timer. The plus 1 ensures a period of zero is not specified. */
pdTRUE, /* Auto-reload is set to true. */
( void * ) xTimer, /* An identifier for the timer as all the auto reload timers use the same callback. */
prvAutoReloadTimerCallback ); /* The callback to be called when the timer expires. */
@@ -314,20 +314,20 @@ portBASE_TYPE xTimer;
/* This time it would not be expected that the timer could be
started at this point. */
xTestStatus = pdFAIL;
- configASSERT( xTestStatus );
+ configASSERT( xTestStatus );
}
}
/* Create the timers that are used from the tick interrupt to test the timer
API functions that can be called from an ISR. */
xISRAutoReloadTimer = xTimerCreate( "ISR AR", /* The text name given to the timer. */
- 0, /* The timer is not given a period yet - this will be done from the tick hook. */
+ 0xffff, /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */
pdTRUE, /* This is an auto reload timer. */
( void * ) NULL, /* The identifier is not required. */
prvISRAutoReloadTimerCallback );/* The callback that is executed when the timer expires. */
xISROneShotTimer = xTimerCreate( "ISR OS", /* The text name given to the timer. */
- 0, /* The timer is not given a period yet - this will be done from the tick hook. */
+ 0xffff, /* The timer is not given a period yet - this will be done from the tick hook, but a period of 0 is invalid. */
pdFALSE, /* This is a one shot timer. */
( void * ) NULL, /* The identifier is not required. */
prvISROneShotTimerCallback ); /* The callback that is executed when the timer expires. */
@@ -698,13 +698,13 @@ unsigned char ucTimer;
void vTimerPeriodicISRTests( void )
{
-static unsigned portBASE_TYPE uxTick = ( unsigned portBASE_TYPE ) -1;
+static portTickType uxTick = ( portTickType ) -1;
/* The xHigherPriorityTaskWoken parameter is not used in this case as this
function is called from the tick hook anyway. However the API required it
to be present. */
portBASE_TYPE xHigherPriorityTaskWoken = pdTRUE;
-portBASE_TYPE xMargin;
+portTickType xMargin;
if( configTIMER_TASK_PRIORITY != ( configMAX_PRIORITIES - 1 ) )
{
@@ -718,10 +718,24 @@ portBASE_TYPE xMargin;
}
else
{
- xMargin = 0;
+ xMargin = 1;
+ }
+
+ /* This test is called from the tick ISR even when the scheduler is suspended.
+ Therefore, it is possible for the xTickCount to be temporarily less than the
+ uxTicks count maintained in this function. That can result in calculated
+ unblock times being too short, as this function is not called as missed ticks
+ (ticks that occur while the scheduler is suspended) are unwound to re-instate
+ the real tick value. Therefore, if this happens, just abandon the test
+ and start again. */
+ if( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
+ {
+ uxTick = ( portTickType ) -1;
+ }
+ else
+ {
+ uxTick++;
}
-
- uxTick++;
if( uxTick == 0 )
{
@@ -969,7 +983,7 @@ portBASE_TYPE xMargin;
configASSERT( xTestStatus );
}
- uxTick = ( unsigned portBASE_TYPE ) -1;
+ uxTick = ( portTickType ) -1;
}
}
/*-----------------------------------------------------------*/