| 1054 | #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) |
| 1055 | |
| 1056 | TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, |
| 1057 | const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ |
| 1058 | const uint32_t ulStackDepth, |
| 1059 | void * const pvParameters, |
| 1060 | UBaseType_t uxPriority, |
| 1061 | StackType_t * const puxStackBuffer, |
| 1062 | StaticTask_t * const pxTaskBuffer ) |
| 1063 | { |
| 1064 | TCB_t * pxNewTCB; |
| 1065 | TaskHandle_t xReturn; |
| 1066 | |
| 1067 | configASSERT( puxStackBuffer != NULL ); |
| 1068 | configASSERT( pxTaskBuffer != NULL ); |
| 1069 | |
| 1070 | #if ( configASSERT_DEFINED == 1 ) |
| 1071 | { |
| 1072 | /* Sanity check that the size of the structure used to declare a |
| 1073 | * variable of type StaticTask_t equals the size of the real task |
| 1074 | * structure. */ |
| 1075 | volatile size_t xSize = sizeof( StaticTask_t ); |
| 1076 | configASSERT( xSize == sizeof( TCB_t ) ); |
| 1077 | ( void ) xSize; /* Prevent lint warning when configASSERT() is not used. */ |
| 1078 | } |
| 1079 | #endif /* configASSERT_DEFINED */ |
| 1080 | |
| 1081 | if( ( pxTaskBuffer != NULL ) && ( puxStackBuffer != NULL ) ) |
| 1082 | { |
| 1083 | /* The memory used for the task's TCB and stack are passed into this |
| 1084 | * function - use them. */ |
| 1085 | pxNewTCB = ( TCB_t * ) pxTaskBuffer; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ |
| 1086 | pxNewTCB->pxStack = ( StackType_t * ) puxStackBuffer; |
| 1087 | |
| 1088 | #if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */ |
| 1089 | { |
| 1090 | /* Tasks can be created statically or dynamically, so note this |
| 1091 | * task was created statically in case the task is later deleted. */ |
| 1092 | pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_AND_TCB; |
| 1093 | } |
| 1094 | #endif /* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE */ |
| 1095 | |
| 1096 | prvInitialiseNewTask( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, &xReturn, pxNewTCB, NULL ); |
| 1097 | prvAddNewTaskToReadyList( pxNewTCB ); |
| 1098 | } |
| 1099 | else |
| 1100 | { |
| 1101 | xReturn = NULL; |
| 1102 | } |
| 1103 | |
| 1104 | return xReturn; |
| 1105 | } |
| 1106 | |
| 1107 | #endif /* SUPPORT_STATIC_ALLOCATION */ |
| 1108 | /*-----------------------------------------------------------*/ |
no test coverage detected