亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os-task-switch._c

?? ucos-ii-at90S-icc-avr
?? _C
字號:
//os主要代碼
#define  OS_GLOBALS                           /* Declare GLOBAL variables                              */
#include "includes.h"

#define  OS_MASTER_FILE                       /* Prevent the following files from including includes.h */

void        OSInit(void)
{
  INT8U i;

  OSIntNesting=0;             /* Interrupt nesting level                              */
  OSLockNesting=0;            /* Multitasking lock nesting level                      */
  OSPrioCur=0xff;                /* Priority of current task                             */
  OSPrioHighRdy=0xff;            /* Priority of highest priority task                    */
  OSRunning = FALSE;

  OSTCBCur=0;                        /* Pointer to currently running TCB              */
  OSTCBHighRdy=0;                    /* Pointer to highest priority TCB ready to run  */
/*init task tcb pointers list*/
  for(i=0;i<OS_TASK_COUNT;i++)
    OSpTCBList[i]=(OS_TCB*)0;
}
/*
OS_STK *	OSTaskStkInit (void (*task)(void *pd),void *pdata, OS_STK *ptos);
INT8U       OSTCBInit(OS_TCB *ptcb,INT8U prio, OS_STK *ptos,INT16U stk_size);
*/

INT8U       OSTaskCreate(OS_TCB *ptcb,void (*task)(void *pd), void *pdata, OS_STK *ptos,INT16U stk_size, INT8U prio)
{
    void   *psp;
    INT8U   err;

    if (prio > OS_LOWEST_PRIO) {             /* Make sure priority is within allowable range           */
        return (OSERR_PRIO_INVALID);
    }
    OS_ENTER_CRITICAL();
    if (OSpTCBList[prio] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority  */
        OSpTCBList[prio] = ptcb;    /* Reserve the priority to prevent others from doing ...  */
        OS_EXIT_CRITICAL();
        psp = (void *)OSTaskStkInit(task, pdata, ptos, stk_size); /* Initialize the task's stack              */
        err = OSTCBInit(ptcb,prio, psp,stk_size);         
        if (err == OS_NO_ERR) {
            if (OSRunning) {                 /* Find highest priority task if multitasking has started */
                OSSched();
            }
        } else {
        }
        return (err);
    } else {
        OS_EXIT_CRITICAL();
        return (OSERR_PRIO_EXIST);
    }
}

/*
*********************************************************************************************************
*                                            INITIALIZE TCB
*
* Description: This function is internal to uC/OS-II and is used to initialize a Task Control Block when
*              a task is created (see OSTaskCreate() and OSTaskCreateExt()).
*
* Arguments  : prio          is the priority of the task being created
*
*              ptos          is a pointer to the task's top-of-stack assuming that the CPU registers
*                            have been placed on the stack.  Note that the top-of-stack corresponds to a 
*                            'high' memory location is OS_STK_GROWTH is set to 1 and a 'low' memory
*                            location if OS_STK_GROWTH is set to 0.  Note that stack growth is CPU
*                            specific.
*
*              pbos          is a pointer to the bottom of stack.  A NULL pointer is passed if called by
*                            'OSTaskCreate()'.
*
*              id            is the task's ID (0..65535)
*
*              stk_size      is the size of the stack (in 'stack units').  If the stack units are INT8Us
*                            then, 'stk_size' contains the number of bytes for the stack.  If the stack
*                            units are INT32Us then, the stack contains '4 * stk_size' bytes.  The stack
*                            units are established by the #define constant OS_STK which is CPU
*                            specific.  'stk_size' is 0 if called by 'OSTaskCreate()'.
*
*              pext          is a pointer to a user supplied memory area that is used to extend the task
*                            control block.  This allows you to store the contents of floating-point
*                            registers, MMU registers or anything else you could find useful during a 
*                            context switch.  You can even assign a name to each task and store this name
*                            in this TCB extension.  A NULL pointer is passed if called by OSTaskCreate().
*
*              opt           options as passed to 'OSTaskCreateExt()' or, 
*                            0 if called from 'OSTaskCreate()'.
*
* Returns    : OS_NO_ERR         if the call was successful
*              OS_NO_MORE_TCB    if there are no more free TCBs to be allocated and thus, the task cannot
*                                be created.
*
* Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
*********************************************************************************************************
*/

INT8U OSTCBInit (OS_TCB *ptcb,INT8U prio, OS_STK *ptos, INT16U stk_size)
{
#if OS_STRICT
  if((0==ptcb)||(prio>OS_LOWEST_PRIO)||((INT16U)ptos<OS_HARDWARE_STACK_SIZE+40)||(stk_size<OS_HARDWARE_STACK_SIZE+40))
    OSError(0);
#endif
    OS_ENTER_CRITICAL();
    if ((OS_TCB *)0!=ptcb) {
        OS_EXIT_CRITICAL();
        ptcb->OSTCBStkPtr    = ptos;                       /* Load Stack pointer in TCB                */
        ptcb->OSTCBPrio      = (INT8U)prio;                /* Load task priority into TCB              */
        ptcb->OSTCBStat      = OS_STAT_RDY;                /* Task is ready to run                     */
        ptcb->OSTCBDly       = 0;                          /* Task is not delayed                      */

        return (OS_NO_ERR);
    } else {
        OS_EXIT_CRITICAL();
        return (OSERR_TCB_INVALID);
    }
}

/*
*********************************************************************************************************
*                                              SCHEDULER
*
* Description: This function is called by other uC/OS-II services to determine whether a new, high
*              priority task has been made ready to run.  This function is invoked by TASK level code
*              and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
*
* Arguments  : none
*
* Returns    : none
*
* Notes      : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
*              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
*********************************************************************************************************
*/

void OSSched (void)
{
    OS_ENTER_CRITICAL();
    if ((OSLockNesting | OSIntNesting) == 0) {   /* Task scheduling must be enabled and not ISR level  */
        OSPrioHighRdy=OSGetPrioRdy();
		if(OSPrioHighRdy>OS_LOWEST_PRIO)
		{
#if OS_STRICT
		  OSError(0);
#endif
		}else if (OSPrioHighRdy != OSPrioCur) {         /* No context switch if current task is highest ready */
            OSTCBHighRdy = OSpTCBList[OSPrioHighRdy];
#if OS_STRICT
		  	if(0==OSTCBHighRdy)
			  OSError(0);
#endif			
			OS_TASK_SW();                        /* Perform a context switch                           */
        }//end OSPrioHighRdy != OSPrioCur
    }//end nesting==0
    OS_EXIT_CRITICAL();
}

/*
*********************************************************************************************************
*                                          START MULTITASKING
*
* Description: This function is used to start the multitasking process which lets uC/OS-II manages the
*              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
*              and you MUST have created at least one task.
*
* Arguments  : none
*
* Returns    : none
*
* Note       : OSStartHighRdy() MUST:
*                 a) Call OSTaskSwHook() then,
*                 b) Set OSRunning to TRUE.
*********************************************************************************************************
*/

void OSStart (void)
{
    if (OSRunning == FALSE) {
        OSPrioHighRdy = 0;
        OSPrioCur     = 0;
        OSTCBHighRdy  = OSpTCBList[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
        OSTCBCur      = OSTCBHighRdy;
#if OS_STRICT
		if(0==OSTCBCur) 
		  OSError(0);
#endif		
        OSStartHighRdy();                            /* Execute target specific code to start task     */
    }
#if OS_STRICT
	else OSError(0);
#endif
}

/*
*********************************************************************************************************
*                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
*
* Description: This function is called to delay execution of the currently running task until the 
*              specified number of system ticks expires.  This, of course, directly equates to delaying
*              the current task for some time to expire.  No delay will result If the specified delay is 
*              0.  If the specified delay is greater than 0 then, a context switch will result.
*
* Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.  
*                        Note that by specifying 0, the task will not be delayed.
*
* Returns    : none
*********************************************************************************************************
*/

void OSTimeDly (INT16U ticks)
{
    if (ticks > 0) {                                                      /* 0 means no delay!         */
        OS_ENTER_CRITICAL();
        OSTCBCur->OSTCBDly = ticks;                                       /* Load ticks in TCB         */
        OS_EXIT_CRITICAL();
        OSSched();                                                        /* Find next task to run!    */
    }
}

INT8U OSGetPrioRdy(void)
{
  INT8U i,ret=0xff;
  OS_TCB *ptcb;
  for(i=0;i<OS_TASK_COUNT;i++)
  {
    ptcb=OSpTCBList[i];
    //OS_ENTER_CRITICAL();
    if(ptcb)
	  if((0==ptcb->OSTCBDly)&&
	     (OS_STAT_RDY==ptcb->OSTCBStat))
	  {
#if OS_STRICT
	    if(i!=ptcb->OSTCBPrio)
		  OSError(0);
#endif  
        ret=ptcb->OSTCBPrio;     
#if OS_STRICT
		if(ret>OS_LOWEST_PRIO)
		  OSError(0);
#endif  		
	    break;//for
	  }
    //OS_EXIT_CRITICAL();
  }
  return ret;
}

/*
*********************************************************************************************************
*                                         PROCESS SYSTEM TICK
*
* Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
*              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
*              called by a high priority task.
*
* Arguments  : none
*
* Returns    : none
*********************************************************************************************************
*/

void OSTimeTick (void)
{
    INT8U i,ret;
    OS_TCB *ptcb;
	//skip last task,last task must be idle task
	for(i=0;i<OS_TASK_COUNT-1;i++)
	{
	ptcb=OSpTCBList[i];
//    OS_ENTER_CRITICAL();
    //check ptcb != 0
	if(ptcb){              /* Go through all TCBs in TCB list          */
        if (ptcb->OSTCBDly != 0) {                         /* Delayed or waiting for event with TO     */
            if (--ptcb->OSTCBDly == 0) {                   /* Decrement nbr of ticks to end of delay   */
//                if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {    /* Is task suspended?                   */
//                    OSRdyGrp               |= ptcb->OSTCBBitY; /* No,  Make task Rdy to Run (timed out)*/
//                    OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
                } else {                                       /* Yes, Leave 1 tick to prevent ...     */
                    ptcb->OSTCBDly = 1;                        /* ... loosing the task when the ...    */
                }                                              /* ... suspension is removed.           */
            }//end OSTCBDly!=0
        }//end if(ptcb)
  //  OS_EXIT_CRITICAL();
    }//end for
}

/*
*********************************************************************************************************
*                                               EXIT ISR
*
* Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When 
*              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
*              a new, high-priority task, is ready to run.
*
* Arguments  : none
*
* Returns    : none
*
* Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
*                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
*                 end of the ISR.
*              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
*********************************************************************************************************
*/

void OSIntExit(void)
{
    OS_ENTER_CRITICAL();
    if ((--OSIntNesting | OSLockNesting) == 0) { /* Reschedule only if all ISRs completed & not locked */
        OSPrioHighRdy=OSGetPrioRdy();
		if(OSPrioHighRdy>OS_LOWEST_PRIO)
		{
#if OS_STRICT
		  OSError(0);
#endif
		}else if (OSPrioHighRdy != OSPrioCur) {         /* No context switch if current task is highest ready */
            OSTCBHighRdy = OSpTCBList[OSPrioHighRdy];
#if OS_STRICT
		  	if((0==OSTCBHighRdy)||(0==OSTCBCur)||
			   (OSPrioCur>OS_LOWEST_PRIO)||(OSPrioHighRdy>OS_LOWEST_PRIO))
			  OSError(0);
#endif			
            OSDebug();
            OSIntCtxSw();                        /* Perform interrupt level context switch             */
        }//end OSPrioHighRdy != OSPrioCur
    }//end nesting==0
    OS_EXIT_CRITICAL();
}

void OSDebug(void)
{
INT8U port_a;
            //debug
			DDRA=0;port_a=PORTA;
			DDRA=0xff;PORTA=~port_a;
			//end debug
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精三区欧美精三区| 综合欧美一区二区三区| 国产精品色眯眯| 日日摸夜夜添夜夜添精品视频| 国产精品 欧美精品| 欧美精品三级在线观看| 国产精品久久久久9999吃药| 免费在线观看日韩欧美| 91丨porny丨国产| 欧美成人a视频| 亚洲高清视频在线| 色系网站成人免费| 国产精品美女久久久久aⅴ| 激情六月婷婷久久| 日韩一卡二卡三卡四卡| 午夜国产精品一区| 欧美系列日韩一区| 一区二区三区美女视频| 99综合影院在线| 亚洲国产精品成人综合| 国产高清久久久| 久久综合狠狠综合久久激情| 蜜桃精品视频在线观看| 欧美精品一二三四| 日韩综合小视频| 欧美视频在线观看一区二区| 尤物av一区二区| 色老综合老女人久久久| 亚洲黄色片在线观看| 北条麻妃国产九九精品视频| 国产精品全国免费观看高清| 床上的激情91.| 国产拍欧美日韩视频二区| 国产精品一区在线观看你懂的| 日韩一级二级三级| 美女mm1313爽爽久久久蜜臀| 欧美大度的电影原声| 久久机这里只有精品| 日韩欧美的一区| 久久福利视频一区二区| 久久久亚洲精品石原莉奈| 国产美女视频一区| 国产午夜亚洲精品羞羞网站| 国产69精品久久久久777| 欧美国产97人人爽人人喊| 99久久免费国产| 亚洲国产精品久久艾草纯爱| 538prom精品视频线放| 麻豆精品蜜桃视频网站| 国产色产综合产在线视频| av爱爱亚洲一区| 五月天久久比比资源色| 精品国产乱码久久久久久牛牛| 国产成a人亚洲| 亚洲视频你懂的| 欧美日韩国产天堂| 国产一区二区久久| 国产精品视频一二| 欧美在线短视频| 久久99国产精品尤物| 国产精品久久久久久户外露出| 欧洲一区二区三区在线| 精品一区二区三区免费播放| 国产精品每日更新在线播放网址| 91黄色免费版| 久久69国产一区二区蜜臀 | 韩国av一区二区| **性色生活片久久毛片| 91.xcao| 成人av网址在线观看| 日韩成人一区二区三区在线观看| 国产网站一区二区| 欧美日韩中文字幕一区二区| 国产一区二区三区精品视频| 亚洲成人午夜电影| 国产精品日韩精品欧美在线| 91精品国产色综合久久| 99久久国产综合精品色伊| 日韩精品亚洲一区二区三区免费| 中文字幕一区日韩精品欧美| 欧美va天堂va视频va在线| 91极品视觉盛宴| 成人蜜臀av电影| 久久99国产精品久久| 午夜天堂影视香蕉久久| 日韩美女啊v在线免费观看| 精品国产精品一区二区夜夜嗨| 欧美中文字幕一区二区三区| 粉嫩av亚洲一区二区图片| 麻豆精品国产传媒mv男同| 亚洲黄色免费网站| 国产精品不卡在线| 久久精品一级爱片| 日韩午夜激情免费电影| 欧美日韩成人激情| 91国内精品野花午夜精品| 成人黄色免费短视频| 国产精品一区二区在线观看不卡 | 91一区二区三区在线播放| 精品一区二区三区免费视频| 日本不卡视频一二三区| 亚洲一区视频在线观看视频| 日韩一区日韩二区| 亚洲国产精品精华液2区45| 久久久久久影视| 久久先锋影音av| 久久久久国产免费免费 | 国产色爱av资源综合区| 26uuu另类欧美| 久久婷婷色综合| 精品动漫一区二区三区在线观看| 欧美一级理论片| 日韩一区二区三区四区五区六区| 欧美日韩在线免费视频| 在线亚洲+欧美+日本专区| 91美女片黄在线| 日本久久一区二区三区| 欧美日韩一区久久| 欧美喷潮久久久xxxxx| 欧美老肥妇做.爰bbww| 欧美精品亚洲一区二区在线播放| 欧美蜜桃一区二区三区| 欧美情侣在线播放| 欧美乱熟臀69xxxxxx| 88在线观看91蜜桃国自产| 欧美精品99久久久**| 日韩精品一区二区三区老鸭窝 | 国产日产欧美一区二区三区| 国产女人18水真多18精品一级做| 国产精品久久久久四虎| 亚洲精品久久嫩草网站秘色| 亚洲18影院在线观看| 麻豆免费精品视频| 日韩精品一级中文字幕精品视频免费观看| 亚洲丶国产丶欧美一区二区三区| 日本vs亚洲vs韩国一区三区二区 | 亚洲综合视频在线观看| 三级久久三级久久| 国产一区二区三区在线观看精品| 国产成人在线视频免费播放| 一本一道综合狠狠老| 欧美三级日韩三级| 欧美成人性福生活免费看| 国产欧美日韩精品在线| 亚洲精品国产第一综合99久久| 亚洲欧美激情插| 天天综合日日夜夜精品| 国产一区二区三区久久悠悠色av| 99精品国产一区二区三区不卡 | 91蜜桃在线观看| 日韩欧美视频一区| 国产精品久久久久久久岛一牛影视 | 国产成人无遮挡在线视频| 波多野结衣中文字幕一区| 欧美群妇大交群中文字幕| 久久久精品国产免大香伊| 亚洲最大成人网4388xx| 国产精选一区二区三区| 色国产综合视频| 国产欧美一区二区精品忘忧草| 夜夜揉揉日日人人青青一国产精品| 九九视频精品免费| 欧美美女bb生活片| 国产精品欧美久久久久无广告| 日韩专区中文字幕一区二区| 91视视频在线观看入口直接观看www | 91久久免费观看| 国产拍欧美日韩视频二区| 婷婷综合五月天| 91看片淫黄大片一级在线观看| 欧美一级理论片| 亚洲午夜精品在线| 91小视频在线免费看| 久久女同互慰一区二区三区| 亚洲va国产天堂va久久en| 成人av免费网站| 久久精品视频免费观看| 蜜臀av性久久久久蜜臀aⅴ| 在线看国产一区| 自拍视频在线观看一区二区| 国产高清不卡二三区| 亚洲精品在线电影| 日产精品久久久久久久性色| 色综合久久综合网欧美综合网| 国产亚洲一本大道中文在线| 美女在线一区二区| 91精品国产综合久久久久| 亚洲一区自拍偷拍| 欧美系列亚洲系列| 亚洲国产美国国产综合一区二区| 91色视频在线| 18欧美乱大交hd1984| 97精品久久久午夜一区二区三区| 欧美国产精品久久| 国产精品白丝jk白祙喷水网站| 2020国产精品自拍| 精品一二线国产| 久久综合999| 成人午夜电影网站| 国产精品欧美极品|