亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区 | 国产suv精品一区二区6| 99久免费精品视频在线观看| 91网站黄www| 欧美伦理视频网站| 久久这里只有精品6| 国产精品视频在线看| 一区二区三区日韩在线观看| 日日夜夜精品视频免费| 国产综合久久久久影院| 色婷婷久久综合| 久久久久青草大香线综合精品| 亚洲人成7777| 高清av一区二区| 91精品国产色综合久久| 亚洲天堂成人网| 丁香婷婷综合激情五月色| 666欧美在线视频| 一区二区三区av电影 | 久久久久国产精品麻豆ai换脸 | 久久久久久久网| 精品久久人人做人人爽| 国产揄拍国内精品对白| 91在线观看高清| 3751色影院一区二区三区| 国产视频在线观看一区二区三区| 亚洲欧洲日韩一区二区三区| 韩国精品主播一区二区在线观看 | 日韩视频免费直播| 国产肉丝袜一区二区| www.亚洲激情.com| 日韩美女视频一区| 欧美亚洲日本国产| 舔着乳尖日韩一区| 欧美日韩中文另类| 免费人成精品欧美精品 | 风间由美一区二区三区在线观看| 亚洲黄色小说网站| 亚洲综合色噜噜狠狠| 色综合色狠狠综合色| 成人精品视频.| 中文字幕一区二区三区在线播放| 91网页版在线| 一区二区三区**美女毛片| 成人欧美一区二区三区1314| 久久久久综合网| 国产精品一区二区久激情瑜伽 | 日韩中文字幕区一区有砖一区 | 色综合婷婷久久| 青椒成人免费视频| 一区二区三区日韩精品视频| 欧美变态tickle挠乳网站| 欧美视频在线不卡| 99re66热这里只有精品3直播 | 亚洲午夜羞羞片| 中文字幕一区二区三区av| www激情久久| 欧美一区二区三区啪啪| 日本乱人伦aⅴ精品| 成人精品gif动图一区| 另类人妖一区二区av| 亚洲444eee在线观看| 亚洲视频资源在线| 中文字幕精品在线不卡| 欧美成人性福生活免费看| 7777女厕盗摄久久久| 欧美在线观看视频一区二区三区| 国产精品1024| 国产91精品入口| 国产一区二区福利| 黑人巨大精品欧美一区| 久久精品久久99精品久久| 午夜久久久久久| 三级影片在线观看欧美日韩一区二区| 一区二区在线观看av| 亚洲欧美偷拍三级| 亚洲欧美一区二区三区极速播放 | 久久亚洲欧美国产精品乐播| 久久一区二区三区四区| 久久久影视传媒| 久久久综合视频| 欧美高清在线一区| 国产精品视频麻豆| 亚洲欧美日韩人成在线播放| 亚洲青青青在线视频| 亚洲综合精品自拍| 香蕉久久夜色精品国产使用方法 | 全国精品久久少妇| 一区二区三区毛片| 日韩综合一区二区| 日韩中文字幕不卡| 日韩成人一区二区| 日韩经典中文字幕一区| 日韩av电影天堂| 天天色天天爱天天射综合| 免费人成精品欧美精品| 蜜臀va亚洲va欧美va天堂| 免费在线欧美视频| 蜜臀av一区二区在线免费观看 | 97精品视频在线观看自产线路二| 成人网在线播放| 国产精品888| 91亚洲精品久久久蜜桃| 色偷偷久久一区二区三区| 91久久国产最好的精华液| 91福利精品第一导航| 在线精品视频免费观看| 欧美日韩1区2区| 9191国产精品| 国产女同性恋一区二区| 中文字幕va一区二区三区| 亚洲视频在线观看三级| 亚洲午夜精品一区二区三区他趣| 亚洲成人在线免费| 久久国产三级精品| 91丨九色porny丨蝌蚪| 精品1区2区3区| 日韩欧美一二三区| 中文成人综合网| 亚洲国产精品尤物yw在线观看| 秋霞国产午夜精品免费视频| 亚洲国产精品影院| 成人av资源网站| 在线观看日韩高清av| 日韩一区二区三区在线| 日本一区二区视频在线观看| 亚洲特级片在线| 久久精品72免费观看| 99久久婷婷国产| 欧美一区二区三区视频| 亚洲欧洲av另类| 日韩高清不卡一区二区三区| 大胆欧美人体老妇| 欧美日韩视频一区二区| 国产日韩在线不卡| 亚洲男人的天堂网| 日韩精品一卡二卡三卡四卡无卡 | 日韩电影在线观看一区| 丁香亚洲综合激情啪啪综合| 在线观看国产一区二区| 4438成人网| 亚洲欧洲精品一区二区三区| 日韩高清一级片| 99精品在线观看视频| 精品精品欲导航| 天天综合天天做天天综合| 丁香激情综合国产| 欧美一区二区免费观在线| 国产精品视频麻豆| 久久不见久久见免费视频1| 91日韩精品一区| 日韩美女天天操| 亚洲成a人片综合在线| www.欧美.com| wwwwww.欧美系列| 午夜精品一区二区三区电影天堂| 91蝌蚪porny成人天涯| 久久久久久久久久久久久夜| 国产精品久久久久久久久动漫| 久久99精品久久久久| 欧美日韩久久久一区| 国产精品嫩草久久久久| 国产在线播精品第三| 91精品国产免费| 日韩**一区毛片| 欧美日韩一区在线观看| 亚洲欧美激情插| av不卡在线播放| 精品对白一区国产伦| 精品一区二区在线看| 日韩一区二区三区视频| 三级不卡在线观看| 欧美视频一区二区三区四区| 一区在线播放视频| 成人激情av网| 国产精品麻豆一区二区| av一区二区三区在线| 国产精品日产欧美久久久久| 国产成人免费视频网站 | 丁香六月综合激情| 精品国产免费一区二区三区香蕉| 久久成人免费网| 欧美va亚洲va香蕉在线| 麻豆成人91精品二区三区| 日韩一卡二卡三卡四卡| 亚洲成人激情av| 精品国产髙清在线看国产毛片| 久久激情五月婷婷| 2020日本不卡一区二区视频| 精品一区二区三区在线视频| 欧美国产综合色视频| 不卡的av网站| 亚洲视频一区二区免费在线观看| 91丨porny丨国产| 国产精品视频九色porn| 欧美无砖专区一中文字| 免费在线看成人av|