⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tasks.s43

📁 MSP430 IAR project with FreeRTOS port.
💻 S43
📖 第 1 页 / 共 5 页
字号:
//  166 
//  167 /*
//  168  * Default a definitions for backwards compatibility with old
//  169  * portmacro.h files.
//  170  */
//  171 #ifndef configMAX_TASK_NAME_LEN
//  172 	#define configMAX_TASK_NAME_LEN 16
//  173 #endif
//  174 
//  175 #ifndef INCLUDE_xTaskGetCurrentTaskHandle
//  176 	#define INCLUDE_xTaskGetCurrentTaskHandle 0
//  177 #endif
//  178 
//  179 #ifndef configIDLE_SHOULD_YIELD
//  180 	#define configIDLE_SHOULD_YIELD		1
//  181 #endif
//  182 
//  183 #if configMAX_TASK_NAME_LEN < 1
//  184 	#undef configMAX_TASK_NAME_LEN
//  185 	#define configMAX_TASK_NAME_LEN 1
//  186 #endif
//  187 
//  188 
//  189 /*
//  190  * Task control block.  A task control block (TCB) is allocated to each task,
//  191  * and stores the context of the task.
//  192  */
//  193 typedef struct tskTaskControlBlock
//  194 {
//  195 	volatile portSTACK_TYPE	*pxTopOfStack;		/*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE STRUCT. */
//  196 	xListItem				xGenericListItem;	/*< List item used to place the TCB in ready and blocked queues. */
//  197 	xListItem				xEventListItem;		/*< List item used to place the TCB in event lists. */
//  198 	unsigned portBASE_TYPE	uxPriority;			/*< The priority of the task where 0 is the lowest priority. */
//  199 	portSTACK_TYPE			*pxStack;			/*< Points to the start of the stack. */
//  200 	unsigned portBASE_TYPE	uxTCBNumber;		/*< This is used for tracing the scheduler and making debugging easier only. */
//  201 	signed portCHAR			pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */
//  202 	unsigned portSHORT		usStackDepth;		/*< Total depth of the stack (when empty).  This is defined as the number of variables the stack can hold, not the number of bytes. */
//  203 } tskTCB;
//  204 
//  205 /*lint -e956 */
//  206 

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  207 tskTCB * volatile pxCurrentTCB = NULL;					
pxCurrentTCB:
        DS8 2
//  208 
//  209 /* Lists for ready and blocked tasks. --------------------*/
//  210 

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  211 static xList pxReadyTasksLists[ configMAX_PRIORITIES ];	/*< Prioritised ready tasks. */
pxReadyTasksLists:
        DS8 40

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  212 static xList xDelayedTaskList1;							/*< Delayed tasks. */
xDelayedTaskList1:
        DS8 10

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  213 static xList xDelayedTaskList2;							/*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */
xDelayedTaskList2:
        DS8 10

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  214 static xList * volatile pxDelayedTaskList;				/*< Points to the delayed task list currently being used. */
pxDelayedTaskList:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  215 static xList * volatile pxOverflowDelayedTaskList;		/*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */
pxOverflowDelayedTaskList:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  216 static xList xPendingReadyList;							/*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready queue when the scheduler is resumed. */
xPendingReadyList:
        DS8 10
//  217 
//  218 #if ( INCLUDE_vTaskDelete == 1 )
//  219 

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  220 	static volatile xList xTasksWaitingTermination;		/*< Tasks that have been deleted - but the their memory not yet freed. */
xTasksWaitingTermination:
        DS8 10

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  221 	static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0;
uxTasksDeleted:
        DS8 2
//  222 
//  223 #endif
//  224 
//  225 #if ( INCLUDE_vTaskSuspend == 1 )
//  226 

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  227 	static xList xSuspendedTaskList;					/*< Tasks that are currently suspended. */
xSuspendedTaskList:
        DS8 10
//  228 
//  229 #endif
//  230 
//  231 /* File private variables. --------------------------------*/

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  232 static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks	= ( unsigned portBASE_TYPE ) 0;
uxCurrentNumberOfTasks:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  233 static volatile portTickType xTickCount							= ( portTickType ) 0;
xTickCount:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  234 static unsigned portBASE_TYPE uxTopUsedPriority				= tskIDLE_PRIORITY;
uxTopUsedPriority:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  235 static volatile unsigned portBASE_TYPE uxTopReadyPriority		= tskIDLE_PRIORITY;
uxTopReadyPriority:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  236 static volatile signed portBASE_TYPE xSchedulerRunning			= pdFALSE;
xSchedulerRunning:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  237 static volatile unsigned portBASE_TYPE uxSchedulerSuspended		= ( unsigned portBASE_TYPE ) pdFALSE;
uxSchedulerSuspended:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  238 static volatile unsigned portBASE_TYPE uxMissedTicks			= ( unsigned portBASE_TYPE ) 0;
uxMissedTicks:
        DS8 2

        RSEG DATA16_Z:DATA:SORT:NOROOT(1)
        REQUIRE ?cstart_init_zero
//  239 static volatile portBASE_TYPE xMissedYield						= ( portBASE_TYPE ) pdFALSE;
xMissedYield:
        DS8 2
//  240 
//  241 /* Debugging and trace facilities private variables and macros. ------------*/
//  242 
//  243 /*
//  244  * The value used to fill the stack of a task when the task is created.  This
//  245  * is used purely for checking the high water mark for tasks.
//  246  */
//  247 #define tskSTACK_FILL_BYTE	( 0xa5 )
//  248 
//  249 /*
//  250  * Macros used by vListTask to indicate which state a task is in.
//  251  */
//  252 #define tskBLOCKED_CHAR		( ( signed portCHAR ) 'B' )
//  253 #define tskREADY_CHAR		( ( signed portCHAR ) 'R' )
//  254 #define tskDELETED_CHAR		( ( signed portCHAR ) 'D' )
//  255 #define tskSUSPENDED_CHAR	( ( signed portCHAR ) 'S' )
//  256 
//  257 /*
//  258  * Macros and private variables used by the trace facility.
//  259  */
//  260 #if ( configUSE_TRACE_FACILITY == 1 )
//  261 
//  262 	#define tskSIZE_OF_EACH_TRACE_LINE			( ( unsigned portLONG ) ( sizeof( unsigned portLONG ) + sizeof( unsigned portLONG ) ) )
//  263 	static volatile signed portCHAR * volatile pcTraceBuffer;
//  264 	static signed portCHAR *pcTraceBufferStart;
//  265 	static signed portCHAR *pcTraceBufferEnd;
//  266 	static signed portBASE_TYPE xTracing = pdFALSE;
//  267 
//  268 #endif
//  269 
//  270 /*
//  271  * Macro that writes a trace of scheduler activity to a buffer.  This trace
//  272  * shows which task is running when and is very useful as a debugging tool.
//  273  * As this macro is called each context switch it is a good idea to undefine
//  274  * it if not using the facility.
//  275  */
//  276 #if ( configUSE_TRACE_FACILITY == 1 )
//  277 
//  278 	#define vWriteTraceToBuffer()														\ 
//  279 	{																					\ 
//  280 		if( xTracing )																	\ 
//  281 		{																				\ 
//  282 			static unsigned portBASE_TYPE uxPreviousTask = 255;							\ 
//  283 																						\ 
//  284 			if( uxPreviousTask != pxCurrentTCB->uxTCBNumber )							\ 
//  285 			{																			\ 
//  286 				if( ( pcTraceBuffer + tskSIZE_OF_EACH_TRACE_LINE ) < pcTraceBufferEnd )	\ 
//  287 				{																		\ 
//  288 					uxPreviousTask = pxCurrentTCB->uxTCBNumber;							\ 
//  289 					*( unsigned portLONG * ) pcTraceBuffer = ( unsigned portLONG ) xTickCount;		\ 
//  290 					pcTraceBuffer += sizeof( unsigned portLONG );						\ 
//  291 					*( unsigned portLONG * ) pcTraceBuffer = ( unsigned portLONG ) uxPreviousTask;	\ 
//  292 					pcTraceBuffer += sizeof( unsigned portLONG );						\ 
//  293 				}																		\ 
//  294 				else																	\ 
//  295 				{																		\ 
//  296 					xTracing = pdFALSE;													\ 
//  297 				}																		\ 
//  298 			}																			\ 
//  299 		}																				\ 
//  300 	}
//  301 
//  302 #else
//  303 
//  304 	#define vWriteTraceToBuffer()
//  305 
//  306 #endif
//  307 
//  308 
//  309 /*
//  310  * Place the task represented by pxTCB into the appropriate ready queue for
//  311  * the task.  It is inserted at the end of the list.  One quirk of this is
//  312  * that if the task being inserted is at the same priority as the currently
//  313  * executing task, then it will only be rescheduled after the currently
//  314  * executing task has been rescheduled.
//  315  */
//  316 #define prvAddTaskToReadyQueue( pxTCB )																			\ 
//  317 {																												\ 
//  318 	if( pxTCB->uxPriority > uxTopReadyPriority )																\ 
//  319 	{																											\ 
//  320 		uxTopReadyPriority = pxTCB->uxPriority;																	\ 
//  321 	}																											\ 
//  322 	vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) );	\ 
//  323 }	
//  324 
//  325 
//  326 /*
//  327  * Macro that looks at the list of tasks that are currently delayed to see if
//  328  * any require waking.
//  329  *
//  330  * Tasks are stored in the queue in the order of their wake time - meaning
//  331  * once one tasks has been found whose timer has not expired we need not look
//  332  * any further down the list.
//  333  */
//  334 #define prvCheckDelayedTasks()																	\ 
//  335 {																								\ 
//  336 register tskTCB *pxTCB;																			\ 
//  337 																								\ 
//  338 	while( ( pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList ) ) != NULL )	\ 
//  339 	{																							\ 
//  340 		if( xTickCount < listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ) )				\ 
//  341 		{																						\ 
//  342 			break;																				\ 
//  343 		}																						\ 
//  344 		vListRemove( &( pxTCB->xGenericListItem ) );											\ 
//  345 		/* Is the task waiting on an event also? */												\ 
//  346 		if( pxTCB->xEventListItem.pvContainer )													\ 
//  347 		{																						\ 
//  348 			vListRemove( &( pxTCB->xEventListItem ) );											\ 
//  349 		}																						\ 
//  350 		prvAddTaskToReadyQueue( pxTCB );														\ 
//  351 	}																							\ 
//  352 }																							
//  353 
//  354 /*
//  355  * Several functions take an xTaskHandle parameter that can optionally be NULL,
//  356  * where NULL is used to indicate that the handle of the currently executing
//  357  * task should be used in place of the parameter.  This macro simply checks to
//  358  * see if the parameter is NULL and returns a pointer to the appropriate TCB.
//  359  */
//  360 #define prvGetTCBFromHandle( pxHandle ) ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle )
//  361 
//  362 
//  363 /* File private functions. --------------------------------*/
//  364 
//  365 /*
//  366  * Utility to ready a TCB for a given task.  Mainly just copies the parameters
//  367  * into the TCB structure.
//  368  */
//  369 static void prvInitialiseTCBVariables( tskTCB *pxTCB, unsigned portSHORT usStackDepth, const signed portCHAR * const pcName, unsigned portBASE_TYPE uxPriority );
//  370 
//  371 /*
//  372  * Utility to ready all the lists used by the scheduler.  This is called
//  373  * automatically upon the creation of the first task.
//  374  */
//  375 static void prvInitialiseTaskLists( void );
//  376 
//  377 /*
//  378  * The idle task, which as all tasks is implemented as a never ending loop.
//  379  * The idle task is automatically created and added to the ready lists upon
//  380  * creation of the first user task.
//  381  *
//  382  * The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific
//  383  * language extensions.  The equivalent prototype for this function is:
//  384  *
//  385  * void prvIdleTask( void *pvParameters );
//  386  *
//  387  */
//  388 static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters );
//  389 
//  390 /*
//  391  * Utility to free all memory allocated by the scheduler to hold a TCB,
//  392  * including the stack pointed to by the TCB.
//  393  *
//  394  * This does not free memory allocated by the task itself (i.e. memory
//  395  * allocated by calls to pvPortMalloc from within the tasks application code).
//  396  */
//  397 #if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) )
//  398 	static void prvDeleteTCB( tskTCB *pxTCB );
//  399 #endif
//  400 
//  401 /*
//  402  * Used only by the idle task.  This checks to see if anything has been placed
//  403  * in the list of tasks waiting to be deleted.  If so the task is cleaned up
//  404  * and its TCB deleted.
//  405  */
//  406 static void prvCheckTasksWaitingTermination( void );
//  407 
//  408 /*
//  409  * Allocates memory from the heap for a TCB and associated stack.  Checks the
//  410  * allocation was successful.
//  411  */
//  412 static tskTCB *prvAllocateTCBAndStack( unsigned portSHORT usStackDepth );
//  413 
//  414 /*
//  415  * Called from vTaskList.  vListTasks details all the tasks currently under
//  416  * control of the scheduler.  The tasks may be in one of a number of lists.
//  417  * prvListTaskWithinSingleList accepts a list and details the tasks from
//  418  * within just that list.
//  419  *
//  420  * THIS FUNCTION IS INTENDED FOR DEBUGGING ONLY, AND SHOULD NOT BE CALLED FROM
//  421  * NORMAL APPLICATION CODE.
//  422  */
//  423 #if ( configUSE_TRACE_FACILITY == 1 )
//  424 
//  425 	static void prvListTaskWithinSingleList( signed portCHAR *pcWriteBuffer, xList *pxList, signed portCHAR cStatus );
//  426 
//  427 #endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -