From ba2d5b628adfd60a00b9c90e805b4ab5d1405c5d Mon Sep 17 00:00:00 2001 From: rtel Date: Wed, 4 Jan 2017 05:07:12 +0000 Subject: [PATCH] Change how volatile is used in some of the standard demos to remove compiler warnings in the latest GCC versions. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2476 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- FreeRTOS/Demo/Common/Minimal/QueueSet.c | 3 ++- FreeRTOS/Demo/Common/Minimal/countsem.c | 12 ++++++------ FreeRTOS/Demo/Common/Minimal/dynamic.c | 8 ++++---- FreeRTOS/Demo/Common/Minimal/flop.c | 10 +++++----- FreeRTOS/Demo/Common/Minimal/integer.c | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/FreeRTOS/Demo/Common/Minimal/QueueSet.c b/FreeRTOS/Demo/Common/Minimal/QueueSet.c index f97ebb083..473a88a28 100644 --- a/FreeRTOS/Demo/Common/Minimal/QueueSet.c +++ b/FreeRTOS/Demo/Common/Minimal/QueueSet.c @@ -619,8 +619,9 @@ uint32_t ulReceived; static void prvSendToQueueInSetFromISR( void ) { static BaseType_t xQueueToWriteTo = 0; +uint32_t ulTxValueSnapshot = ulISRTxValue; - if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS ) + if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulTxValueSnapshot, NULL ) == pdPASS ) { ulISRTxValue++; diff --git a/FreeRTOS/Demo/Common/Minimal/countsem.c b/FreeRTOS/Demo/Common/Minimal/countsem.c index 575eded65..503d7b0f5 100644 --- a/FreeRTOS/Demo/Common/Minimal/countsem.c +++ b/FreeRTOS/Demo/Common/Minimal/countsem.c @@ -115,13 +115,13 @@ static void prvCountingSemaphoreTask( void *pvParameters ); * Utility function to increment the semaphore count value up from zero to * countMAX_COUNT_VALUE. */ -static void prvIncrementSemaphoreCount( SemaphoreHandle_t xSemaphore, UBaseType_t *puxLoopCounter ); +static void prvIncrementSemaphoreCount( SemaphoreHandle_t xSemaphore, volatile UBaseType_t *puxLoopCounter ); /* * Utility function to decrement the semaphore count value up from * countMAX_COUNT_VALUE to zero. */ -static void prvDecrementSemaphoreCount( SemaphoreHandle_t xSemaphore, UBaseType_t *puxLoopCounter ); +static void prvDecrementSemaphoreCount( SemaphoreHandle_t xSemaphore, volatile UBaseType_t *puxLoopCounter ); /*-----------------------------------------------------------*/ @@ -138,11 +138,11 @@ typedef struct COUNT_SEM_STRUCT /* Incremented on each cycle of the demo task. Used to detect a stalled task. */ - UBaseType_t uxLoopCounter; + volatile UBaseType_t uxLoopCounter; } xCountSemStruct; /* Two structures are defined, one is passed to each test task. */ -static volatile xCountSemStruct xParameters[ countNUM_TEST_TASKS ]; +static xCountSemStruct xParameters[ countNUM_TEST_TASKS ]; /*-----------------------------------------------------------*/ @@ -178,7 +178,7 @@ void vStartCountingSemaphoreTasks( void ) } /*-----------------------------------------------------------*/ -static void prvDecrementSemaphoreCount( SemaphoreHandle_t xSemaphore, UBaseType_t *puxLoopCounter ) +static void prvDecrementSemaphoreCount( SemaphoreHandle_t xSemaphore, volatile UBaseType_t *puxLoopCounter ) { UBaseType_t ux; @@ -217,7 +217,7 @@ UBaseType_t ux; } /*-----------------------------------------------------------*/ -static void prvIncrementSemaphoreCount( SemaphoreHandle_t xSemaphore, UBaseType_t *puxLoopCounter ) +static void prvIncrementSemaphoreCount( SemaphoreHandle_t xSemaphore, volatile UBaseType_t *puxLoopCounter ) { UBaseType_t ux; diff --git a/FreeRTOS/Demo/Common/Minimal/dynamic.c b/FreeRTOS/Demo/Common/Minimal/dynamic.c index 0c1571019..4e1ab698c 100644 --- a/FreeRTOS/Demo/Common/Minimal/dynamic.c +++ b/FreeRTOS/Demo/Common/Minimal/dynamic.c @@ -162,7 +162,7 @@ static TaskHandle_t xContinuousIncrementHandle, xLimitedIncrementHandle; /* The shared counter variable. This is passed in as a parameter to the two counter variables for demonstration purposes. */ -static volatile uint32_t ulCounter; +static uint32_t ulCounter; /* Variables used to check that the tasks are still operating without error. Each complete iteration of the controller task increments this variable @@ -214,11 +214,11 @@ void vStartDynamicPriorityTasks( void ) */ static portTASK_FUNCTION( vLimitedIncrementTask, pvParameters ) { -uint32_t *pulCounter; +volatile uint32_t *pulCounter; /* Take a pointer to the shared variable from the parameters passed into the task. */ - pulCounter = ( uint32_t * ) pvParameters; + pulCounter = ( volatile uint32_t * ) pvParameters; /* This will run before the control task, so the first thing it does is suspend - the control task will resume it when ready. */ @@ -248,7 +248,7 @@ UBaseType_t uxOurPriority; /* Take a pointer to the shared variable from the parameters passed into the task. */ - pulCounter = ( uint32_t * ) pvParameters; + pulCounter = ( volatile uint32_t * ) pvParameters; /* Query our priority so we can raise it when exclusive access to the shared variable is required. */ diff --git a/FreeRTOS/Demo/Common/Minimal/flop.c b/FreeRTOS/Demo/Common/Minimal/flop.c index 0c107b7b6..f5755cf8b 100644 --- a/FreeRTOS/Demo/Common/Minimal/flop.c +++ b/FreeRTOS/Demo/Common/Minimal/flop.c @@ -106,7 +106,7 @@ static portTASK_FUNCTION_PROTO( vCompetingMathTask4, pvParameters ); /* These variables are used to check that all the tasks are still running. If a task gets a calculation wrong it will stop setting its check variable. */ -static volatile uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; +static uint16_t usTaskCheck[ mathNUMBER_OF_TASKS ] = { ( uint16_t ) 0 }; /*-----------------------------------------------------------*/ @@ -139,7 +139,7 @@ short sError = pdFALSE; /* The variable this task increments to show it is still running is passed in as the parameter. */ - pusTaskCheckVariable = ( uint16_t * ) pvParameters; + pusTaskCheckVariable = ( volatile uint16_t * ) pvParameters; /* Keep performing a calculation and checking the result against a constant. */ for(;;) @@ -198,7 +198,7 @@ short sError = pdFALSE; /* The variable this task increments to show it is still running is passed in as the parameter. */ - pusTaskCheckVariable = ( uint16_t * ) pvParameters; + pusTaskCheckVariable = ( volatile uint16_t * ) pvParameters; /* Keep performing a calculation and checking the result against a constant. */ for( ;; ) @@ -250,7 +250,7 @@ short sError = pdFALSE; /* The variable this task increments to show it is still running is passed in as the parameter. */ - pusTaskCheckVariable = ( uint16_t * ) pvParameters; + pusTaskCheckVariable = ( volatile uint16_t * ) pvParameters; pdArray = ( portDOUBLE * ) pvPortMalloc( xArraySize * sizeof( portDOUBLE ) ); @@ -313,7 +313,7 @@ short sError = pdFALSE; /* The variable this task increments to show it is still running is passed in as the parameter. */ - pusTaskCheckVariable = ( uint16_t * ) pvParameters; + pusTaskCheckVariable = ( volatile uint16_t * ) pvParameters; pdArray = ( portDOUBLE * ) pvPortMalloc( xArraySize * sizeof( portDOUBLE ) ); diff --git a/FreeRTOS/Demo/Common/Minimal/integer.c b/FreeRTOS/Demo/Common/Minimal/integer.c index 8e01ff1c8..d99ff52c2 100644 --- a/FreeRTOS/Demo/Common/Minimal/integer.c +++ b/FreeRTOS/Demo/Common/Minimal/integer.c @@ -104,7 +104,7 @@ static portTASK_FUNCTION_PROTO( vCompeteingIntMathTask, pvParameters ); that the task is still executing. The check task sets the variable back to false, flagging an error if the variable is still false the next time it is called. */ -static volatile BaseType_t xTaskCheck[ intgNUMBER_OF_TASKS ] = { ( BaseType_t ) pdFALSE }; +static BaseType_t xTaskCheck[ intgNUMBER_OF_TASKS ] = { ( BaseType_t ) pdFALSE }; /*-----------------------------------------------------------*/ -- 2.39.5