From c99428a5659873d3c9451bd437dcd5c823578374 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 5 Apr 2011 20:19:54 +0000 Subject: [PATCH] Cosmetic work towards MISRA compliance statement pre release of V7. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1345 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/include/FreeRTOS.h | 22 +-- Source/include/StackMacros.h | 34 ++-- Source/include/croutine.h | 2 +- Source/include/queue.h | 42 ++-- Source/include/semphr.h | 40 ++-- Source/include/task.h | 2 +- Source/include/timers.h | 362 +++++++++++++++++------------------ Source/queue.c | 15 +- Source/tasks.c | 43 ++--- Source/timers.c | 12 +- 10 files changed, 279 insertions(+), 295 deletions(-) diff --git a/Source/include/FreeRTOS.h b/Source/include/FreeRTOS.h index cbaf57b48..0edc2af46 100644 --- a/Source/include/FreeRTOS.h +++ b/Source/include/FreeRTOS.h @@ -173,8 +173,7 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #endif #if configMAX_TASK_NAME_LEN < 1 - #undef configMAX_TASK_NAME_LEN - #define configMAX_TASK_NAME_LEN 1 + #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h #endif #ifndef INCLUDE_xTaskResumeFromISR @@ -188,9 +187,6 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); /* The timers module relies on xTaskGetSchedulerState(). */ #if configUSE_TIMERS == 1 - #undef INCLUDE_xTaskGetSchedulerState - #define INCLUDE_xTaskGetSchedulerState 1 - #ifndef configTIMER_TASK_PRIORITY #error If configUSE_TIMERS is set to 1 then configTIMER_TASK_PRIORITY must also be defined. #endif /* configTIMER_TASK_PRIORITY */ @@ -209,15 +205,8 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #define INCLUDE_xTaskGetSchedulerState 0 #endif -#if ( configUSE_MUTEXES == 1 ) - /* xTaskGetCurrentTaskHandle is used by the priority inheritance mechanism - within the mutex implementation so must be available if mutexes are used. */ - #undef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 1 -#else - #ifndef INCLUDE_xTaskGetCurrentTaskHandle - #define INCLUDE_xTaskGetCurrentTaskHandle 0 - #endif +#ifndef INCLUDE_xTaskGetCurrentTaskHandle + #define INCLUDE_xTaskGetCurrentTaskHandle 0 #endif @@ -231,11 +220,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * ); #ifndef configQUEUE_REGISTRY_SIZE - #define configQUEUE_REGISTRY_SIZE 0 + #define configQUEUE_REGISTRY_SIZE 0U #endif -#if configQUEUE_REGISTRY_SIZE < 1 - #define configQUEUE_REGISTRY_SIZE 0 +#if ( configQUEUE_REGISTRY_SIZE < 1U ) #define vQueueAddToRegistry( xQueue, pcName ) #define vQueueUnregisterQueue( xQueue ) #endif diff --git a/Source/include/StackMacros.h b/Source/include/StackMacros.h index 902738c81..9a96151e8 100644 --- a/Source/include/StackMacros.h +++ b/Source/include/StackMacros.h @@ -142,23 +142,23 @@ #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) - #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ - { \ - char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \ - static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ - tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ - \ - \ - pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ - \ - /* Has the extremity of the task stack ever been written over? */ \ - if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ - { \ - vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ - } \ + #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ + { \ + char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \ + static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \ + tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \ + \ + \ + pcEndOfStack -= sizeof( ucExpectedStackBytes ); \ + \ + /* Has the extremity of the task stack ever been written over? */ \ + if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \ + { \ + vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \ + } \ } #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ diff --git a/Source/include/croutine.h b/Source/include/croutine.h index fec57c46c..21b6358d9 100644 --- a/Source/include/croutine.h +++ b/Source/include/croutine.h @@ -406,7 +406,7 @@ void vCoRoutineSchedule( void ); #define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ { \ *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ - if( *pxResult == errQUEUE_BLOCKED ) \ + if( *( pxResult ) == errQUEUE_BLOCKED ) \ { \ crSET_STATE0( ( xHandle ) ); \ *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \ diff --git a/Source/include/queue.h b/Source/include/queue.h index f9d7bfa78..0c166786f 100644 --- a/Source/include/queue.h +++ b/Source/include/queue.h @@ -33,9 +33,9 @@ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained by writing to Richard Barry, contact details for whom are available on the FreeRTOS WEB site. @@ -51,16 +51,14 @@ licensing and training services. */ -#ifndef INC_FREERTOS_H - #error "#include FreeRTOS.h" must appear in source files before "#include queue.h" -#endif - - - #ifndef QUEUE_H #define QUEUE_H +#ifndef INC_FREERTOS_H + #error "#include FreeRTOS.h" must appear in source files before "#include queue.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -219,7 +217,7 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA * \defgroup xQueueSend xQueueSend * \ingroup QueueManagement */ -#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT ) +#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) /** * queue. h @@ -301,7 +299,7 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA * \defgroup xQueueSend xQueueSend * \ingroup QueueManagement */ -#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) +#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** * queue. h @@ -385,7 +383,7 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA * \defgroup xQueueSend xQueueSend * \ingroup QueueManagement */ -#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) +#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) /** @@ -567,7 +565,7 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const * \defgroup xQueueReceive xQueueReceive * \ingroup QueueManagement */ -#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdTRUE ) +#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) /** * queue. h @@ -660,7 +658,7 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const * \defgroup xQueueReceive xQueueReceive * \ingroup QueueManagement */ -#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE ) +#define xQueueReceive( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) /** @@ -858,7 +856,7 @@ void vQueueDelete( xQueueHandle pxQueue ); * \defgroup xQueueSendFromISR xQueueSendFromISR * \ingroup QueueManagement */ -#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_FRONT ) +#define xQueueSendToFrontFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) /** @@ -929,7 +927,7 @@ void vQueueDelete( xQueueHandle pxQueue ); * \defgroup xQueueSendFromISR xQueueSendFromISR * \ingroup QueueManagement */ -#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK ) +#define xQueueSendToBackFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** * queue. h @@ -1003,7 +1001,7 @@ void vQueueDelete( xQueueHandle pxQueue ); * \defgroup xQueueSendFromISR xQueueSendFromISR * \ingroup QueueManagement */ -#define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken, queueSEND_TO_BACK ) +#define xQueueSendFromISR( pxQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** * queue. h @@ -1197,10 +1195,10 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue */ signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); -#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_FRONT ) -#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( xQueue, pvItemToQueue, xTicksToWait, queueSEND_TO_BACK ) -#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( xQueue, pvBuffer, xTicksToWait, pdFALSE ) -#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( xQueue, pvBuffer, xTicksToWait, pdTRUE ) +#define xQueueAltSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) +#define xQueueAltSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueAltGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) +#define xQueueAltReceive( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdFALSE ) +#define xQueueAltPeek( xQueue, pvBuffer, xTicksToWait ) xQueueAltGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE ) /* * The functions defined above are for passing data to and from tasks. The @@ -1250,7 +1248,7 @@ portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex ); * @param pcName The name to be associated with the handle. This is the * name that the kernel aware debugger will display. */ -#if configQUEUE_REGISTRY_SIZE > 0 +#if configQUEUE_REGISTRY_SIZE > 0U void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ); #endif diff --git a/Source/include/semphr.h b/Source/include/semphr.h index 8674096ad..c08659786 100644 --- a/Source/include/semphr.h +++ b/Source/include/semphr.h @@ -51,20 +51,20 @@ licensing and training services. */ +#ifndef SEMAPHORE_H +#define SEMAPHORE_H + #ifndef INC_FREERTOS_H #error "#include FreeRTOS.h" must appear in source files before "#include semphr.h" #endif -#ifndef SEMAPHORE_H -#define SEMAPHORE_H - #include "queue.h" typedef xQueueHandle xSemaphoreHandle; -#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned char ) 1 ) -#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned char ) 0 ) -#define semGIVE_BLOCK_TIME ( ( portTickType ) 0 ) +#define semBINARY_SEMAPHORE_QUEUE_LENGTH ( ( unsigned char ) 1U ) +#define semSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned char ) 0U ) +#define semGIVE_BLOCK_TIME ( ( portTickType ) 0U ) /** @@ -105,12 +105,12 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary * \ingroup Semaphores */ -#define vSemaphoreCreateBinary( xSemaphore ) { \ - xSemaphore = xQueueCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \ - if( xSemaphore != NULL ) \ - { \ - xSemaphoreGive( xSemaphore ); \ - } \ +#define vSemaphoreCreateBinary( xSemaphore ) { \ + ( xSemaphore ) = xQueueCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \ + if( ( xSemaphore ) != NULL ) \ + { \ + xSemaphoreGive( ( xSemaphore ) ); \ + } \ } /** @@ -178,7 +178,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreTake xSemaphoreTake * \ingroup Semaphores */ -#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( xQueueHandle ) xSemaphore, NULL, xBlockTime, pdFALSE ) +#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) /** * semphr. h @@ -271,7 +271,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive * \ingroup Semaphores */ -#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( xMutex, xBlockTime ) +#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) /* @@ -286,7 +286,7 @@ typedef xQueueHandle xSemaphoreHandle; * responsiveness to gain execution speed, whereas the fully featured API * sacrifices execution speed to ensure better interrupt responsiveness. */ -#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( xQueueHandle ) xSemaphore, NULL, xBlockTime, pdFALSE ) +#define xSemaphoreAltTake( xSemaphore, xBlockTime ) xQueueAltGenericReceive( ( xQueueHandle ) ( xSemaphore ), NULL, ( xBlockTime ), pdFALSE ) /** * semphr. h @@ -349,7 +349,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreGive xSemaphoreGive * \ingroup Semaphores */ -#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( xQueueHandle ) xSemaphore, NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** * semphr. h @@ -433,7 +433,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive * \ingroup Semaphores */ -#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( xMutex ) +#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) /* * xSemaphoreAltGive() is an alternative version of xSemaphoreGive(). @@ -447,7 +447,7 @@ typedef xQueueHandle xSemaphoreHandle; * responsiveness to gain execution speed, whereas the fully featured API * sacrifices execution speed to ensure better interrupt responsiveness. */ -#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( xQueueHandle ) xSemaphore, NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) +#define xSemaphoreAltGive( xSemaphore ) xQueueAltGenericSend( ( xQueueHandle ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) /** * semphr. h @@ -538,7 +538,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR * \ingroup Semaphores */ -#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) xSemaphore, NULL, pxHigherPriorityTaskWoken, queueSEND_TO_BACK ) +#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueueHandle ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) /** * semphr. h @@ -703,7 +703,7 @@ typedef xQueueHandle xSemaphoreHandle; * \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting * \ingroup Semaphores */ -#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( uxMaxCount, uxInitialCount ) +#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) #endif /* SEMAPHORE_H */ diff --git a/Source/include/task.h b/Source/include/task.h index 3a64d0966..c4b65b750 100644 --- a/Source/include/task.h +++ b/Source/include/task.h @@ -122,7 +122,7 @@ typedef struct xTASK_PARAMTERS * * \ingroup TaskUtils */ -#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 ) +#define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0U ) /** * task. h diff --git a/Source/include/timers.h b/Source/include/timers.h index 727c4fdec..b55a6d4d5 100644 --- a/Source/include/timers.h +++ b/Source/include/timers.h @@ -79,7 +79,7 @@ as defined below. */ *----------------------------------------------------------*/ /** - * Type by which software timers are referenced. For example, a call to + * Type by which software timers are referenced. For example, a call to * xTimerCreate() returns an xTimerHandle variable that can then be used to * reference the subject timer in calls to other software timer API functions * (for example, xTimerStart(), xTimerReset(), etc.). @@ -90,14 +90,14 @@ typedef void * xTimerHandle; typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); /** - * xTimerHandle xTimerCreate( const signed char *pcTimerName, - * portTickType xTimerPeriod, - * unsigned portBASE_TYPE uxAutoReload, - * void * pvTimerID, + * xTimerHandle xTimerCreate( const signed char *pcTimerName, + * portTickType xTimerPeriod, + * unsigned portBASE_TYPE uxAutoReload, + * void * pvTimerID, * tmrTIMER_CALLBACK pxCallbackFunction ); * - * Creates a new software timer instance. This allocates the storage required - * by the new timer, initialises the new timers internal state, and returns a + * Creates a new software timer instance. This allocates the storage required + * by the new timer, initialises the new timers internal state, and returns a * handle by which the new timer can be referenced. * * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), @@ -109,7 +109,7 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); * purely to assist debugging. The kernel itself only ever references a timer by * its handle, and never by its name. * - * @param xTimerPeriod The timer period. The time is defined in tick periods so + * @param xTimerPeriod The timer period. The time is defined in tick periods so * the constant portTICK_RATE_MS can be used to convert a time that has been * specified in milliseconds. For example, if the timer must expire after 100 * ticks, then xTimerPeriod should be set to 100. Alternatively, if the timer @@ -121,46 +121,46 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and * enter the dormant state after it expires. * - * @param pvTimerID An identifier that is assigned to the timer being created. - * Typically this would be used in the timer callback function to identify which - * timer expired when the same callback function is assigned to more than one + * @param pvTimerID An identifier that is assigned to the timer being created. + * Typically this would be used in the timer callback function to identify which + * timer expired when the same callback function is assigned to more than one * timer. * * @param pxCallbackFunction The function to call when the timer expires. - * Callback functions must have the prototype defined by tmrTIMER_CALLBACK, + * Callback functions must have the prototype defined by tmrTIMER_CALLBACK, * which is "void vCallbackFunction( xTIMER *xTimer );". * * @return If the timer is successfully create then a handle to the newly * created timer is returned. If the timer cannot be created (because either - * there is insufficient FreeRTOS heap remaining to allocate the timer + * there is insufficient FreeRTOS heap remaining to allocate the timer * structures, or the timer period was set to 0) then 0 is returned. * * Example usage: * - * + * * #define NUM_TIMERS 5 - * + * * // An array to hold handles to the created timers. * xTimerHandle xTimers[ NUM_TIMERS ]; - * + * * // An array to hold a count of the number of times each timer expires. * long lExpireCounters[ NUM_TIMERS ] = { 0 }; - * - * // Define a callback function that will be used by multiple timer instances. - * // The callback function does nothing but count the number of times the + * + * // Define a callback function that will be used by multiple timer instances. + * // The callback function does nothing but count the number of times the * // associated timer expires, and stop the timer once the timer has expired * // 10 times. * void vTimerCallback( xTIMER *pxTimer ) * { * long lArrayIndex; * const long xMaxExpiryCountBeforeStopping = 10; - * + * * // Optionally do something if the pxTimer parameter is NULL. * configASSERT( pxTimer ); * * // Which timer expired? * lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer ); - * + * * // Increment the number of times that pxTimer has expired. * lExpireCounters[ lArrayIndex ] += 1; * @@ -172,11 +172,11 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); * xTimerStop( pxTimer, 0 ); * } * } - * + * * void main( void ) * { * long x; - * + * * // Create then start some timers. Starting the timers before the scheduler * // has been started means the timers will start running immediately that * // the scheduler starts. @@ -188,7 +188,7 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); * ( void * ) x, // Assign each timer a unique id equal to its array index. * vTimerCallback // Each timer calls the same callback when it expires. * ); - * + * * if( xTimers[ x ] == NULL ) * { * // The timer was not created. @@ -197,33 +197,33 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer ); * { * // Start the timer. No block time is specified, and even if one was * // it would be ignored because the scheduler has not yet been - * // started. + * // started. * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) * { * // The timer could not be set into the Active state. * } * } * } - * + * * // ... * // Create tasks here. * // ... - * + * * // Starting the scheduler will start the timers running as they have already * // been set into the active state. * xTaskStartScheduler(); - * + * * // Should not reach here. * for( ;; ); * } */ -xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriod, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION; +xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION; /** * void *pvTimerGetTimerID( xTimerHandle xTimer ); * * Returns the ID assigned to the timer. - * + * * IDs are assigned to timers using the pvTimerID parameter of the call to * xTimerCreated() that was used to create the timer. * @@ -247,7 +247,7 @@ void *pvTimerGetTimerID( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * Queries a timer to see if it is active or dormant. * * A timer will be dormant if: - * 1) It has been created but not started, or + * 1) It has been created but not started, or * 2) It is an expired on-shot timer that has not been restarted. * * Timers are created in the dormant state. The xTimerStart(), xTimerReset(), @@ -272,7 +272,7 @@ void *pvTimerGetTimerID( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * else * { * // xTimer is not active, do something else. - * } + * } * } */ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; @@ -281,20 +281,20 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * portBASE_TYPE xTimerStart( xTimerHandle xTimer, portTickType xBlockTime ); * * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the + * public FreeRTOS timer API functions send commands to the timer service task + * though a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the * configTIMER_QUEUE_LENGTH configuration constant. * - * xTimerStart() starts a timer that was previously created using the + * xTimerStart() starts a timer that was previously created using the * xTimerCreate() API function. If the timer had already been started and was * already in the active state, then xTimerStart() has equivalent functionality * to the xTimerReset() API function. * * Starting a timer ensures the timer is in the active state. If the timer * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerStart() was + * associated with the timer will get called 'n' ticks after xTimerStart() was * called, where 'n' is the timers defined period. * * It is valid to call xTimerStart() before the scheduler has been started, but @@ -309,38 +309,38 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * * @param xBlockTime Specifies the time, in ticks, that the calling task should * be held in the Blocked state to wait for the start command to be successfully - * sent to the timer command queue, should the queue already be full when + * sent to the timer command queue, should the queue already be full when * xTimerStart() was called. xBlockTime is ignored if xTimerStart() is called - * before the scheduler is started. + * before the scheduler is started. * - * @return pdFAIL will be returned if the start command could not be sent to + * @return pdFAIL will be returned if the start command could not be sent to * the timer command queue even after xBlockTime ticks had passed. pdPASS will * be returned if the command was successfully sent to the timer command queue. * When the command is actually processed will depend on the priority of the * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * timers expiry time is relative to when xTimerStart() is actually called. The + * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY * configuration constant. * * Example usage: - * + * * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCount(), NULL, xBlockTime ) +#define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) ) /** * portBASE_TYPE xTimerStop( xTimerHandle xTimer, portTickType xBlockTime ); * * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the + * public FreeRTOS timer API functions send commands to the timer service task + * though a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the * configTIMER_QUEUE_LENGTH configuration constant. * - * xTimerStop() stops a timer that was previously started using either of the - * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), + * xTimerStop() stops a timer that was previously started using either of the + * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), * xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions. * * Stopping a timer ensures the timer is not in the active state. @@ -352,74 +352,74 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * * @param xBlockTime Specifies the time, in ticks, that the calling task should * be held in the Blocked state to wait for the stop command to be successfully - * sent to the timer command queue, should the queue already be full when + * sent to the timer command queue, should the queue already be full when * xTimerStop() was called. xBlockTime is ignored if xTimerStop() is called - * before the scheduler is started. + * before the scheduler is started. * - * @return pdFAIL will be returned if the stop command could not be sent to + * @return pdFAIL will be returned if the stop command could not be sent to * the timer command queue even after xBlockTime ticks had passed. pdPASS will * be returned if the command was successfully sent to the timer command queue. * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * timer service/daemon task relative to other tasks in the system. The timer + * service/daemon task priority is set by the configTIMER_TASK_PRIORITY * configuration constant. * * Example usage: - * + * * See the xTimerCreate() API function example usage scenario. * */ -#define xTimerStop( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_STOP, 0, NULL, xBlockTime ) +#define xTimerStop( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xBlockTime ) ) /** - * portBASE_TYPE xTimerChangePeriod( xTimerHandle xTimer, + * portBASE_TYPE xTimerChangePeriod( xTimerHandle xTimer, * portTickType xNewPeriod, * portTickType xBlockTime ); * * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the + * public FreeRTOS timer API functions send commands to the timer service task + * though a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the * configTIMER_QUEUE_LENGTH configuration constant. * - * xTimerChangePeriod() changes the period of a timer that was previously + * xTimerChangePeriod() changes the period of a timer that was previously * created using the xTimerCreate() API function. * * xTimerChangePeriod() can be called to change the period of an active or * dormant state timer. * - * The configUSE_TIMERS configuration constant must be set to 1 for + * The configUSE_TIMERS configuration constant must be set to 1 for * xTimerChangePeriod() to be available. * * @param xTimer The handle of the timer that is having its period changed. * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_RATE_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to + * @param xNewPeriod The new period for xTimer. Timer periods are specified in + * tick periods, so the constant portTICK_RATE_MS can be used to convert a time + * that has been specified in milliseconds. For example, if the timer must + * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, + * if the timer must expire after 500ms, then xNewPeriod can be set to * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than * or equal to 1000. * * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the change period command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerChangePeriod() was called. xBlockTime is ignored if - * xTimerChangePeriod() is called before the scheduler is started. - * - * @return pdFAIL will be returned if the change period command could not be - * sent to the timer command queue even after xBlockTime ticks had passed. - * pdPASS will be returned if the command was successfully sent to the timer - * command queue. When the command is actually processed will depend on the - * priority of the timer service/daemon task relative to other tasks in the - * system. The timer service/daemon task priority is set by the + * be held in the Blocked state to wait for the change period command to be + * successfully sent to the timer command queue, should the queue already be + * full when xTimerChangePeriod() was called. xBlockTime is ignored if + * xTimerChangePeriod() is called before the scheduler is started. + * + * @return pdFAIL will be returned if the change period command could not be + * sent to the timer command queue even after xBlockTime ticks had passed. + * pdPASS will be returned if the command was successfully sent to the timer + * command queue. When the command is actually processed will depend on the + * priority of the timer service/daemon task relative to other tasks in the + * system. The timer service/daemon task priority is set by the * configTIMER_TASK_PRIORITY configuration constant. * * Example usage: * * // This function assumes xTimer has already been created. If the timer - * // referenced by xTimer is already active when it is called, then the timer + * // referenced by xTimer is already active when it is called, then the timer * // is deleted. If the timer referenced by xTimer is not active when it is * // called, then the period of the timer is set to 500ms and the timer is * // started. @@ -445,69 +445,69 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * // The command could not be sent, even after waiting for 100 ticks * // to pass. Take appropriate action here. * } - * } + * } * } */ - #define xTimerChangePeriod( xTimer, xNewPeriod, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_CHANGE_PERIOD, xNewPeriod, NULL, xBlockTime ) + #define xTimerChangePeriod( xTimer, xNewPeriod, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xBlockTime ) ) /** * portBASE_TYPE xTimerDelete( xTimerHandle xTimer, portTickType xBlockTime ); * * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the + * public FreeRTOS timer API functions send commands to the timer service task + * though a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the * configTIMER_QUEUE_LENGTH configuration constant. * * xTimerDelete() deletes a timer that was previously created using the * xTimerCreate() API function. * - * The configUSE_TIMERS configuration constant must be set to 1 for + * The configUSE_TIMERS configuration constant must be set to 1 for * xTimerDelete() to be available. * * @param xTimer The handle of the timer being deleted. * * @param xBlockTime Specifies the time, in ticks, that the calling task should - * be held in the Blocked state to wait for the delete command to be - * successfully sent to the timer command queue, should the queue already be - * full when xTimerDelete() was called. xBlockTime is ignored if xTimerDelete() - * is called before the scheduler is started. + * be held in the Blocked state to wait for the delete command to be + * successfully sent to the timer command queue, should the queue already be + * full when xTimerDelete() was called. xBlockTime is ignored if xTimerDelete() + * is called before the scheduler is started. * - * @return pdFAIL will be returned if the delete command could not be sent to + * @return pdFAIL will be returned if the delete command could not be sent to * the timer command queue even after xBlockTime ticks had passed. pdPASS will * be returned if the command was successfully sent to the timer command queue. * When the command is actually processed will depend on the priority of the - * timer service/daemon task relative to other tasks in the system. The timer - * service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * timer service/daemon task relative to other tasks in the system. The timer + * service/daemon task priority is set by the configTIMER_TASK_PRIORITY * configuration constant. * * Example usage: - * + * * See the xTimerChangePeriod() API function example usage scenario. */ -#define xTimerDelete( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_DELETE, 0, NULL, xBlockTime ) +#define xTimerDelete( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xBlockTime ) ) /** * portBASE_TYPE xTimerReset( xTimerHandle xTimer, portTickType xBlockTime ); * * Timer functionality is provided by a timer service/daemon task. Many of the - * public FreeRTOS timer API functions send commands to the timer service task - * though a queue called the timer command queue. The timer command queue is - * private to the kernel itself and is not directly accessible to application - * code. The length of the timer command queue is set by the + * public FreeRTOS timer API functions send commands to the timer service task + * though a queue called the timer command queue. The timer command queue is + * private to the kernel itself and is not directly accessible to application + * code. The length of the timer command queue is set by the * configTIMER_QUEUE_LENGTH configuration constant. * - * xTimerReset() re-starts a timer that was previously created using the + * xTimerReset() re-starts a timer that was previously created using the * xTimerCreate() API function. If the timer had already been started and was * already in the active state, then xTimerReset() will cause the timer to * re-evaluate its expiry time so that it is relative to when xTimerReset() was - * called. If the timer was in the dormant state then xTimerReset() has + * called. If the timer was in the dormant state then xTimerReset() has * equivalent functionality to the xTimerStart() API function. * * Resetting a timer ensures the timer is in the active state. If the timer * is not stopped, deleted, or reset in the mean time, the callback function - * associated with the timer will get called 'n' ticks after xTimerReset() was + * associated with the timer will get called 'n' ticks after xTimerReset() was * called, where 'n' is the timers defined period. * * It is valid to call xTimerReset() before the scheduler has been started, but @@ -522,23 +522,23 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * * @param xBlockTime Specifies the time, in ticks, that the calling task should * be held in the Blocked state to wait for the reset command to be successfully - * sent to the timer command queue, should the queue already be full when + * sent to the timer command queue, should the queue already be full when * xTimerReset() was called. xBlockTime is ignored if xTimerReset() is called - * before the scheduler is started. + * before the scheduler is started. * - * @return pdFAIL will be returned if the reset command could not be sent to + * @return pdFAIL will be returned if the reset command could not be sent to * the timer command queue even after xBlockTime ticks had passed. pdPASS will * be returned if the command was successfully sent to the timer command queue. * When the command is actually processed will depend on the priority of the * timer service/daemon task relative to other tasks in the system, although the - * timers expiry time is relative to when xTimerStart() is actually called. The - * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY + * timers expiry time is relative to when xTimerStart() is actually called. The + * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY * configuration constant. * * Example usage: - * - * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In + * + * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In * // this case, the timer is a one-shot timer. * * xTimerHandle xBacklightTimer = NULL; @@ -556,7 +556,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * void vKeyPressEventHandler( char cKey ) * { * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of + * // responsible for turning the back-light off after 5 seconds of * // key inactivity. Wait 10 ticks for the command to be successfully sent * // if it cannot be sent immediately. * vSetBacklightState( BACKLIGHT_ON ); @@ -572,7 +572,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * void main( void ) * { * long x; - * + * * // Create then start the one-shot timer that is responsible for turning * // the back-light off if no keys are pressed within a 5 second period. * xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel. @@ -581,7 +581,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * 0, // The id is not used by the callback so can take any value. * vBacklightTimerCallback // The callback function that switches the LCD back-light off. * ); - * + * * if( xBacklightTimer == NULL ) * { * // The timer was not created. @@ -590,29 +590,29 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * { * // Start the timer. No block time is specified, and even if one was * // it would be ignored because the scheduler has not yet been - * // started. + * // started. * if( xTimerStart( xBacklightTimer, 0 ) != pdPASS ) * { * // The timer could not be set into the Active state. * } * } - * + * * // ... * // Create tasks here. * // ... - * + * * // Starting the scheduler will start the timer running as it has already * // been set into the active state. * xTaskStartScheduler(); - * + * * // Should not reach here. * for( ;; ); * } */ -#define xTimerReset( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCount(), NULL, xBlockTime ) +#define xTimerReset( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) ) /** - * portBASE_TYPE xTimerStartFromISR( xTimerHandle xTimer, + * portBASE_TYPE xTimerStartFromISR( xTimerHandle xTimer, * portBASE_TYPE *pxHigherPriorityTaskWoken ); * * A version of xTimerStart() that can be called from an interrupt service @@ -632,20 +632,20 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * xTimerStartFromISR() sets this value to pdTRUE then a context switch should * be performed before the interrupt exits. * - * @return pdFAIL will be returned if the start command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerStartFromISR() is actually called. The timer service/daemon - * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * @return pdFAIL will be returned if the start command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system, although the timers expiry time is + * relative to when xTimerStartFromISR() is actually called. The timer service/daemon + * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for + * + * // This scenario assumes xBacklightTimer has already been created. When a + * // key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In + * // this case, the timer is a one-shot timer, and unlike the example given for * // the xTimerReset() function, the key press event handler is an interrupt * // service routine. * @@ -664,7 +664,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; * * // Ensure the LCD back-light is on, then restart the timer that is - * // responsible for turning the back-light off after 5 seconds of + * // responsible for turning the back-light off after 5 seconds of * // key inactivity. This is an interrupt service routine so can only * // call FreeRTOS API functions that end in "FromISR". * vSetBacklightState( BACKLIGHT_ON ); @@ -693,10 +693,10 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * } * } */ -#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCountFromISR(), pxHigherPriorityTaskWoken, 0 ) +#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) /** - * portBASE_TYPE xTimerStopFromISR( xTimerHandle xTimer, + * portBASE_TYPE xTimerStopFromISR( xTimerHandle xTimer, * portBASE_TYPE *pxHigherPriorityTaskWoken ); * * A version of xTimerStop() that can be called from an interrupt service @@ -716,12 +716,12 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * xTimerStopFromISR() sets this value to pdTRUE then a context switch should * be performed before the interrupt exits. * - * @return pdFAIL will be returned if the stop command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * @return pdFAIL will be returned if the stop command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system. The timer service/daemon task + * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: * @@ -755,45 +755,45 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * } * } */ -#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_STOP, 0, pxHigherPriorityTaskWoken, 0 ) +#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0, ( pxHigherPriorityTaskWoken ), 0U ) /** - * portBASE_TYPE xTimerChangePeriodFromISR( xTimerHandle xTimer, + * portBASE_TYPE xTimerChangePeriodFromISR( xTimerHandle xTimer, * portTickType xNewPeriod, * portBASE_TYPE *pxHigherPriorityTaskWoken ); * - * A version of xTimerChangePeriod() that can be called from an interrupt + * A version of xTimerChangePeriod() that can be called from an interrupt * service routine. * * @param xTimer The handle of the timer that is having its period changed. * - * @param xNewPeriod The new period for xTimer. Timer periods are specified in - * tick periods, so the constant portTICK_RATE_MS can be used to convert a time - * that has been specified in milliseconds. For example, if the timer must - * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, - * if the timer must expire after 500ms, then xNewPeriod can be set to + * @param xNewPeriod The new period for xTimer. Timer periods are specified in + * tick periods, so the constant portTICK_RATE_MS can be used to convert a time + * that has been specified in milliseconds. For example, if the timer must + * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, + * if the timer must expire after 500ms, then xNewPeriod can be set to * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than * or equal to 1000. * * @param pxHigherPriorityTaskWoken The timer service/daemon task spends most * of its time in the Blocked state, waiting for messages to arrive on the timer - * command queue. Calling xTimerChangePeriodFromISR() writes a message to the + * command queue. Calling xTimerChangePeriodFromISR() writes a message to the * timer command queue, so has the potential to transition the timer service/ - * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() - * causes the timer service/daemon task to leave the Blocked state, and the - * timer service/daemon task has a priority equal to or greater than the - * currently executing task (the task that was interrupted), then - * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the - * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets - * this value to pdTRUE then a context switch should be performed before the + * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() + * causes the timer service/daemon task to leave the Blocked state, and the + * timer service/daemon task has a priority equal to or greater than the + * currently executing task (the task that was interrupted), then + * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the + * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets + * this value to pdTRUE then a context switch should be performed before the * interrupt exits. * * @return pdFAIL will be returned if the command to change the timers period - * could not be sent to the timer command queue. pdPASS will be returned if the - * command was successfully sent to the timer command queue. When the command - * is actually processed will depend on the priority of the timer service/daemon - * task relative to other tasks in the system. The timer service/daemon task - * priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * could not be sent to the timer command queue. pdPASS will be returned if the + * command was successfully sent to the timer command queue. When the command + * is actually processed will depend on the priority of the timer service/daemon + * task relative to other tasks in the system. The timer service/daemon task + * priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: * @@ -811,7 +811,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * // FreeRTOS API functions that end in "FromISR" can be used. * if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS ) * { - * // The command to change the timers period was not executed + * // The command to change the timers period was not executed * // successfully. Take appropriate action here. * } * @@ -827,10 +827,10 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * } * } */ -#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_CHANGE_PERIOD, xNewPeriod, pxHigherPriorityTaskWoken, 0 ) +#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) /** - * portBASE_TYPE xTimerResetFromISR( xTimerHandle xTimer, + * portBASE_TYPE xTimerResetFromISR( xTimerHandle xTimer, * portBASE_TYPE *pxHigherPriorityTaskWoken ); * * A version of xTimerReset() that can be called from an interrupt service @@ -851,20 +851,20 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * xTimerResetFromISR() sets this value to pdTRUE then a context switch should * be performed before the interrupt exits. * - * @return pdFAIL will be returned if the reset command could not be sent to - * the timer command queue. pdPASS will be returned if the command was - * successfully sent to the timer command queue. When the command is actually - * processed will depend on the priority of the timer service/daemon task - * relative to other tasks in the system, although the timers expiry time is - * relative to when xTimerResetFromISR() is actually called. The timer service/daemon - * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. + * @return pdFAIL will be returned if the reset command could not be sent to + * the timer command queue. pdPASS will be returned if the command was + * successfully sent to the timer command queue. When the command is actually + * processed will depend on the priority of the timer service/daemon task + * relative to other tasks in the system, although the timers expiry time is + * relative to when xTimerResetFromISR() is actually called. The timer service/daemon + * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * * Example usage: - * - * // This scenario assumes xBacklightTimer has already been created. When a - * // key is pressed, an LCD back-light is switched on. If 5 seconds pass - * // without a key being pressed, then the LCD back-light is switched off. In - * // this case, the timer is a one-shot timer, and unlike the example given for + * + * // This scenario assumes xBacklightTimer has already been created. When a + * // key is pressed, an LCD back-light is switched on. If 5 seconds pass + * // without a key being pressed, then the LCD back-light is switched off. In + * // this case, the timer is a one-shot timer, and unlike the example given for * // the xTimerReset() function, the key press event handler is an interrupt * // service routine. * @@ -883,7 +883,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; * * // Ensure the LCD back-light is on, then reset the timer that is - * // responsible for turning the back-light off after 5 seconds of + * // responsible for turning the back-light off after 5 seconds of * // key inactivity. This is an interrupt service routine so can only * // call FreeRTOS API functions that end in "FromISR". * vSetBacklightState( BACKLIGHT_ON ); @@ -912,7 +912,7 @@ portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION; * } * } */ -#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCountFromISR(), pxHigherPriorityTaskWoken, 0 ) +#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) /* * Functions beyond this part are not part of the public API and are intended diff --git a/Source/queue.c b/Source/queue.c index 25374c77c..f5ce8bba1 100644 --- a/Source/queue.c +++ b/Source/queue.c @@ -144,6 +144,7 @@ signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; +void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; /* * Co-routine queue functions differ from task queue functions. Co-routines are @@ -1285,7 +1286,7 @@ signed portBASE_TYPE xReturn; xReturn = pdPASS; /* Were any co-routines waiting for data to become available? */ - if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { /* In this instance the co-routine could be placed directly into the ready list as we are within a critical section. @@ -1360,7 +1361,7 @@ signed portBASE_TYPE xReturn; xReturn = pdPASS; /* Were any co-routines waiting for space to become available? */ - if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { /* In this instance the co-routine could be placed directly into the ready list as we are within a critical section. @@ -1399,7 +1400,7 @@ signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvIt co-routine has not already been woken. */ if( !xCoRoutinePreviouslyWoken ) { - if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { @@ -1434,7 +1435,7 @@ signed portBASE_TYPE xReturn; if( !( *pxCoRoutineWoken ) ) { - if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { if( xCoRoutineRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) { @@ -1463,7 +1464,7 @@ signed portBASE_TYPE xReturn; /* See if there is an empty space in the registry. A NULL name denotes a free slot. */ - for( ux = 0; ux < configQUEUE_REGISTRY_SIZE; ux++ ) + for( ux = ( unsigned portBASE_TYPE ) 0U; ux < configQUEUE_REGISTRY_SIZE; ux++ ) { if( xQueueRegistry[ ux ].pcQueueName == NULL ) { @@ -1486,7 +1487,7 @@ signed portBASE_TYPE xReturn; /* See if the handle of the queue being unregistered in actually in the registry. */ - for( ux = 0; ux < configQUEUE_REGISTRY_SIZE; ux++ ) + for( ux = ( unsigned portBASE_TYPE ) 0U; ux < configQUEUE_REGISTRY_SIZE; ux++ ) { if( xQueueRegistry[ ux ].xHandle == xQueue ) { @@ -1506,7 +1507,7 @@ signed portBASE_TYPE xReturn; void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) { /* This function should not be called by application code hence the - 'Restricted' in its name. It is not part of the public API. It is + 'Restricted' in its name. It is not part of the public API. It is designed for use by kernel code, and has special calling requirements. It can result in vListInsert() being called on a list that can only possibly ever have one item in it, so the list will be fast, but even diff --git a/Source/tasks.c b/Source/tasks.c index aad896a6d..0c4862497 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -329,6 +329,7 @@ portTickType xItemValue; \ /* Callback function prototypes. --------------------------*/ extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); +extern void vApplicationTickHook( void ); /* File private functions. --------------------------------*/ @@ -1298,25 +1299,25 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) { uxQueue--; - if( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) ) + if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE ) { prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), tskREADY_CHAR ); } }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY ); - if( !listLIST_IS_EMPTY( pxDelayedTaskList ) ) + if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE ) { prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, tskBLOCKED_CHAR ); } - if( !listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) ) + if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE ) { prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, tskBLOCKED_CHAR ); } #if( INCLUDE_vTaskDelete == 1 ) { - if( !listLIST_IS_EMPTY( &xTasksWaitingTermination ) ) + if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) { prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, tskDELETED_CHAR ); } @@ -1325,7 +1326,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) #if ( INCLUDE_vTaskSuspend == 1 ) { - if( !listLIST_IS_EMPTY( &xSuspendedTaskList ) ) + if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) { prvListTaskWithinSingleList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, tskSUSPENDED_CHAR ); } @@ -1373,25 +1374,25 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) { uxQueue--; - if( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) ) + if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxQueue ] ) ) == pdFALSE ) { prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &( pxReadyTasksLists[ uxQueue ] ), ulTotalRunTime ); } }while( uxQueue > ( unsigned short ) tskIDLE_PRIORITY ); - if( !listLIST_IS_EMPTY( pxDelayedTaskList ) ) + if( listLIST_IS_EMPTY( pxDelayedTaskList ) == pdFALSE ) { prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxDelayedTaskList, ulTotalRunTime ); } - if( !listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) ) + if( listLIST_IS_EMPTY( pxOverflowDelayedTaskList ) == pdFALSE ) { prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) pxOverflowDelayedTaskList, ulTotalRunTime ); } #if ( INCLUDE_vTaskDelete == 1 ) { - if( !listLIST_IS_EMPTY( &xTasksWaitingTermination ) ) + if( listLIST_IS_EMPTY( &xTasksWaitingTermination ) == pdFALSE ) { prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xTasksWaitingTermination, ulTotalRunTime ); } @@ -1400,7 +1401,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) #if ( INCLUDE_vTaskSuspend == 1 ) { - if( !listLIST_IS_EMPTY( &xSuspendedTaskList ) ) + if( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) { prvGenerateRunTimeStatsForTasksInList( pcWriteBuffer, ( xList * ) &xSuspendedTaskList, ulTotalRunTime ); } @@ -1512,8 +1513,6 @@ void vTaskIncrementTick( void ) scheduler is locked. */ #if ( configUSE_TICK_HOOK == 1 ) { - extern void vApplicationTickHook( void ); - vApplicationTickHook(); } #endif @@ -1521,11 +1520,9 @@ void vTaskIncrementTick( void ) #if ( configUSE_TICK_HOOK == 1 ) { - extern void vApplicationTickHook( void ); - /* Guard against the tick hook being called when the missed tick count is being unwound (when the scheduler is being unlocked. */ - if( uxMissedTicks == 0 ) + if( uxMissedTicks == ( unsigned portBASE_TYPE ) 0U ) { vApplicationTickHook(); } @@ -1550,7 +1547,7 @@ void vTaskIncrementTick( void ) { usQueue--; - while( !listLIST_IS_EMPTY( &( pxReadyTasksLists[ usQueue ] ) ) ) + while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ usQueue ] ) ) == pdFALSE ) { listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &( pxReadyTasksLists[ usQueue ] ) ); vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); @@ -1560,7 +1557,7 @@ void vTaskIncrementTick( void ) }while( usQueue > ( unsigned short ) tskIDLE_PRIORITY ); /* Remove any TCB's from the delayed queue. */ - while( !listLIST_IS_EMPTY( &xDelayedTaskList1 ) ) + while( listLIST_IS_EMPTY( &xDelayedTaskList1 ) == pdFALSE ) { listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList1 ); vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); @@ -1569,7 +1566,7 @@ void vTaskIncrementTick( void ) } /* Remove any TCB's from the overflow delayed queue. */ - while( !listLIST_IS_EMPTY( &xDelayedTaskList2 ) ) + while( listLIST_IS_EMPTY( &xDelayedTaskList2 ) == pdFALSE ) { listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xDelayedTaskList2 ); vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); @@ -1577,7 +1574,7 @@ void vTaskIncrementTick( void ) prvDeleteTCB( ( tskTCB * ) pxTCB ); } - while( !listLIST_IS_EMPTY( &xSuspendedTaskList ) ) + while( listLIST_IS_EMPTY( &xSuspendedTaskList ) == pdFALSE ) { listGET_OWNER_OF_NEXT_ENTRY( pxTCB, &xSuspendedTaskList ); vListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ); @@ -1591,7 +1588,7 @@ void vTaskIncrementTick( void ) #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxTagValue ) + void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) { tskTCB *xTCB; @@ -1608,7 +1605,7 @@ void vTaskIncrementTick( void ) /* Save the hook function in the TCB. A critical section is required as the value can be accessed from an interrupt. */ taskENTER_CRITICAL(); - xTCB->pxTaskTag = pxTagValue; + xTCB->pxTaskTag = pxHookFunction; taskEXIT_CRITICAL(); } @@ -2374,7 +2371,7 @@ tskTCB *pxNewTCB; /*-----------------------------------------------------------*/ -#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) +#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) xTaskHandle xTaskGetCurrentTaskHandle( void ) { @@ -2392,7 +2389,7 @@ tskTCB *pxNewTCB; /*-----------------------------------------------------------*/ -#if ( INCLUDE_xTaskGetSchedulerState == 1 ) +#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) portBASE_TYPE xTaskGetSchedulerState( void ) { diff --git a/Source/timers.c b/Source/timers.c index 62c8c318a..44071a1ed 100644 --- a/Source/timers.c +++ b/Source/timers.c @@ -65,7 +65,7 @@ task.h is included from an application file. */ /* This entire source file will be skipped if the application is not configured to include software timer functionality. This #if is closed at the very bottom -of this file. If you want to include software timer functionality then ensure +of this file. If you want to include software timer functionality then ensure configUSE_TIMERS is set to 1 in FreeRTOSConfig.h. */ #if ( configUSE_TIMERS == 1 ) @@ -177,7 +177,7 @@ portBASE_TYPE xReturn = pdFAIL; if( xTimerQueue != NULL ) { - xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", configTIMER_TASK_STACK_DEPTH, NULL, configTIMER_TASK_PRIORITY, NULL); + xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL); } configASSERT( xReturn ); @@ -274,7 +274,7 @@ portBASE_TYPE xResult; /* If the timer is an auto reload timer then calculate the next expiry time and re-insert the timer in the list of active timers. */ - if( pxTimer->uxAutoReload == pdTRUE ) + if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) { /* This is the only time a timer is inserted into a list using a time relative to anything other than the current time. It @@ -499,7 +499,7 @@ portTickType xTimeNow; list. Process it now. */ pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); - if( pxTimer->uxAutoReload == pdTRUE ) + if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) { xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY ); configASSERT( xResult ); @@ -560,7 +560,7 @@ portBASE_TYPE xResult; have not yet been switched. */ pxTimer->pxCallbackFunction( ( xTimerHandle ) pxTimer ); - if( pxTimer->uxAutoReload == pdTRUE ) + if( pxTimer->uxAutoReload == ( unsigned portBASE_TYPE ) pdTRUE ) { /* Calculate the reload value, and if the reload value results in the timer going into the same timer list then it has already expired @@ -603,7 +603,7 @@ static void prvCheckForValidListAndQueue( void ) vListInitialise( &xActiveTimerList2 ); pxCurrentTimerList = &xActiveTimerList1; pxOverflowTimerList = &xActiveTimerList2; - xTimerQueue = xQueueCreate( configTIMER_QUEUE_LENGTH, sizeof( xTIMER_MESSAGE ) ); + xTimerQueue = xQueueCreate( ( unsigned portBASE_TYPE ) configTIMER_QUEUE_LENGTH, sizeof( xTIMER_MESSAGE ) ); } } taskEXIT_CRITICAL(); -- 2.39.5