cxttrig.c

来自「CMEX source code RTOS for atmel atmega12」· C语言 代码 · 共 60 行

C
60
字号
/*********************************************************

Copyright (c) CMX Company. 1999. All rights reserved

*********************************************************/
/* version 5.30 */

#define CMXMODULE 1

#include <cxfuncs.h>	/* get cmx include header file */
#include <cxextern.h>	/* get cmx include header file */

#ifdef CMXTRACKER
#include <cmxtrack.h>	/* get cmx include header file */
#endif

/****************************************************************
 This function will place a task into the READY state, if in the
 IDLE state. If the task is already triggered, then this will
 be queued up. The maximum number of starts for a task, can be
 255.
*****************************************************************/
byte K_Task_Start(byte tskid)
{
	tcbpointer tcbptr;

	if(K_I_Get_Ptr(tskid,&tcbptr))	/* send address of pointer */
		{
#ifdef CMXTRACKER
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXTTRIG_K_ERROR,tskid);
			}
#endif
		return(K_ERROR);
		}
	K_I_Disable_Sched();	/* set task block */
	if (tcbptr->trig != 0xff) /* see if 0xFF, bypass if so */
		{
		if (++tcbptr->trig == 1)	/* increment the task start count byte */
			{
				/* if count = 1, then put task into READY state */
				tcbptr->tcbstate = READY;

			/* see if this task has a higher priority then current RUNNING task */
				if (tcbptr->priority < active_priority) 
					PREEMPTED;	/* yes, set preempted scheduling flag */
			}
		}
#ifdef CMXTRACKER
		if (CMXTRACKER_ON)
			{
			cmxtracker_in2(CXTTRIG_K_OK,tskid);
			}
#endif
	K_I_Func_Return();	/* release task block */
	return(K_OK);	/* return good status */
}

⌨️ 快捷键说明

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