]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/TimerDemo.c
Update the demo directory to use the version 8 type naming conventions.
[freertos] / FreeRTOS / Demo / Common / Minimal / TimerDemo.c
index 35af89bb29da357817ee351ebf74399907ed41c7..a9a34ef849b4b10eb1eae93b986f86e5c7ddda2e 100644 (file)
@@ -84,8 +84,8 @@
        #error configTIMER_TASK_PRIORITY must be set to at least 1 for this test/demo to function correctly.\r
 #endif\r
 \r
-#define tmrdemoDONT_BLOCK                              ( ( portTickType ) 0 )\r
-#define tmrdemoONE_SHOT_TIMER_PERIOD   ( xBasePeriod * ( portTickType ) 3 )\r
+#define tmrdemoDONT_BLOCK                              ( ( TickType_t ) 0 )\r
+#define tmrdemoONE_SHOT_TIMER_PERIOD   ( xBasePeriod * ( TickType_t ) 3 )\r
 #define trmdemoNUM_TIMER_RESETS                        ( ( unsigned char ) 10 )\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -97,11 +97,11 @@ prvAutoReloadTimerCallback() callback function, and use the ID of the
 pxExpiredTimer parameter passed into that function to know which counter to\r
 increment.  The other timers all have their own unique callback function and\r
 simply increment their counters without using the callback function parameter. */\r
-static void prvAutoReloadTimerCallback( xTimerHandle pxExpiredTimer );\r
-static void prvOneShotTimerCallback( xTimerHandle pxExpiredTimer );\r
+static void prvAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer );\r
+static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer );\r
 static void prvTimerTestTask( void *pvParameters );\r
-static void prvISRAutoReloadTimerCallback( xTimerHandle pxExpiredTimer );\r
-static void prvISROneShotTimerCallback( xTimerHandle pxExpiredTimer );\r
+static void prvISRAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer );\r
+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
@@ -128,33 +128,33 @@ static volatile unsigned long ulLoopCounter = 0;
 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
 referenced from xAutoReloadTimers[] are used by the prvTimerTestTask task. */\r
-static xTimerHandle xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
+static TimerHandle_t xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
 static unsigned char ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
 \r
 /* The one shot timer is configured to use a callback function that increments\r
 ucOneShotTimerCounter each time it gets called. */\r
-static xTimerHandle xOneShotTimer = NULL;\r
+static TimerHandle_t xOneShotTimer = NULL;\r
 static unsigned char ucOneShotTimerCounter = ( unsigned char ) 0;\r
 \r
 /* The ISR reload 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 xTimerHandle xISRAutoReloadTimer = NULL;\r
+static TimerHandle_t xISRAutoReloadTimer = NULL;\r
 static unsigned char ucISRAutoReloadTimerCounter = ( unsigned char ) 0;\r
 \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 xTimerHandle xISROneShotTimer = NULL;\r
+static TimerHandle_t xISROneShotTimer = NULL;\r
 static unsigned char ucISROneShotTimerCounter = ( unsigned char ) 0;\r
 \r
 /* The period of all the timers are a multiple of the base period.  The base\r
 period is configured by the parameter to vStartTimerDemoTask(). */\r
-static portTickType xBasePeriod = 0;\r
+static TickType_t xBasePeriod = 0;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-void vStartTimerDemoTask( portTickType xBasePeriodIn )\r
+void vStartTimerDemoTask( TickType_t xBasePeriodIn )\r
 {\r
        /* Start with the timer and counter arrays clear - this is only necessary\r
        where the compiler does not clear them automatically on start up. */\r
@@ -226,17 +226,17 @@ static void prvTimerTestTask( void *pvParameters )
 \r
 /* This is called to check that the created task is still running and has not\r
 detected any errors. */\r
-portBASE_TYPE xAreTimerDemoTasksStillRunning( portTickType xCycleFrequency )\r
+portBASE_TYPE xAreTimerDemoTasksStillRunning( TickType_t xCycleFrequency )\r
 {\r
 static unsigned long ulLastLoopCounter = 0UL;\r
-portTickType xMaxBlockTimeUsedByTheseTests, xLoopCounterIncrementTimeMax;\r
-static portTickType xIterationsWithoutCounterIncrement = ( portTickType ) 0, xLastCycleFrequency;\r
+TickType_t xMaxBlockTimeUsedByTheseTests, xLoopCounterIncrementTimeMax;\r
+static TickType_t xIterationsWithoutCounterIncrement = ( TickType_t ) 0, xLastCycleFrequency;\r
 \r
        if( xLastCycleFrequency != xCycleFrequency )\r
        {\r
                /* The cycle frequency has probably become much faster due to an error\r
                elsewhere.  Start counting Iterations again. */\r
-               xIterationsWithoutCounterIncrement = ( portTickType ) 0;\r
+               xIterationsWithoutCounterIncrement = ( TickType_t ) 0;\r
                xLastCycleFrequency = xCycleFrequency;\r
        }               \r
 \r
@@ -244,7 +244,7 @@ static portTickType xIterationsWithoutCounterIncrement = ( portTickType ) 0, xLa
        function to be called without ulLoopCounter being incremented.  This is\r
        necessary because the tests in this file block for extended periods, and the\r
        block period might be longer than the time between calls to this function. */\r
-       xMaxBlockTimeUsedByTheseTests = ( ( portTickType ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\r
+       xMaxBlockTimeUsedByTheseTests = ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\r
        xLoopCounterIncrementTimeMax = ( xMaxBlockTimeUsedByTheseTests / xCycleFrequency ) + 1;\r
 \r
        /* If the demo task is still running then the loop counter is expected to\r
@@ -263,7 +263,7 @@ static portTickType xIterationsWithoutCounterIncrement = ( portTickType ) 0, xLa
        {\r
                /* ulLoopCounter changed, so the count of times this function was called\r
                without a change can be reset to zero. */\r
-               xIterationsWithoutCounterIncrement = ( portTickType ) 0;\r
+               xIterationsWithoutCounterIncrement = ( TickType_t ) 0;\r
        }\r
 \r
        ulLastLoopCounter = ulLoopCounter;\r
@@ -286,7 +286,7 @@ unsigned portBASE_TYPE xTimer;
                been started, so their block times should get set to zero within the timer\r
                API itself. */\r
                xAutoReloadTimers[ xTimer ] = xTimerCreate( "FR Timer",                                                 /* Text name to facilitate debugging.  The kernel does not use this itself. */\r
-                                                                                                       ( ( xTimer + ( portTickType ) 1 ) * xBasePeriod ),/* The period for the timer.  The plus 1 ensures a period of zero is not specified. */\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
                                                                                                        prvAutoReloadTimerCallback );           /* The callback to be called when the timer expires. */\r
@@ -388,14 +388,14 @@ unsigned char ucTimer;
 static void    prvTest3_CheckAutoReloadExpireRates( void )\r
 {\r
 unsigned char ucMaxAllowableValue, ucMinAllowableValue, ucTimer;\r
-portTickType xBlockPeriod, xTimerPeriod, xExpectedNumber;\r
+TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;\r
 \r
        /* Check the auto reload timers expire at the expected rates. */\r
 \r
        \r
        /* Delaying for configTIMER_QUEUE_LENGTH * xBasePeriod ticks should allow\r
        all the auto reload timers to expire at least once. */\r
-       xBlockPeriod = ( ( portTickType ) configTIMER_QUEUE_LENGTH ) * xBasePeriod;\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
@@ -404,7 +404,7 @@ portTickType xBlockPeriod, xTimerPeriod, xExpectedNumber;
        {\r
                /* The expected number of expiries is equal to the block period divided\r
                by the timer period. */\r
-               xTimerPeriod = ( ( ( portTickType ) ucTimer + ( portTickType ) 1 ) * xBasePeriod );\r
+               xTimerPeriod = ( ( ( TickType_t ) ucTimer + ( TickType_t ) 1 ) * xBasePeriod );\r
                xExpectedNumber = xBlockPeriod / xTimerPeriod;\r
                \r
                ucMaxAllowableValue = ( ( unsigned char ) xExpectedNumber ) ;\r
@@ -477,7 +477,7 @@ unsigned char ucTimer;
 \r
        /* The timers are now all inactive, so this time, after delaying, none\r
        of the callback counters should have incremented. */\r
-       vTaskDelay( ( ( portTickType ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
+       vTaskDelay( ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
        for( ucTimer = 0; ucTimer < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
                if( ucAutoReloadTimerCounters[ ucTimer ] != ( unsigned char ) 0 )\r
@@ -525,7 +525,7 @@ static void prvTest5_CheckBasicOneShotTimerBehaviour( void )
        /* 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 * ( portTickType ) 3 );\r
+       vTaskDelay( tmrdemoONE_SHOT_TIMER_PERIOD * ( TickType_t ) 3 );\r
 \r
        if( xTimerIsTimerActive( xOneShotTimer ) != pdFALSE )\r
        {\r
@@ -622,7 +622,7 @@ unsigned char ucTimer;
        }\r
 \r
        /* Finally delay long enough for both running timers to expire. */\r
-       vTaskDelay( ( ( portTickType ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
+       vTaskDelay( ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
 \r
        /* The timers were not reset during the above delay period so should now\r
        both have called their callback functions. */\r
@@ -715,7 +715,7 @@ unsigned char ucTimer;
 \r
 void vTimerPeriodicISRTests( void )\r
 {\r
-static portTickType uxTick = ( portTickType ) -1;\r
+static TickType_t uxTick = ( TickType_t ) -1;\r
 \r
 #if( configTIMER_TASK_PRIORITY != ( configMAX_PRIORITIES - 1 ) )\r
        /* The timer service task is not the highest priority task, so it cannot\r
@@ -737,9 +737,9 @@ static portTickType uxTick = ( portTickType ) -1;
        will expire when the kernel's tick count is (100 + xBasePeriod).  For this\r
        reason xMargin is used as an allowable margin for premature timer expiries\r
        as well as late timer expiries. */\r
-       const portTickType xMargin = 6;\r
+       const TickType_t xMargin = 6;\r
 #else\r
-       const portTickType xMargin = 3;\r
+       const TickType_t xMargin = 3;\r
 #endif\r
 \r
 \r
@@ -755,7 +755,7 @@ static portTickType uxTick = ( portTickType ) -1;
                /* It is possible that the timer task has not yet made room in the\r
                timer queue.  If the timers cannot be started then reset uxTick so\r
                another attempt is made later. */\r
-               uxTick = ( portTickType ) -1;\r
+               uxTick = ( TickType_t ) -1;\r
 \r
                /* Try starting first timer. */\r
                if( xTimerChangePeriodFromISR( xISRAutoReloadTimer, xBasePeriod, NULL ) == pdPASS )\r
@@ -822,7 +822,7 @@ static portTickType uxTick = ( portTickType ) -1;
                        configASSERT( xTestStatus );\r
                }\r
        }\r
-       else if( uxTick == ( ( 2 * xBasePeriod ) + ( xBasePeriod >> ( portTickType ) 2U ) ) )\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
                should now have stopped.  Again though, at this time, neither timer call\r
@@ -1012,14 +1012,14 @@ static portTickType uxTick = ( portTickType ) -1;
                        configASSERT( xTestStatus );\r
                }\r
                \r
-               uxTick = ( portTickType ) -1;\r
+               uxTick = ( TickType_t ) -1;\r
        }       \r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 /*** Timer callback functions are defined below here. ***/\r
 \r
-static void prvAutoReloadTimerCallback( xTimerHandle pxExpiredTimer )\r
+static void prvAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer )\r
 {\r
 unsigned long ulTimerID;\r
 \r
@@ -1037,7 +1037,7 @@ unsigned long ulTimerID;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvOneShotTimerCallback( xTimerHandle pxExpiredTimer )\r
+static void prvOneShotTimerCallback( TimerHandle_t pxExpiredTimer )\r
 {\r
        /* The parameter is not used in this case as only one timer uses this\r
        callback function. */\r
@@ -1047,7 +1047,7 @@ static void prvOneShotTimerCallback( xTimerHandle pxExpiredTimer )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvISRAutoReloadTimerCallback( xTimerHandle pxExpiredTimer )\r
+static void prvISRAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer )\r
 {\r
        /* The parameter is not used in this case as only one timer uses this\r
        callback function. */\r
@@ -1057,7 +1057,7 @@ static void prvISRAutoReloadTimerCallback( xTimerHandle pxExpiredTimer )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvISROneShotTimerCallback( xTimerHandle pxExpiredTimer )\r
+static void prvISROneShotTimerCallback( TimerHandle_t pxExpiredTimer )\r
 {\r
        /* The parameter is not used in this case as only one timer uses this\r
        callback function. */\r