]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/Common/Minimal/TimerDemo.c
Ensure demo app files are using FreeRTOS V8 names - a few were missed previously.
[freertos] / FreeRTOS / Demo / Common / Minimal / TimerDemo.c
index 9a8e52510042669a9144a8b62fe0954eeec224b2..35f8d96780ca6d83e6874c5cd9e21632e274886d 100644 (file)
@@ -86,7 +86,7 @@
 \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
+#define trmdemoNUM_TIMER_RESETS                        ( ( uint8_t ) 10 )\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -118,35 +118,35 @@ static void prvResetStartConditionsForNextIteration( void );
 \r
 /* Flag that will be latched to pdFAIL should any unexpected behaviour be\r
 detected in any of the demo tests. */\r
-static volatile portBASE_TYPE xTestStatus = pdPASS;\r
+static volatile BaseType_t xTestStatus = pdPASS;\r
 \r
 /* Counter that is incremented on each cycle of a test.  This is used to\r
 detect a stalled task - a test that is no longer running. */\r
-static volatile unsigned long ulLoopCounter = 0;\r
+static volatile uint32_t ulLoopCounter = 0;\r
 \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
 referenced from xAutoReloadTimers[] are used by the prvTimerTestTask task. */\r
 static TimerHandle_t xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };\r
-static unsigned char ucAutoReloadTimerCounters[ 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
 ucOneShotTimerCounter each time it gets called. */\r
 static TimerHandle_t xOneShotTimer = NULL;\r
-static unsigned char ucOneShotTimerCounter = ( unsigned char ) 0;\r
+static uint8_t ucOneShotTimerCounter = ( uint8_t ) 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 TimerHandle_t xISRAutoReloadTimer = NULL;\r
-static unsigned char ucISRAutoReloadTimerCounter = ( unsigned char ) 0;\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
 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
-static unsigned char ucISROneShotTimerCounter = ( unsigned char ) 0;\r
+static uint8_t ucISROneShotTimerCounter = ( uint8_t ) 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
@@ -226,9 +226,9 @@ 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( TickType_t xCycleFrequency )\r
+BaseType_t xAreTimerDemoTasksStillRunning( TickType_t xCycleFrequency )\r
 {\r
-static unsigned long ulLastLoopCounter = 0UL;\r
+static uint32_t ulLastLoopCounter = 0UL;\r
 TickType_t xMaxBlockTimeUsedByTheseTests, xLoopCounterIncrementTimeMax;\r
 static TickType_t xIterationsWithoutCounterIncrement = ( TickType_t ) 0, xLastCycleFrequency;\r
 \r
@@ -277,7 +277,7 @@ static TickType_t xIterationsWithoutCounterIncrement = ( TickType_t ) 0, xLastCy
 \r
 static void prvTest1_CreateTimersWithoutSchedulerRunning( void )\r
 {\r
-unsigned portBASE_TYPE xTimer;\r
+UBaseType_t xTimer;\r
 \r
        for( xTimer = 0; xTimer < configTIMER_QUEUE_LENGTH; xTimer++ )\r
        {\r
@@ -361,7 +361,7 @@ unsigned portBASE_TYPE xTimer;
 \r
 static void prvTest2_CheckTaskAndTimersInitialState( void )\r
 {\r
-unsigned char ucTimer;\r
+uint8_t ucTimer;\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
@@ -370,7 +370,7 @@ unsigned char ucTimer;
        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 < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
+       for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
                if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) == pdFALSE )\r
                {\r
@@ -389,7 +389,7 @@ unsigned char ucTimer;
 \r
 static void    prvTest3_CheckAutoReloadExpireRates( void )\r
 {\r
-unsigned char ucMaxAllowableValue, ucMinAllowableValue, ucTimer;\r
+uint8_t ucMaxAllowableValue, ucMinAllowableValue, ucTimer;\r
 TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;\r
 \r
        /* Check the auto reload timers expire at the expected rates. */\r
@@ -402,15 +402,15 @@ TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;
 \r
        /* Check that all the auto reload timers have called their callback     \r
        function the expected number of times. */\r
-       for( ucTimer = 0; ucTimer < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
+       for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
                /* The expected number of expiries is equal to the block period divided\r
                by the timer period. */\r
                xTimerPeriod = ( ( ( TickType_t ) ucTimer + ( TickType_t ) 1 ) * xBasePeriod );\r
                xExpectedNumber = xBlockPeriod / xTimerPeriod;\r
                \r
-               ucMaxAllowableValue = ( ( unsigned char ) xExpectedNumber ) ;\r
-               ucMinAllowableValue = ( unsigned char ) ( ( unsigned char ) xExpectedNumber - ( unsigned char ) 1 ); /* Weird casting to try and please all compilers. */\r
+               ucMaxAllowableValue = ( ( uint8_t ) xExpectedNumber ) ;\r
+               ucMinAllowableValue = ( uint8_t ) ( ( uint8_t ) xExpectedNumber - ( uint8_t ) 1 ); /* Weird casting to try and please all compilers. */\r
 \r
                if( ( ucAutoReloadTimerCounters[ ucTimer ] < ucMinAllowableValue ) ||\r
                        ( ucAutoReloadTimerCounters[ ucTimer ] > ucMaxAllowableValue )\r
@@ -432,13 +432,13 @@ TickType_t xBlockPeriod, xTimerPeriod, xExpectedNumber;
 \r
 static void prvTest4_CheckAutoReloadTimersCanBeStopped( void )\r
 {              \r
-unsigned char ucTimer;\r
+uint8_t ucTimer;\r
 \r
        /* Check the auto reload timers can be stopped correctly, and correctly\r
        report their state. */\r
 \r
        /* Stop all the active timers. */\r
-       for( ucTimer = 0; ucTimer < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
+       for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
                /* The timer has not been stopped yet! */\r
                if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) == pdFALSE )\r
@@ -466,7 +466,7 @@ unsigned char ucTimer;
                be active.  The critical section is used to ensure the timer does\r
                not call its callback between the next line running and the array\r
                being cleared back to zero, as that would mask an error condition. */\r
-               if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH ] != ( unsigned char ) 0 )\r
+               if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH ] != ( uint8_t ) 0 )\r
                {\r
                        xTestStatus = pdFAIL;\r
                        configASSERT( xTestStatus );\r
@@ -480,9 +480,9 @@ unsigned char ucTimer;
        /* The timers are now all inactive, so this time, after delaying, none\r
        of the callback counters should have incremented. */\r
        vTaskDelay( ( ( TickType_t ) configTIMER_QUEUE_LENGTH ) * xBasePeriod );\r
-       for( ucTimer = 0; ucTimer < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
+       for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
-               if( ucAutoReloadTimerCounters[ ucTimer ] != ( unsigned char ) 0 )\r
+               if( ucAutoReloadTimerCounters[ ucTimer ] != ( uint8_t ) 0 )\r
                {\r
                        xTestStatus = pdFAIL;\r
                        configASSERT( xTestStatus );\r
@@ -510,7 +510,7 @@ static void prvTest5_CheckBasicOneShotTimerBehaviour( void )
                configASSERT( xTestStatus );\r
        }\r
 \r
-       if( ucOneShotTimerCounter != ( unsigned char ) 0 )\r
+       if( ucOneShotTimerCounter != ( uint8_t ) 0 )\r
        {\r
                xTestStatus = pdFAIL;\r
                configASSERT( xTestStatus );\r
@@ -535,7 +535,7 @@ static void prvTest5_CheckBasicOneShotTimerBehaviour( void )
                configASSERT( xTestStatus );\r
        }\r
 \r
-       if( ucOneShotTimerCounter != ( unsigned char ) 1 )\r
+       if( ucOneShotTimerCounter != ( uint8_t ) 1 )\r
        {\r
                xTestStatus = pdFAIL;\r
                configASSERT( xTestStatus );\r
@@ -543,7 +543,7 @@ static void prvTest5_CheckBasicOneShotTimerBehaviour( void )
        else\r
        {\r
                /* Reset the one shot timer callback count. */\r
-               ucOneShotTimerCounter = ( unsigned char ) 0;\r
+               ucOneShotTimerCounter = ( uint8_t ) 0;\r
        }\r
 \r
        if( xTestStatus == pdPASS )\r
@@ -557,7 +557,7 @@ static void prvTest5_CheckBasicOneShotTimerBehaviour( void )
 \r
 static void prvTest6_CheckAutoReloadResetBehaviour( void )\r
 {\r
-unsigned char ucTimer;\r
+uint8_t ucTimer;\r
 \r
        /* Check timer reset behaviour. */\r
 \r
@@ -593,7 +593,7 @@ unsigned char ucTimer;
                        configASSERT( xTestStatus );\r
                }\r
 \r
-               if( ucOneShotTimerCounter != ( unsigned char ) 0 )\r
+               if( ucOneShotTimerCounter != ( uint8_t ) 0 )\r
                {\r
                        xTestStatus = pdFAIL;\r
                        configASSERT( xTestStatus );\r
@@ -605,7 +605,7 @@ unsigned char ucTimer;
                        configASSERT( xTestStatus );\r
                }\r
 \r
-               if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] != ( unsigned char ) 0 )\r
+               if( ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] != ( uint8_t ) 0 )\r
                {\r
                        xTestStatus = pdFAIL;\r
                        configASSERT( xTestStatus );\r
@@ -628,7 +628,7 @@ unsigned char ucTimer;
 \r
        /* The timers were not reset during the above delay period so should now\r
        both have called their callback functions. */\r
-       if( ucOneShotTimerCounter != ( unsigned char ) 1 )\r
+       if( ucOneShotTimerCounter != ( uint8_t ) 1 )\r
        {\r
                xTestStatus = pdFAIL;\r
                configASSERT( xTestStatus );\r
@@ -665,8 +665,8 @@ unsigned char ucTimer;
 \r
        /* Clear the timer callback counts, ready for another iteration of these\r
        tests. */\r
-       ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] = ( unsigned char ) 0;\r
-       ucOneShotTimerCounter = ( unsigned char ) 0;\r
+       ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH - 1 ] = ( uint8_t ) 0;\r
+       ucOneShotTimerCounter = ( uint8_t ) 0;\r
 \r
        if( xTestStatus == pdPASS )\r
        {\r
@@ -679,12 +679,12 @@ unsigned char ucTimer;
 \r
 static void prvResetStartConditionsForNextIteration( void )\r
 {\r
-unsigned char ucTimer;\r
+uint8_t ucTimer;\r
 \r
        /* Start the timers again to start all the tests over again. */\r
 \r
        /* Start the timers again. */\r
-       for( ucTimer = 0; ucTimer < ( unsigned char ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
+       for( ucTimer = 0; ucTimer < ( uint8_t ) configTIMER_QUEUE_LENGTH; ucTimer++ )\r
        {\r
                /* The timer has not been started yet! */\r
                if( xTimerIsTimerActive( xAutoReloadTimers[ ucTimer ] ) != pdFALSE )\r
@@ -1023,9 +1023,9 @@ static TickType_t uxTick = ( TickType_t ) -1;
 \r
 static void prvAutoReloadTimerCallback( TimerHandle_t pxExpiredTimer )\r
 {\r
-unsigned long ulTimerID;\r
+uint32_t ulTimerID;\r
 \r
-       ulTimerID = ( unsigned long ) pvTimerGetTimerID( pxExpiredTimer );\r
+       ulTimerID = ( uint32_t ) pvTimerGetTimerID( pxExpiredTimer );\r
        if( ulTimerID <= ( configTIMER_QUEUE_LENGTH + 1 ) )\r
        {\r
                ( ucAutoReloadTimerCounters[ ulTimerID ] )++;\r