#error Missing definition: configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
-#ifndef INCLUDE_vTaskPrioritySet\r
- #error Missing definition: INCLUDE_vTaskPrioritySet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
-#endif\r
-\r
-#ifndef INCLUDE_uxTaskPriorityGet\r
- #error Missing definition: INCLUDE_uxTaskPriorityGet must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
-#endif\r
-\r
-#ifndef INCLUDE_vTaskDelete\r
- #error Missing definition: INCLUDE_vTaskDelete must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configUSE_16_BIT_TICKS\r
+ #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
#endif\r
\r
-#ifndef INCLUDE_vTaskSuspend\r
- #error Missing definition: INCLUDE_vTaskSuspend must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configMAX_PRIORITIES\r
+ #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
#endif\r
\r
-#ifndef INCLUDE_vTaskDelayUntil\r
- #error Missing definition: INCLUDE_vTaskDelayUntil must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configUSE_CO_ROUTINES\r
+ #define configUSE_CO_ROUTINES 0\r
#endif\r
\r
-#ifndef INCLUDE_vTaskDelay\r
- #error Missing definition: INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef INCLUDE_vTaskPrioritySet\r
+ #define INCLUDE_vTaskPrioritySet 0\r
#endif\r
\r
-#ifndef configUSE_16_BIT_TICKS\r
- #error Missing definition: configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0. See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef INCLUDE_uxTaskPriorityGet\r
+ #define INCLUDE_uxTaskPriorityGet 0\r
#endif\r
\r
-#ifndef configMAX_PRIORITIES\r
- #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
+#ifndef INCLUDE_vTaskDelete\r
+ #define INCLUDE_vTaskDelete 0\r
#endif\r
\r
-#ifndef configUSE_CO_ROUTINES\r
- #define configUSE_CO_ROUTINES 0\r
+#ifndef INCLUDE_vTaskSuspend\r
+ #define INCLUDE_vTaskSuspend 0\r
#endif\r
\r
-#if configUSE_CO_ROUTINES != 0\r
- #ifndef configMAX_CO_ROUTINE_PRIORITIES\r
- #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.\r
- #endif\r
+#ifndef INCLUDE_vTaskDelayUntil\r
+ #define INCLUDE_vTaskDelayUntil 0\r
#endif\r
\r
-#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK\r
- #define configUSE_DAEMON_TASK_STARTUP_HOOK 0\r
+#ifndef INCLUDE_vTaskDelay\r
+ #define INCLUDE_vTaskDelay 0\r
#endif\r
\r
#ifndef INCLUDE_xTaskGetIdleTaskHandle\r
#define INCLUDE_xTaskGetIdleTaskHandle 0\r
#endif\r
\r
+#ifndef INCLUDE_xTaskAbortDelay\r
+ #define INCLUDE_xTaskAbortDelay 0\r
+#endif\r
+\r
#ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle\r
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 0\r
#endif\r
#define INCLUDE_xTaskGetTaskHandle 0\r
#endif\r
\r
-#ifndef configUSE_APPLICATION_TASK_TAG\r
- #define configUSE_APPLICATION_TASK_TAG 0\r
-#endif\r
-\r
-#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS\r
- #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0\r
-#endif\r
-\r
#ifndef INCLUDE_uxTaskGetStackHighWaterMark\r
#define INCLUDE_uxTaskGetStackHighWaterMark 0\r
#endif\r
#define INCLUDE_eTaskGetState 0\r
#endif\r
\r
+#ifndef INCLUDE_xTaskResumeFromISR\r
+ #define INCLUDE_xTaskResumeFromISR 1\r
+#endif\r
+\r
+#ifndef INCLUDE_xTimerPendFunctionCall\r
+ #define INCLUDE_xTimerPendFunctionCall 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetSchedulerState\r
+ #define INCLUDE_xTaskGetSchedulerState 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
+ #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
+#endif\r
+\r
+#if configUSE_CO_ROUTINES != 0\r
+ #ifndef configMAX_CO_ROUTINE_PRIORITIES\r
+ #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.\r
+ #endif\r
+#endif\r
+\r
+#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK\r
+ #define configUSE_DAEMON_TASK_STARTUP_HOOK 0\r
+#endif\r
+\r
+#ifndef configUSE_APPLICATION_TASK_TAG\r
+ #define configUSE_APPLICATION_TASK_TAG 0\r
+#endif\r
+\r
+#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS\r
+ #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0\r
+#endif\r
+\r
#ifndef configUSE_RECURSIVE_MUTEXES\r
#define configUSE_RECURSIVE_MUTEXES 0\r
#endif\r
#error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h\r
#endif\r
\r
-#ifndef INCLUDE_xTaskResumeFromISR\r
- #define INCLUDE_xTaskResumeFromISR 1\r
-#endif\r
-\r
-#ifndef INCLUDE_xTimerPendFunctionCall\r
- #define INCLUDE_xTimerPendFunctionCall 0\r
-#endif\r
-\r
#ifndef configASSERT\r
#define configASSERT( x )\r
#define configASSERT_DEFINED 0\r
\r
#endif /* configUSE_TIMERS */\r
\r
-#ifndef INCLUDE_xTaskGetSchedulerState\r
- #define INCLUDE_xTaskGetSchedulerState 0\r
-#endif\r
-\r
-#ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
- #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
-#endif\r
-\r
-\r
#ifndef portSET_INTERRUPT_MASK_FROM_ISR\r
#define portSET_INTERRUPT_MASK_FROM_ISR() 0\r
#endif\r
#endif\r
\r
#ifndef traceTASK_DELAY_UNTIL\r
- #define traceTASK_DELAY_UNTIL()\r
+ #define traceTASK_DELAY_UNTIL( x )\r
#endif\r
\r
#ifndef traceTASK_DELAY\r
StaticMiniListItem_t xDummy3;\r
} StaticList_t;\r
\r
-/* For data hiding purposes. */\r
-typedef enum\r
-{\r
- eNothing = 0\r
-} eDummy;\r
-\r
/*\r
* In line with software engineering best practice, especially when supplying a\r
* library that is likely to change in future versions, FreeRTOS implements a\r
#endif\r
#if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
uint32_t ulDummy18;\r
- eDummy eDummy19;\r
+ uint8_t ucDummy19;\r
#endif\r
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r
uint8_t uxDummy20;\r
#define taskSTATICALLY_ALLOCATED_STACK ( ( uint8_t ) 0x01 )\r
#define taskSTATICALLY_ALLOCATED_TCB ( ( uint8_t ) 0x02 )\r
\r
+/* Values that can be assigned to the ucNotifyState member of the TCB. */\r
+#define taskNOT_WAITING_NOTIFICATION ( ( uint8_t ) 0 )\r
+#define taskWAITING_NOTIFICATION ( ( uint8_t ) 1 )\r
+#define taskNOTIFICATION_RECEIVED ( ( uint8_t ) 2 )\r
+\r
/*\r
* Task control block. A task control block (TCB) is allocated for each task,\r
* and stores task state information, including a pointer to the task's context\r
void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];\r
#endif\r
\r
- #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+ #if( configGENERATE_RUN_TIME_STATS == 1 )\r
uint32_t ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */\r
#endif\r
\r
struct _reent xNewLib_reent;\r
#endif\r
\r
- #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+ #if( configUSE_TASK_NOTIFICATIONS == 1 )\r
volatile uint32_t ulNotifiedValue;\r
- volatile eNotifyValue eNotifyState;\r
+ volatile uint8_t ucNotifyState;\r
#endif\r
\r
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r
uint8_t ucStaticAllocationFlags; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */\r
#endif\r
\r
- } tskTCB;\r
+} tskTCB;\r
\r
/* The old tskTCB name is maintained above then typedefed to the new TCB_t name\r
below to enable the use of older kernel aware debuggers. */\r
* The currently executing task is entering the Blocked state. Add the task to\r
* either the current or the overflow delayed task list.\r
*/\r
-static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION;\r
+static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Allocates memory from the heap for a TCB and associated stack. Checks the\r
/* If we want to use stack checking on architectures that use\r
a positive stack growth direction then we also need to store the\r
other extreme of the stack space. */\r
- pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );\r
+ pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 );\r
}\r
#endif /* portSTACK_GROWTH */\r
\r
\r
if( xShouldDelay != pdFALSE )\r
{\r
- traceTASK_DELAY_UNTIL();\r
+ traceTASK_DELAY_UNTIL( xTimeToWake );\r
\r
- /* Remove the task from the ready list before adding it to the\r
- blocked list as the same list item is used for both lists. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is\r
- no need to check, and the port reset macro can be called\r
- directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+ /* prvAddCurrentTaskToDelayedList() needs the block time, not\r
+ the time to wake, so subtract the current tick count. */\r
+ prvAddCurrentTaskToDelayedList( xTimeToWake - xConstTickCount, pdFALSE );\r
}\r
else\r
{\r
\r
void vTaskDelay( const TickType_t xTicksToDelay )\r
{\r
- TickType_t xTimeToWake;\r
BaseType_t xAlreadyYielded = pdFALSE;\r
\r
-\r
/* A delay time of zero just forces a reschedule. */\r
if( xTicksToDelay > ( TickType_t ) 0U )\r
{\r
\r
This task cannot be in an event list as it is the currently\r
executing task. */\r
-\r
- /* Calculate the time to wake - this may overflow but this is\r
- not a problem. */\r
- xTimeToWake = xTickCount + xTicksToDelay;\r
-\r
- /* We must remove ourselves from the ready list before adding\r
- ourselves to the blocked list as the same list item is used for\r
- both lists. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is\r
- no need to check, and the port reset macro can be called\r
- directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+ prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE );\r
}\r
xAlreadyYielded = xTaskResumeAll();\r
}\r
\r
void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait )\r
{\r
-TickType_t xTimeToWake;\r
-\r
configASSERT( pxEventList );\r
\r
/* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE\r
list is locked, preventing simultaneous access from interrupts. */\r
vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
\r
- /* The task must be removed from from the ready list before it is added to\r
- the blocked list as the same list item is used for both lists. Exclusive\r
- access to the ready lists guaranteed because the scheduler is locked. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is no need to\r
- check, and the port reset macro can be called directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- #if ( INCLUDE_vTaskSuspend == 1 )\r
- {\r
- if( xTicksToWait == portMAX_DELAY )\r
- {\r
- /* Add the task to the suspended task list instead of a delayed task\r
- list to ensure the task is not woken by a timing event. It will\r
- block indefinitely. */\r
- vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* Calculate the time at which the task should be woken if the event\r
- does not occur. This may overflow but this doesn't matter, the\r
- scheduler will handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- }\r
- #else /* INCLUDE_vTaskSuspend */\r
- {\r
- /* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter, the scheduler\r
- will handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- #endif /* INCLUDE_vTaskSuspend */\r
+ prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait )\r
{\r
-TickType_t xTimeToWake;\r
-\r
configASSERT( pxEventList );\r
\r
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by\r
the task level). */\r
vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
\r
- /* The task must be removed from the ready list before it is added to the\r
- blocked list. Exclusive access can be assured to the ready list as the\r
- scheduler is locked. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is no need to\r
- check, and the port reset macro can be called directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- #if ( INCLUDE_vTaskSuspend == 1 )\r
- {\r
- if( xTicksToWait == portMAX_DELAY )\r
- {\r
- /* Add the task to the suspended task list instead of a delayed task\r
- list to ensure it is not woken by a timing event. It will block\r
- indefinitely. */\r
- vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* Calculate the time at which the task should be woken if the event\r
- does not occur. This may overflow but this doesn't matter, the\r
- kernel will manage it correctly. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- }\r
- #else /* INCLUDE_vTaskSuspend */\r
- {\r
- /* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter, the kernel\r
- will manage it correctly. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- #endif /* INCLUDE_vTaskSuspend */\r
+ prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
}\r
/*-----------------------------------------------------------*/\r
\r
-#if configUSE_TIMERS == 1\r
+#if( configUSE_TIMERS == 1 )\r
\r
- void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
+ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
{\r
- TickType_t xTimeToWake;\r
-\r
configASSERT( pxEventList );\r
\r
/* This function should not be called by application code hence the\r
can be used in place of vListInsert. */\r
vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
\r
- /* We must remove this task from the ready list before adding it to the\r
- blocked list as the same list item is used for both lists. This\r
- function is called with the scheduler locked so interrupts will not\r
- access the lists at the same time. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is no need to\r
- check, and the port reset macro can be called directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- /* If vTaskSuspend() is available then the suspended task list is also\r
- available and a task that is blocking indefinitely can enter the\r
- suspended state (it is not really suspended as it will re-enter the\r
- Ready state when the event it is waiting indefinitely for occurs).\r
- Blocking indefinitely is useful when using tickless idle mode as when\r
- all tasks are blocked indefinitely all timers can be turned off. */\r
- #if( INCLUDE_vTaskSuspend == 1 )\r
+ /* If the task should block indefinitely then set the block time to a\r
+ value that will be recognised as an indefinite delay inside the\r
+ prvAddCurrentTaskToDelayedList() function. */\r
+ if( xWaitIndefinitely == pdTRUE )\r
{\r
- if( xWaitIndefinitely == pdTRUE )\r
- {\r
- /* Add the task to the suspended task list instead of a delayed\r
- task list to ensure the task is not woken by a timing event. It\r
- will block indefinitely. */\r
- vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* Calculate the time at which the task should be woken if the\r
- event does not occur. This may overflow but this doesn't\r
- matter. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- traceTASK_DELAY_UNTIL();\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
+ xTicksToWait = portMAX_DELAY;\r
}\r
- #else\r
- {\r
- /* Calculate the time at which the task should be woken if the event\r
- does not occur. This may overflow but this doesn't matter. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- traceTASK_DELAY_UNTIL();\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
\r
- /* Remove compiler warnings when INCLUDE_vTaskSuspend() is not\r
- defined. */\r
- ( void ) xWaitIndefinitely;\r
- }\r
- #endif\r
+ traceTASK_DELAY_UNTIL( ( xTickCount + xTicksToWait ) );\r
+ prvAddCurrentTaskToDelayedList( xTicksToWait, xWaitIndefinitely );\r
}\r
\r
#endif /* configUSE_TIMERS */\r
const TickType_t xConstTickCount = xTickCount;\r
\r
#if ( INCLUDE_vTaskSuspend == 1 )\r
- /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
- the maximum block time then the task should block indefinitely, and\r
- therefore never time out. */\r
+ /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified\r
+ is the maximum block time then the task should block indefinitely,\r
+ and therefore never time out. */\r
if( *pxTicksToWait == portMAX_DELAY )\r
{\r
xReturn = pdFALSE;\r
\r
if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */\r
{\r
- /* The tick count is greater than the time at which vTaskSetTimeout()\r
- was called, but has also overflowed since vTaskSetTimeOut() was called.\r
- It must have wrapped all the way around and gone past us again. This\r
- passed since vTaskSetTimeout() was called. */\r
+ /* The tick count is greater than the time at which\r
+ vTaskSetTimeout() was called, but has also overflowed since\r
+ vTaskSetTimeOut() was called. It must have wrapped all the way\r
+ around and gone past again. This passed since vTaskSetTimeout()\r
+ was called. */\r
xReturn = pdTRUE;\r
}\r
- else if( ( xConstTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait )\r
+ else if( ( ( TickType_t ) ( xConstTickCount - pxTimeOut->xTimeOnEntering ) ) < *pxTicksToWait )\r
{\r
/* Not a genuine timeout. Adjust parameters for time remaining. */\r
- *pxTicksToWait -= ( xConstTickCount - pxTimeOut->xTimeOnEntering );\r
+ *pxTicksToWait -= ( xConstTickCount - pxTimeOut->xTimeOnEntering );\r
vTaskSetTimeOutState( pxTimeOut );\r
xReturn = pdFALSE;\r
}\r
#if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
{\r
pxTCB->ulNotifiedValue = 0;\r
- pxTCB->eNotifyState = eNotWaitingNotification;\r
+ pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
}\r
#endif\r
\r
/* Initialise this task's Newlib reent structure. */\r
_REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) );\r
}\r
- #endif /* configUSE_NEWLIB_REENTRANT */\r
+ #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake )\r
-{\r
- /* The list item will be inserted in wake time order. */\r
- listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
-\r
- if( xTimeToWake < xTickCount )\r
- {\r
- /* Wake time has overflowed. Place this item in the overflow list. */\r
- vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* The wake time has not overflowed, so the current block list is used. */\r
- vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
-\r
- /* If the task entering the blocked state was placed at the head of the\r
- list of blocked tasks then xNextTaskUnblockTime needs to be updated\r
- too. */\r
- if( xTimeToWake < xNextTaskUnblockTime )\r
- {\r
- xNextTaskUnblockTime = xTimeToWake;\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer, TCB_t * const pxTaskBuffer )\r
{\r
TCB_t *pxNewTCB;\r
\r
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )\r
{\r
- TickType_t xTimeToWake;\r
uint32_t ulReturn;\r
\r
taskENTER_CRITICAL();\r
if( pxCurrentTCB->ulNotifiedValue == 0UL )\r
{\r
/* Mark this task as waiting for a notification. */\r
- pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+ pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;\r
\r
if( xTicksToWait > ( TickType_t ) 0 )\r
{\r
- /* The task is going to block. First it must be removed\r
- from the ready list. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is\r
- no need to check, and the port reset macro can be called\r
- directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- #if ( INCLUDE_vTaskSuspend == 1 )\r
- {\r
- if( xTicksToWait == portMAX_DELAY )\r
- {\r
- /* Add the task to the suspended task list instead\r
- of a delayed task list to ensure the task is not\r
- woken by a timing event. It will block\r
- indefinitely. */\r
- vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* Calculate the time at which the task should be\r
- woken if no notification events occur. This may\r
- overflow but this doesn't matter, the scheduler will\r
- handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- }\r
- #else /* INCLUDE_vTaskSuspend */\r
- {\r
- /* Calculate the time at which the task should be\r
- woken if the event does not occur. This may\r
- overflow but this doesn't matter, the scheduler will\r
- handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- #endif /* INCLUDE_vTaskSuspend */\r
-\r
+ prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
traceTASK_NOTIFY_TAKE_BLOCK();\r
\r
/* All ports are written to allow a yield in a critical\r
mtCOVERAGE_TEST_MARKER();\r
}\r
\r
- pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+ pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
}\r
taskEXIT_CRITICAL();\r
\r
\r
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )\r
{\r
- TickType_t xTimeToWake;\r
BaseType_t xReturn;\r
\r
taskENTER_CRITICAL();\r
{\r
/* Only block if a notification is not already pending. */\r
- if( pxCurrentTCB->eNotifyState != eNotified )\r
+ if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED )\r
{\r
/* Clear bits in the task's notification value as bits may get\r
set by the notifying task or interrupt. This can be used to\r
pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry;\r
\r
/* Mark this task as waiting for a notification. */\r
- pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+ pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;\r
\r
if( xTicksToWait > ( TickType_t ) 0 )\r
{\r
- /* The task is going to block. First it must be removed\r
- from the ready list. */\r
- if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
- {\r
- /* The current task must be in a ready list, so there is\r
- no need to check, and the port reset macro can be called\r
- directly. */\r
- portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
-\r
- #if ( INCLUDE_vTaskSuspend == 1 )\r
- {\r
- if( xTicksToWait == portMAX_DELAY )\r
- {\r
- /* Add the task to the suspended task list instead\r
- of a delayed task list to ensure the task is not\r
- woken by a timing event. It will block\r
- indefinitely. */\r
- vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
- }\r
- else\r
- {\r
- /* Calculate the time at which the task should be\r
- woken if no notification events occur. This may\r
- overflow but this doesn't matter, the scheduler will\r
- handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- }\r
- #else /* INCLUDE_vTaskSuspend */\r
- {\r
- /* Calculate the time at which the task should be\r
- woken if the event does not occur. This may\r
- overflow but this doesn't matter, the scheduler will\r
- handle it. */\r
- xTimeToWake = xTickCount + xTicksToWait;\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
- }\r
- #endif /* INCLUDE_vTaskSuspend */\r
-\r
+ prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
traceTASK_NOTIFY_WAIT_BLOCK();\r
\r
/* All ports are written to allow a yield in a critical\r
*pulNotificationValue = pxCurrentTCB->ulNotifiedValue;\r
}\r
\r
- /* If eNotifyValue is set then either the task never entered the\r
+ /* If ucNotifyValue is set then either the task never entered the\r
blocked state (because a notification was already pending) or the\r
task unblocked because of a notification. Otherwise the task\r
unblocked because of a timeout. */\r
- if( pxCurrentTCB->eNotifyState == eWaitingNotification )\r
+ if( pxCurrentTCB->ucNotifyState == taskWAITING_NOTIFICATION )\r
{\r
/* A notification was not received. */\r
xReturn = pdFALSE;\r
xReturn = pdTRUE;\r
}\r
\r
- pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+ pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
}\r
taskEXIT_CRITICAL();\r
\r
BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )\r
{\r
TCB_t * pxTCB;\r
- eNotifyValue eOriginalNotifyState;\r
BaseType_t xReturn = pdPASS;\r
+ uint8_t ucOriginalNotifyState;\r
\r
configASSERT( xTaskToNotify );\r
pxTCB = ( TCB_t * ) xTaskToNotify;\r
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
}\r
\r
- eOriginalNotifyState = pxTCB->eNotifyState;\r
+ ucOriginalNotifyState = pxTCB->ucNotifyState;\r
\r
- pxTCB->eNotifyState = eNotified;\r
+ pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
\r
switch( eAction )\r
{\r
break;\r
\r
case eSetValueWithoutOverwrite :\r
- if( eOriginalNotifyState != eNotified )\r
+ if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )\r
{\r
pxTCB->ulNotifiedValue = ulValue;\r
}\r
\r
/* If the task is in the blocked state specifically to wait for a\r
notification then unblock it now. */\r
- if( eOriginalNotifyState == eWaitingNotification )\r
+ if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
{\r
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
prvAddTaskToReadyList( pxTCB );\r
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken )\r
{\r
TCB_t * pxTCB;\r
- eNotifyValue eOriginalNotifyState;\r
+ uint8_t ucOriginalNotifyState;\r
BaseType_t xReturn = pdPASS;\r
UBaseType_t uxSavedInterruptStatus;\r
\r
*pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
}\r
\r
- eOriginalNotifyState = pxTCB->eNotifyState;\r
- pxTCB->eNotifyState = eNotified;\r
+ ucOriginalNotifyState = pxTCB->ucNotifyState;\r
+ pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
\r
switch( eAction )\r
{\r
break;\r
\r
case eSetValueWithoutOverwrite :\r
- if( eOriginalNotifyState != eNotified )\r
+ if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )\r
{\r
pxTCB->ulNotifiedValue = ulValue;\r
}\r
\r
/* If the task is in the blocked state specifically to wait for a\r
notification then unblock it now. */\r
- if( eOriginalNotifyState == eWaitingNotification )\r
+ if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
{\r
/* The task should not have been on an event list. */\r
configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken )\r
{\r
TCB_t * pxTCB;\r
- eNotifyValue eOriginalNotifyState;\r
+ uint8_t ucOriginalNotifyState;\r
UBaseType_t uxSavedInterruptStatus;\r
\r
configASSERT( xTaskToNotify );\r
\r
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- eOriginalNotifyState = pxTCB->eNotifyState;\r
- pxTCB->eNotifyState = eNotified;\r
+ ucOriginalNotifyState = pxTCB->ucNotifyState;\r
+ pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
\r
/* 'Giving' is equivalent to incrementing a count in a counting\r
semaphore. */\r
\r
/* If the task is in the blocked state specifically to wait for a\r
notification then unblock it now. */\r
- if( eOriginalNotifyState == eWaitingNotification )\r
+ if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
{\r
/* The task should not have been on an event list. */\r
configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
\r
taskENTER_CRITICAL();\r
{\r
- if( pxTCB->eNotifyState == eNotified )\r
+ if( pxTCB->ucNotifyState == taskNOTIFICATION_RECEIVED )\r
{\r
- pxTCB->eNotifyState = eNotWaitingNotification;\r
+ pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
xReturn = pdPASS;\r
}\r
else\r
/*-----------------------------------------------------------*/\r
\r
\r
+static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, BaseType_t xCanBlockIndefinitely )\r
+{\r
+TickType_t xTimeToWake;\r
+\r
+ /* Remove the task from the ready list before adding it to the blocked list\r
+ as the same list item is used for both lists. */\r
+ if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+ {\r
+ /* The current task must be in a ready list, so there is no need to\r
+ check, and the port reset macro can be called directly. */\r
+ portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+\r
+\r
+ #if ( INCLUDE_vTaskSuspend == 1 )\r
+ {\r
+ if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) )\r
+ {\r
+ /* Add the task to the suspended task list instead of a delayed task\r
+ list to ensure it is not woken by a timing event. It will block\r
+ indefinitely. */\r
+ vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+ }\r
+ else\r
+ {\r
+ /* Calculate the time at which the task should be woken if the event\r
+ does not occur. This may overflow but this doesn't matter, the\r
+ kernel will manage it correctly. */\r
+ xTimeToWake = xTickCount + xTicksToWait;\r
+\r
+ /* The list item will be inserted in wake time order. */\r
+ listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
+\r
+ if( xTimeToWake < xTickCount )\r
+ {\r
+ /* Wake time has overflowed. Place this item in the overflow\r
+ list. */\r
+ vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+ }\r
+ else\r
+ {\r
+ /* The wake time has not overflowed, so the current block list\r
+ is used. */\r
+ vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+\r
+ /* If the task entering the blocked state was placed at the\r
+ head of the list of blocked tasks then xNextTaskUnblockTime\r
+ needs to be updated too. */\r
+ if( xTimeToWake < xNextTaskUnblockTime )\r
+ {\r
+ xNextTaskUnblockTime = xTimeToWake;\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ #else /* INCLUDE_vTaskSuspend */\r
+ {\r
+ /* Calculate the time at which the task should be woken if the event\r
+ does not occur. This may overflow but this doesn't matter, the kernel\r
+ will manage it correctly. */\r
+ xTimeToWake = xTickCount + xTicksToWait;\r
+\r
+ /* The list item will be inserted in wake time order. */\r
+ listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
+\r
+ if( xTimeToWake < xTickCount )\r
+ {\r
+ /* Wake time has overflowed. Place this item in the overflow list. */\r
+ vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+ }\r
+ else\r
+ {\r
+ /* The wake time has not overflowed, so the current block list is used. */\r
+ vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+\r
+ /* If the task entering the blocked state was placed at the head of the\r
+ list of blocked tasks then xNextTaskUnblockTime needs to be updated\r
+ too. */\r
+ if( xTimeToWake < xNextTaskUnblockTime )\r
+ {\r
+ xNextTaskUnblockTime = xTimeToWake;\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+\r
+ /* Avoid compiler warning when INCLUDE_vTaskSuspend is not 1. */\r
+ ( void ) xCanBlockIndefinitely;\r
+ }\r
+ #endif /* INCLUDE_vTaskSuspend */\r
+}\r
+\r
+\r
#ifdef FREERTOS_MODULE_TEST\r
#include "tasks_test_access_functions.h"\r
#endif\r