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

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

?? sch51.c

?? 時間觸發嵌入式系統設計模式源碼
?? C
字號:
/*------------------------------------------------------------------*-

   SCH51.C (v1.00) 

  ------------------------------------------------------------------

   *** THESE ARE THE CORE SCHEDULER FUNCTIONS ***
   --- These functions may be used with all 8051 devices ---

   *** SCH_MAX_TASKS *must* be set by the user ***
   --- see "Sch51.H" ---

   *** Includes (optional) power-saving mode ***
   --- You must ensure that the power-down mode is adapted ---
   --- to match your chosen device (or disabled altogether) ---


   COPYRIGHT
   ---------

   This code is from the book:

   PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont 
   [Pearson Education, 2001; ISBN: 0-201-33138-1].

   This code is copyright (c) 2001 by Michael J. Pont.
 
   See book for copyright details and other information.

-*------------------------------------------------------------------*/

#include "Main.h"
#include "Port.h"

#include "Sch51.h"

// ------ Public variable definitions ------------------------------

// The array of tasks
sTask SCH_tasks_G[SCH_MAX_TASKS];

// Used to display the error code
// See Main.H for details of error codes
// See Port.H for details of the error port
tByte Error_code_G = 0;

// ------ Private function prototypes ------------------------------

static void SCH_Go_To_Sleep(void);

// ------ Private variables ----------------------------------------

// Keeps track of time since last error was recorded (see below)
static tWord Error_tick_count_G;

// The code of the last error (reset after ~1 minute)
static tByte Last_error_code_G;


/*------------------------------------------------------------------*-

  SCH_Dispatch_Tasks()

  This is the 'dispatcher' function.  When a task (function)
  is due to run, SCH_Dispatch_Tasks() will run it.
  This function must be called (repeatedly) from the main loop.

-*------------------------------------------------------------------*/
void SCH_Dispatch_Tasks(void) 
   {
   tByte Index;

   // Dispatches (runs) the next task (if one is ready)
   for (Index = 0; Index < SCH_MAX_TASKS; Index++)
      {
      if (SCH_tasks_G[Index].RunMe > 0) 
         {
         (*SCH_tasks_G[Index].pTask)();  // Run the task

         SCH_tasks_G[Index].RunMe -= 1;   // Reset / reduce RunMe flag

         // Periodic tasks will automatically run again
         // - if this is a 'one shot' task, remove it from the array
         if (SCH_tasks_G[Index].Period == 0)
            {
            SCH_Delete_Task(Index);
            }
         }
      }

   // Report system status
   SCH_Report_Status();  

   // The scheduler enters idle mode at this point 
   SCH_Go_To_Sleep();          
   }

/*------------------------------------------------------------------*-

  SCH_Add_Task()

  Causes a task (function) to be executed at regular intervals 
  or after a user-defined delay

  Fn_P   - The name of the function which is to be scheduled.
           NOTE: All scheduled functions must be 'void, void' -
           that is, they must take no parameters, and have 
           a void return type. 
                   
  DELAY  - The interval (TICKS) before the task is first executed

  PERIOD - If 'PERIOD' is 0, the function is only called once,
           at the time determined by 'DELAY'.  If PERIOD is non-zero,
           then the function is called repeatedly at an interval
           determined by the value of PERIOD (see below for examples
           which should help clarify this).


  RETURN VALUE:  

  Returns the position in the task array at which the task has been 
  added.  If the return value is SCH_MAX_TASKS then the task could 
  not be added to the array (there was insufficient space).  If the
  return value is < SCH_MAX_TASKS, then the task was added 
  successfully.  

  Note: this return value may be required, if a task is
  to be subsequently deleted - see SCH_Delete_Task().

  EXAMPLES:

  Task_ID = SCH_Add_Task(Do_X,1000,0);
  Causes the function Do_X() to be executed once after 1000 sch ticks.            

  Task_ID = SCH_Add_Task(Do_X,0,1000);
  Causes the function Do_X() to be executed regularly, every 1000 sch ticks.            

  Task_ID = SCH_Add_Task(Do_X,300,1000);
  Causes the function Do_X() to be executed regularly, every 1000 ticks.
  Task will be first executed at T = 300 ticks, then 1300, 2300, etc.            
 
-*------------------------------------------------------------------*/
tByte SCH_Add_Task(void (code * pFunction)(), 
                   const tWord DELAY, 
                   const tWord PERIOD)    
   {
   tByte Index = 0;
   
   // First find a gap in the array (if there is one)
   while ((SCH_tasks_G[Index].pTask != 0) && (Index < SCH_MAX_TASKS))
      {
      Index++;
      } 
   
   // Have we reached the end of the list?   
   if (Index == SCH_MAX_TASKS)
      {
      // Task list is full
      //
      // Set the global error variable
      Error_code_G = ERROR_SCH_TOO_MANY_TASKS;

      // Also return an error code
      return SCH_MAX_TASKS;  
      }
      
   // If we're here, there is a space in the task array
   SCH_tasks_G[Index].pTask  = pFunction;
     
   SCH_tasks_G[Index].Delay  = DELAY;
   SCH_tasks_G[Index].Period = PERIOD;

   SCH_tasks_G[Index].RunMe  = 0;

   return Index; // return position of task (to allow later deletion)
   }

/*------------------------------------------------------------------*-

  SCH_Delete_Task()

  Removes a task from the scheduler.  Note that this does
  *not* delete the associated function from memory: 
  it simply means that it is no longer called by the scheduler. 
 
  TASK_INDEX - The task index.  Provided by SCH_Add_Task(). 

  RETURN VALUE:  RETURN_ERROR or RETURN_NORMAL

-*------------------------------------------------------------------*/
bit SCH_Delete_Task(const tByte TASK_INDEX) 
   {
   bit Return_code;

   if (SCH_tasks_G[TASK_INDEX].pTask == 0)
      {
      // No task at this location...
      //
      // Set the global error variable
      Error_code_G = ERROR_SCH_CANNOT_DELETE_TASK;

      // ...also return an error code
      Return_code = RETURN_ERROR;
      }
   else
      {
      Return_code = RETURN_NORMAL;
      }      
   
   SCH_tasks_G[TASK_INDEX].pTask   = 0x0000;
   SCH_tasks_G[TASK_INDEX].Delay   = 0;
   SCH_tasks_G[TASK_INDEX].Period  = 0;

   SCH_tasks_G[TASK_INDEX].RunMe   = 0;

   return Return_code;       // return status
   }


/*------------------------------------------------------------------*-

  SCH_Report_Status()

  Simple function to display error codes.

  This version displays code on a port with attached LEDs:
  adapt, if required, to report errors over serial link, etc.

  Errors are only displayed for a limited period 
  (60000 ticks = 1 minute at 1ms tick interval).
  After this the the error code is reset to 0. 

  This code may be easily adapted to display the last
  error 'for ever': this may be appropriate in your
  application.

  See Chapter 10 for further information.

-*------------------------------------------------------------------*/
void SCH_Report_Status(void)
   {
#ifdef SCH_REPORT_ERRORS
   // ONLY APPLIES IF WE ARE REPORTING ERRORS
   // Check for a new error code
   if (Error_code_G != Last_error_code_G)
      {
      // Negative logic on LEDs assumed
      Error_port = 255 - Error_code_G;
      
      Last_error_code_G = Error_code_G;

      if (Error_code_G != 0)
         {
         Error_tick_count_G = 60000;
         }
      else
         {
         Error_tick_count_G = 0;
         }
      }
   else
      {
      if (Error_tick_count_G != 0)
         {
         if (--Error_tick_count_G == 0)
            {
            Error_code_G = 0; // Reset error code
            }
         }
      }
#endif
   }


/*------------------------------------------------------------------*-

  SCH_Go_To_Sleep()

  This scheduler enters 'idle mode' between clock ticks
  to save power.  The next clock tick will return the processor
  to the normal operating state.

  Note: a slight performance improvement is possible if this
  function is implemented as a macro, or if the code here is simply 
  pasted into the 'dispatch' function.  

  However, by making this a function call, it becomes easier 
  - during development - to assess the performance of the 
  scheduler, using the 'performance analyser' in the Keil 
  hardware simulator. See Chapter 14 for examples for this. 

  *** May wish to disable this if using a watchdog ***

  *** ADAPT AS REQUIRED FOR YOUR HARDWARE ***

-*------------------------------------------------------------------*/
void SCH_Go_To_Sleep()
   {
   PCON |= 0x01;    // Enter idle mode (generic 8051 version)

   // Entering idle mode requires TWO consecutive instructions 
   // on 80c515 / 80c505 - to avoid accidental triggering
   //PCON |= 0x01;    // Enter idle mode (#1)
   //PCON |= 0x20;    // Enter idle mode (#2)
   }

/*------------------------------------------------------------------*-
  ---- END OF FILE -------------------------------------------------
-*------------------------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区中文字幕在线 | 色呦呦国产精品| 欧美手机在线视频| 国产三级一区二区| 午夜欧美电影在线观看| 成人网在线播放| 欧美一区二区三区电影| 中文字幕日韩av资源站| 亚洲国产精品久久艾草纯爱| 国产一区二区三区| 91麻豆精品国产91久久久使用方法| 成人精品视频一区| 欧美色偷偷大香| 欧美日韩在线电影| 国产精品久久综合| 国产精品99久久久久久久女警| 欧美日韩一区成人| 一个色妞综合视频在线观看| 国产激情一区二区三区四区| 日韩美女视频一区二区在线观看| 亚洲精品国产一区二区三区四区在线| 国产黄人亚洲片| 精品国产91乱码一区二区三区 | 国产精品乱码一区二区三区软件 | 亚洲蜜臀av乱码久久精品| 国产精品一区二区久激情瑜伽| 日韩午夜av电影| 日韩激情视频在线观看| 欧美影片第一页| 亚洲午夜羞羞片| 欧美性生活影院| 午夜精品一区在线观看| 欧美日本一区二区三区| 午夜精品久久久久久久久久久| 色综合久久久久综合99| 亚洲精品欧美在线| 欧美三级资源在线| 日韩国产高清在线| 精品国产免费一区二区三区香蕉| 精品中文字幕一区二区| 久久精品网站免费观看| 从欧美一区二区三区| 欧美经典一区二区三区| 成人aa视频在线观看| 中文字幕一区二区三区在线不卡| 成人视屏免费看| 成人欧美一区二区三区在线播放| 91亚洲精品乱码久久久久久蜜桃| 国产精品久久久久久户外露出 | 国产成人午夜视频| 亚洲欧洲日韩综合一区二区| 色悠悠亚洲一区二区| 午夜精品福利一区二区蜜股av| 宅男在线国产精品| 国产精品一品视频| 亚洲在线视频网站| 91精品国产综合久久精品性色| 国产一区二区在线观看视频| 亚洲国产精品成人综合| 色88888久久久久久影院野外| 亚洲va韩国va欧美va精品| 日韩久久免费av| 99久久精品免费观看| 日韩中文字幕区一区有砖一区| 精品国产乱码久久久久久浪潮| 成人久久久精品乱码一区二区三区| 亚洲激情自拍偷拍| 欧美va亚洲va在线观看蝴蝶网| 波多野结衣一区二区三区| 亚洲国产成人tv| 国产目拍亚洲精品99久久精品| 99久久99久久免费精品蜜臀| 日韩专区中文字幕一区二区| 中文字幕av不卡| 91精品国产综合久久福利| 成人免费视频一区| 老鸭窝一区二区久久精品| 国产精品乱码妇女bbbb| 日韩午夜激情免费电影| 91丨九色丨蝌蚪富婆spa| 美女视频免费一区| 亚洲精品成人在线| 国产精品久久久久久久第一福利| 91精品在线麻豆| 日本韩国欧美在线| 粉嫩av一区二区三区粉嫩| 丝袜诱惑制服诱惑色一区在线观看 | 在线精品亚洲一区二区不卡| 国内一区二区在线| 日韩福利电影在线| 尤物在线观看一区| 国产精品免费网站在线观看| 日韩一卡二卡三卡| 欧美人与z0zoxxxx视频| 91亚洲精品久久久蜜桃网站| 高清不卡一区二区| 国产自产视频一区二区三区| 午夜精品久久久久久久99水蜜桃 | 久久免费美女视频| 日韩欧美一区二区久久婷婷| 欧美色成人综合| 欧美在线一区二区| 在线观看国产91| 91国偷自产一区二区三区观看| 国产99久久久精品| 国产美女视频91| 国产老肥熟一区二区三区| 狂野欧美性猛交blacked| 日本免费在线视频不卡一不卡二 | 蜜臀精品一区二区三区在线观看| 一区二区高清视频在线观看| 亚洲日本青草视频在线怡红院| 国产欧美一区二区精品久导航 | 欧美一区二区视频免费观看| 欧美伊人久久久久久久久影院 | 午夜精品久久久久久久 | 亚洲女同一区二区| 亚洲美女在线国产| 亚洲欧美韩国综合色| 怡红院av一区二区三区| 一区二区三区中文字幕| 亚洲成人中文在线| 日本美女一区二区| 国产在线不卡一区| 精品成人一区二区三区| 日韩欧美一级二级| 国产日韩v精品一区二区| 777奇米成人网| 日韩一区二区精品葵司在线| 日韩一区和二区| 精品国产伦理网| 久久久久国产精品厨房| 国产精品久久久久久久浪潮网站| 亚洲视频在线观看一区| 中文字幕一区二区在线观看| 亚洲精品免费视频| 日韩和的一区二区| 国产麻豆精品久久一二三| 国产99久久久国产精品潘金网站| 91麻豆.com| 3d动漫精品啪啪1区2区免费| 久久网这里都是精品| 国产精品久久久久久久久晋中| 夜夜操天天操亚洲| 精品一区二区免费在线观看| 成人av一区二区三区| 在线观看亚洲成人| 精品乱人伦一区二区三区| 国产精品女主播av| 丝袜亚洲另类欧美综合| 国产成人精品免费在线| 在线观看不卡视频| 精品美女被调教视频大全网站| 亚洲色图视频免费播放| 男男视频亚洲欧美| 成人av网址在线观看| 91.麻豆视频| 一区在线观看免费| 韩国一区二区在线观看| 91福利小视频| 国产丝袜欧美中文另类| 亚洲a一区二区| 不卡av在线免费观看| 日韩免费观看高清完整版在线观看| 国产精品久久久久久久久久免费看| 琪琪一区二区三区| 91久久免费观看| 国产免费成人在线视频| 美美哒免费高清在线观看视频一区二区| 成人手机电影网| 久久亚洲欧美国产精品乐播| 亚洲sss视频在线视频| 99久久国产综合精品麻豆| 国产亚洲一二三区| 蜜臀av一区二区| 3atv一区二区三区| 亚洲v中文字幕| 在线精品亚洲一区二区不卡| 国产精品午夜在线观看| 黄网站免费久久| 日韩女优毛片在线| 亚洲一区二区在线观看视频| 成人ar影院免费观看视频| 久久色.com| 精品影视av免费| 日韩视频不卡中文| 日本欧美久久久久免费播放网| 欧美午夜片在线看| 一卡二卡欧美日韩| 91成人国产精品| 亚洲蜜臀av乱码久久精品蜜桃| a在线播放不卡| 国产精品久久毛片| 成人高清在线视频| 国产精品午夜春色av| 成人免费av在线| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 欧美一区二区视频在线观看| 91小视频在线观看| 精品婷婷伊人一区三区三|