From: rtel Date: Wed, 11 Feb 2015 15:41:30 +0000 (+0000) Subject: Kernel updates: X-Git-Tag: V8.2.1~9 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=213963db99ec74ea4ea667435e3ab9a0d74fa11a;p=freertos Kernel updates: + Added vTimerSetTimerID() to compliment vTimerGetTimerID(). Now the timer ID can be used as timer local storage. + Updated comments and added some additional assert() calls. Win32 port: + Some changes to allow easier 64-bit builds PIC24/dsPIC port: + Added NOP after disable interrupt instruction. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2329 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/RTOSDemo.uvproj b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/RTOSDemo.uvproj index d4ec7a4e7..744524502 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/RTOSDemo.uvproj +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/RTOSDemo.uvproj @@ -30,6 +30,7 @@ + 0 0 @@ -71,6 +72,8 @@ 0 0 + 0 + 0 1 @@ -97,6 +100,7 @@ 3 + 1 SARMCM3.DLL @@ -117,7 +121,7 @@ 16 - 0 + 1 1 1 1 @@ -126,20 +130,22 @@ 1 1 0 + 1 - 1 + 0 1 - 0 + 1 1 1 1 0 1 0 + 1 0 - 4 + 2 @@ -161,13 +167,18 @@ 1 0 0 - 0 + 1 1 4099 + 1 BIN\lmidk-agdi.dll "" () + + + + 0 @@ -346,6 +357,8 @@ 0 0 0 + 0 + 0 --diag_suppress 191,550,513,167,177,144 RVDS_ARMCM3_LM3S102, "PACK_STRUCT_END=","ALIGN_STRUCT_END=" @@ -362,6 +375,7 @@ 0 0 0 + 0 @@ -378,6 +392,7 @@ 0 0x00000000 0x20000000 + @@ -476,6 +491,11 @@ 1 ..\Common\Minimal\QueueSet.c + + EventGroupsDemo.c + 1 + ..\Common\Minimal\EventGroupsDemo.c + @@ -531,6 +551,16 @@ 1 ..\..\Source\portable\RVDS\ARM_CM3\port.c + + timers.c + 1 + ..\..\Source\timers.c + + + event_groups.c + 1 + ..\..\Source\event_groups.c + heap_2.c 1 diff --git a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/webserver/httpd-cgi.c b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/webserver/httpd-cgi.c index 5b9ae1611..76e1c3d2b 100644 --- a/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/webserver/httpd-cgi.c +++ b/FreeRTOS/Demo/CORTEX_LM3Sxxxx_IAR_Keil/webserver/httpd-cgi.c @@ -61,7 +61,7 @@ HTTPD_CGI_CALL(rtos, "rtos-stats", rtos_stats ); HTTPD_CGI_CALL(io, "led-io", led_io ); -static const struct httpd_cgi_call * const calls[] = { &file, &tcp, &net, &rtos, &io, NULL }; +static const struct httpd_cgi_call * calls[] = { &file, &tcp, &net, &rtos, &io, NULL }; /*---------------------------------------------------------------------------*/ static diff --git a/FreeRTOS/Source/include/portable.h b/FreeRTOS/Source/include/portable.h index 09f894ed6..834438364 100644 --- a/FreeRTOS/Source/include/portable.h +++ b/FreeRTOS/Source/include/portable.h @@ -95,7 +95,7 @@ must be set in the compiler's include path. */ #endif #if portBYTE_ALIGNMENT == 8 - #define portBYTE_ALIGNMENT_MASK ( 0x0007U ) + #define portBYTE_ALIGNMENT_MASK ( 0x0007 ) #endif #if portBYTE_ALIGNMENT == 4 diff --git a/FreeRTOS/Source/include/queue.h b/FreeRTOS/Source/include/queue.h index 8eb704c18..0633fb399 100644 --- a/FreeRTOS/Source/include/queue.h +++ b/FreeRTOS/Source/include/queue.h @@ -1490,10 +1490,8 @@ BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWa BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION; /* - * Reset a queue back to its original empty state. pdPASS is returned if the - * queue is successfully reset. pdFAIL is returned if the queue could not be - * reset because there are tasks blocked on the queue waiting to either - * receive from the queue or send to the queue. + * Reset a queue back to its original empty state. The return value is now + * obsolete and is always set to pdPASS. */ #define xQueueReset( xQueue ) xQueueGenericReset( xQueue, pdFALSE ) diff --git a/FreeRTOS/Source/include/timers.h b/FreeRTOS/Source/include/timers.h index bed0e5c2a..60f394f59 100644 --- a/FreeRTOS/Source/include/timers.h +++ b/FreeRTOS/Source/include/timers.h @@ -265,11 +265,11 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi * 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. + * xTimerCreated() that was used to create the timer, and by calling the + * vTimerSetTimerID() API function. * * If the same callback function is assigned to multiple timers then the timer - * ID can be used within the callback function to identify which timer actually - * expired. + * ID can be used as time specific (timer local) storage. * * @param xTimer The timer being queried. * @@ -281,6 +281,27 @@ TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTi */ void *pvTimerGetTimerID( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; +/** + * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); + * + * Sets 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. + * + * If the same callback function is assigned to multiple timers then the timer + * ID can be used as time specific (timer local) storage. + * + * @param xTimer The timer being updated. + * + * @param pvNewID The ID to assign to the timer. + * + * Example usage: + * + * See the xTimerCreate() API function example usage scenario. + */ +void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; + /** * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); * diff --git a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h index ec6422a8b..ab6d656e1 100644 --- a/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h +++ b/FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portmacro.h @@ -115,7 +115,7 @@ typedef unsigned short UBaseType_t; /* Critical section management. */ #define portINTERRUPT_BITS ( ( uint16_t ) configKERNEL_INTERRUPT_PRIORITY << ( uint16_t ) 5 ) -#define portDISABLE_INTERRUPTS() SR |= portINTERRUPT_BITS +#define portDISABLE_INTERRUPTS() SR |= portINTERRUPT_BITS; __asm volatile ( "NOP" ) #define portENABLE_INTERRUPTS() SR &= ~portINTERRUPT_BITS /* Note that exiting a critical sectino will set the IPL bits to 0, nomatter diff --git a/FreeRTOS/Source/portable/MSVC-MingW/port.c b/FreeRTOS/Source/portable/MSVC-MingW/port.c index 04311a6a7..056407213 100644 --- a/FreeRTOS/Source/portable/MSVC-MingW/port.c +++ b/FreeRTOS/Source/portable/MSVC-MingW/port.c @@ -322,7 +322,7 @@ xThreadState *pxThreadState; /* Start the highest priority task by obtaining its associated thread state structure, in which is stored the thread handle. */ - pxThreadState = ( xThreadState * ) *( ( uint32_t * ) pxCurrentTCB ); + pxThreadState = ( xThreadState * ) *( ( size_t * ) pxCurrentTCB ); ulCriticalNesting = portNO_CRITICAL_NESTING; /* Bump up the priority of the thread that is going to run, in the @@ -422,12 +422,12 @@ void *pvObjectList[ 2 ]; if( pvOldCurrentTCB != pxCurrentTCB ) { /* Suspend the old thread. */ - pxThreadState = ( xThreadState *) *( ( uint32_t * ) pvOldCurrentTCB ); + pxThreadState = ( xThreadState *) *( ( size_t * ) pvOldCurrentTCB ); SuspendThread( pxThreadState->pvThread ); /* Obtain the state of the task now selected to enter the Running state. */ - pxThreadState = ( xThreadState * ) ( *( uint32_t *) pxCurrentTCB ); + pxThreadState = ( xThreadState * ) ( *( size_t *) pxCurrentTCB ); ResumeThread( pxThreadState->pvThread ); } } @@ -446,7 +446,7 @@ uint32_t ulErrorCode; ( void ) ulErrorCode; /* Find the handle of the thread being deleted. */ - pxThreadState = ( xThreadState * ) ( *( uint32_t *) pvTaskToDelete ); + pxThreadState = ( xThreadState * ) ( *( size_t *) pvTaskToDelete ); /* Check that the thread is still valid, it might have been closed by vPortCloseRunningThread() - which will be the case if the task associated @@ -477,7 +477,7 @@ uint32_t ulErrorCode; ( void ) ulErrorCode; /* Find the handle of the thread being deleted. */ - pxThreadState = ( xThreadState * ) ( *( uint32_t *) pvTaskToDelete ); + pxThreadState = ( xThreadState * ) ( *( size_t *) pvTaskToDelete ); pvThread = pxThreadState->pvThread; /* Raise the Windows priority of the thread to ensure the FreeRTOS scheduler diff --git a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h index af52798c7..3666c03ea 100644 --- a/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h +++ b/FreeRTOS/Source/portable/MSVC-MingW/portmacro.h @@ -81,8 +81,9 @@ #define portDOUBLE double #define portLONG long #define portSHORT short -#define portSTACK_TYPE uint32_t +#define portSTACK_TYPE size_t #define portBASE_TYPE long +#define portPOINTER_SIZE_TYPE size_t typedef portSTACK_TYPE StackType_t; typedef long BaseType_t; @@ -96,15 +97,21 @@ typedef unsigned long UBaseType_t; typedef uint32_t TickType_t; #define portMAX_DELAY ( TickType_t ) 0xffffffffUL - /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do - not need to be guarded with a critical section. */ + /* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick + count do not need to be guarded with a critical section. */ #define portTICK_TYPE_IS_ATOMIC 1 #endif /* Hardware specifics. */ #define portSTACK_GROWTH ( -1 ) #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portBYTE_ALIGNMENT 4 + + +#if defined( __x86_64_ _) || defined( _M_X64 ) + #define portBYTE_ALIGNMENT 8 +#else + #define portBYTE_ALIGNMENT 4 +#endif #define portYIELD() vPortGenerateSimulatedInterrupt( portINTERRUPT_YIELD ) @@ -186,3 +193,4 @@ void vPortGenerateSimulatedInterrupt( uint32_t ulInterruptNumber ); void vPortSetInterruptHandler( uint32_t ulInterruptNumber, uint32_t (*pvHandler)( void ) ); #endif + diff --git a/FreeRTOS/Source/portable/MemMang/heap_1.c b/FreeRTOS/Source/portable/MemMang/heap_1.c index 5223dcbc1..195736c60 100644 --- a/FreeRTOS/Source/portable/MemMang/heap_1.c +++ b/FreeRTOS/Source/portable/MemMang/heap_1.c @@ -115,7 +115,7 @@ static uint8_t *pucAlignedHeap = NULL; if( pucAlignedHeap == NULL ) { /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) ); + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); } /* Check there is enough room left for the allocation. */ diff --git a/FreeRTOS/Source/portable/MemMang/heap_2.c b/FreeRTOS/Source/portable/MemMang/heap_2.c index 4860a99ee..6bddc6cd6 100644 --- a/FreeRTOS/Source/portable/MemMang/heap_2.c +++ b/FreeRTOS/Source/portable/MemMang/heap_2.c @@ -283,7 +283,7 @@ BlockLink_t *pxFirstFreeBlock; uint8_t *pucAlignedHeap; /* Ensure the heap starts on a correctly aligned boundary. */ - pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) ); + pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /* xStart is used to hold a pointer to the first item in the list of free blocks. The void cast is used to prevent compiler warnings. */ diff --git a/FreeRTOS/Source/queue.c b/FreeRTOS/Source/queue.c index d04d81fe8..27d3edd6a 100644 --- a/FreeRTOS/Source/queue.c +++ b/FreeRTOS/Source/queue.c @@ -633,10 +633,10 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { taskENTER_CRITICAL(); { - /* Is there room on the queue now? The running task must be - the highest priority task wanting to access the queue. If - the head item in the queue is to be overwritten then it does - not matter if the queue is full. */ + /* Is there room on the queue now? The running task must be the + highest priority task wanting to access the queue. If the head item + in the queue is to be overwritten then it does not matter if the + queue is full. */ if( ( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) || ( xCopyPosition == queueOVERWRITE ) ) { traceQUEUE_SEND( pxQueue ); @@ -1092,11 +1092,11 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; { traceQUEUE_SEND_FROM_ISR( pxQueue ); - /* A task can only have an inherited priority if it is a mutex - holder - and if there is a mutex holder then the mutex cannot be - given from an ISR. Therefore, unlike the xQueueGenericGive() - function, there is no need to determine the need for priority - disinheritance here or to clear the mutex holder TCB member. */ + /* Semaphores use xQueueGiveFromISR(), so pxQueue will not be a + semaphore or mutex. That means prvCopyDataToQueue() cannot result + in a task disinheriting a priority and prvCopyDataToQueue() can be + called here even though the disinherit function does not check if + the scheduler is suspended before accessing the ready lists. */ ( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition ); /* The event list is not altered if the queue is locked. This will @@ -1210,11 +1210,23 @@ BaseType_t xReturn; UBaseType_t uxSavedInterruptStatus; Queue_t * const pxQueue = ( Queue_t * ) xQueue; + /* Similar to xQueueGenericSendFromISR() but used with semaphores where the + item size is 0. Don't directly wake a task that was blocked on a queue + read, instead return a flag to say whether a context switch is required or + not (i.e. has a task with a higher priority than us been woken by this + post). */ + configASSERT( pxQueue ); - /* xQueueGenericSendFromISR() should be used in the item size is not 0. */ + /* xQueueGenericSendFromISR() should be used instead of xQueueGiveFromISR() + if the item size is not 0. */ configASSERT( pxQueue->uxItemSize == 0 ); + /* Normally a mutex would not be given from an interrupt, and doing so is + definitely wrong if there is a mutex holder as priority inheritance makes no + sense for an interrupts, only tasks. */ + configASSERT( !( ( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) && ( pxQueue->pxMutexHolder != NULL ) ) ); + /* RTOS ports that support interrupt nesting have the concept of a maximum system call (or maximum API call) interrupt priority. Interrupts that are above the maximum system call priority are kept permanently enabled, even @@ -1231,11 +1243,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */ portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); - /* Similar to xQueueGenericSendFromISR() but used with semaphores where the - item size is 0. Don't directly wake a task that was blocked on a queue - read, instead return a flag to say whether a context switch is required or - not (i.e. has a task with a higher priority than us been woken by this - post). */ uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); { /* When the queue is used to implement a semaphore no data is ever @@ -1247,10 +1254,10 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; /* A task can only have an inherited priority if it is a mutex holder - and if there is a mutex holder then the mutex cannot be - given from an ISR. Therefore, unlike the xQueueGenericGive() - function, there is no need to determine the need for priority - disinheritance here or to clear the mutex holder TCB member. */ - + given from an ISR. As this is the ISR version of the function it + can be assumed there is no mutex holder and no need to determine if + priority disinheritance is needed. Simply increase the count of + messages (semaphores) available. */ ++( pxQueue->uxMessagesWaiting ); /* The event list is not altered if the queue is locked. This will @@ -1441,8 +1448,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue; any other tasks waiting for the data. */ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) { - /* Tasks that are removed from the event list will get added to - the pending ready list as the scheduler is still suspended. */ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) { /* The task waiting has a higher priority than this task. */ @@ -2556,6 +2561,7 @@ BaseType_t xReturn; if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength ) { traceQUEUE_SEND( pxQueueSetContainer ); + /* The data copied is the handle of the queue that contains data. */ xReturn = prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition ); diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index bce9973d1..c7b29382d 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -387,7 +387,7 @@ count overflows. */ * the task. It is inserted at the end of the list. */ #define prvAddTaskToReadyList( pxTCB ) \ - traceMOVED_TASK_TO_READY_STATE( pxTCB ) \ + traceMOVED_TASK_TO_READY_STATE( pxTCB ); \ taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority ); \ vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) ) /*-----------------------------------------------------------*/ @@ -598,7 +598,7 @@ StackType_t *pxTopOfStack; #if( portSTACK_GROWTH < 0 ) { pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 ); - pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */ + pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */ /* Check the alignment of the calculated top of stack is correct. */ configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) ); @@ -2395,7 +2395,7 @@ TickType_t xTimeToWake; /* 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 designed for use by kernel code, and has special calling requirements - - it should be called from a critical section. */ + it should be called with the scheduler suspended. */ /* Place the event list item of the TCB in the appropriate event list. @@ -2406,7 +2406,8 @@ TickType_t xTimeToWake; /* We must remove this task from the ready list before adding it to the blocked list as the same list item is used for both lists. This - function is called form a critical section. */ + function is called with the scheduler locked so interrupts will not + access the lists at the same time. */ if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) { /* The current task must be in a ready list, so there is no need to @@ -3394,6 +3395,9 @@ TCB_t *pxTCB; locked then the mutex holder might now be NULL. */ if( pxMutexHolder != NULL ) { + /* If the holder of the mutex has a priority below the priority of + the task attempting to obtain the mutex then it will temporarily + inherit the priority of the task attempting to obtain the mutex. */ if( pxTCB->uxPriority < pxCurrentTCB->uxPriority ) { /* Adjust the mutex holder state to account for its new @@ -3408,8 +3412,8 @@ TCB_t *pxTCB; mtCOVERAGE_TEST_MARKER(); } - /* If the task being modified is in the ready state it will need to - be moved into a new list. */ + /* If the task being modified is in the ready state it will need + to be moved into a new list. */ if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE ) { if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 ) @@ -3456,15 +3460,23 @@ TCB_t *pxTCB; if( pxMutexHolder != NULL ) { + /* A task can only have an inherited priority if it holds the mutex. + If the mutex is held by a task then it cannot be given from an + interrupt, and if a mutex is given by the holding task then it must + be the running state task. */ + configASSERT( pxTCB == pxCurrentTCB ); + configASSERT( pxTCB->uxMutexesHeld ); ( pxTCB->uxMutexesHeld )--; + /* Has the holder of the mutex inherited the priority of another + task? */ if( pxTCB->uxPriority != pxTCB->uxBasePriority ) { /* Only disinherit if no other mutexes are held. */ if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) { - /* A task can only have an inhertied priority if it holds + /* A task can only have an inherited priority if it holds the mutex. If the mutex is held by a task then it cannot be given from an interrupt, and if a mutex is given by the holding task then it must be the running state task. Remove diff --git a/FreeRTOS/Source/timers.c b/FreeRTOS/Source/timers.c index 11b33dbd5..b270488bc 100644 --- a/FreeRTOS/Source/timers.c +++ b/FreeRTOS/Source/timers.c @@ -827,8 +827,31 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer; void *pvTimerGetTimerID( const TimerHandle_t xTimer ) { Timer_t * const pxTimer = ( Timer_t * ) xTimer; +void *pvReturn; - return pxTimer->pvTimerID; + configASSERT( xTimer ); + + taskENTER_CRITICAL(); + { + pvReturn = pxTimer->pvTimerID; + } + taskEXIT_CRITICAL(); + + return pvReturn; +} +/*-----------------------------------------------------------*/ + +void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID ) +{ +Timer_t * const pxTimer = ( Timer_t * ) xTimer; + + configASSERT( xTimer ); + + taskENTER_CRITICAL(); + { + pxTimer->pvTimerID = pvNewID; + } + taskEXIT_CRITICAL(); } /*-----------------------------------------------------------*/