亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日韩美女视频一区二区| 免费观看在线综合色| 午夜精品久久久久| 国产成人免费视频网站| 欧美日韩成人在线一区| 国产女人aaa级久久久级| 亚洲高清三级视频| 99久久免费视频.com| 精品剧情在线观看| 亚洲国产裸拍裸体视频在线观看乱了| 国产成人免费视频网站高清观看视频| 欧美军同video69gay| 一区二区在线免费| 不卡的看片网站| 欧美极品少妇xxxxⅹ高跟鞋 | 韩国女主播成人在线观看| 一本大道综合伊人精品热热| 国产亚洲制服色| 老色鬼精品视频在线观看播放| 欧美午夜宅男影院| 亚洲日本一区二区| av网站免费线看精品| 国产目拍亚洲精品99久久精品| 免费观看日韩av| 欧美一区二区女人| 天堂va蜜桃一区二区三区漫画版| 色偷偷久久一区二区三区| 国产精品视频你懂的| 国产一区二区伦理| 国产免费成人在线视频| 国产福利一区二区三区视频在线 | 色噜噜偷拍精品综合在线| 国产精品久久久久桃色tv| 国产suv精品一区二区6| 国产清纯美女被跳蛋高潮一区二区久久w | 欧美一区二区大片| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美区一区二区三区| 亚洲国产美女搞黄色| 欧美欧美欧美欧美| 久久99精品久久久久久国产越南| 日韩一级大片在线| 韩国成人精品a∨在线观看| 2020日本不卡一区二区视频| 国产一区二区三区免费看| 国产欧美1区2区3区| 91小视频免费观看| 亚洲mv大片欧洲mv大片精品| 欧美日韩mp4| 国产精品亚洲专一区二区三区| 久久久电影一区二区三区| caoporn国产精品| 亚洲香蕉伊在人在线观| 国产亚洲欧美在线| 99久久精品国产麻豆演员表| 亚洲综合色成人| 日韩一二三区视频| 成人av电影在线播放| 伊人开心综合网| 欧美一二三区在线观看| 国产成a人无v码亚洲福利| 亚洲男人电影天堂| 日韩欧美第一区| 99这里只有精品| 日韩电影一区二区三区| 国产欧美一区二区精品性色| 91福利在线免费观看| 蜜桃av一区二区| 国产精品免费视频观看| 欧美高清激情brazzers| 国产成人免费视频网站高清观看视频| 一级精品视频在线观看宜春院| 日韩三级视频在线看| 国产成人av一区| 日韩精品欧美成人高清一区二区| 国产亚洲欧美在线| 91精品国产综合久久精品麻豆| 粉嫩一区二区三区性色av| 亚洲妇熟xx妇色黄| 中文在线一区二区| 日韩一级高清毛片| 欧美自拍偷拍一区| 国产福利一区二区| 免费成人av在线播放| 亚洲人成人一区二区在线观看| 日韩亚洲欧美成人一区| 在线一区二区三区做爰视频网站| 国产麻豆成人传媒免费观看| 亚洲成人一二三| 亚洲狼人国产精品| 久久久精品tv| 欧美成人一区二区三区在线观看| 在线观看日韩电影| 成人午夜在线播放| 国模少妇一区二区三区| 日本午夜一区二区| 亚洲午夜电影在线| 亚洲美女视频在线| 国产精品久久久久久一区二区三区 | 日韩情涩欧美日韩视频| 欧美在线你懂的| 91年精品国产| 成人性生交大片免费看在线播放 | 午夜精彩视频在线观看不卡| 国产精品美女一区二区三区| 欧美在线免费观看视频| 91在线视频在线| 午夜av一区二区三区| 日韩精品一区二区三区在线观看| 亚洲一区在线观看免费观看电影高清 | 色婷婷久久久亚洲一区二区三区| 色综合天天综合| av亚洲精华国产精华精华| 蜜桃视频在线一区| 日日欢夜夜爽一区| 日韩在线一区二区三区| 天堂va蜜桃一区二区三区漫画版| 亚洲综合免费观看高清完整版 | 国产精品一区二区三区乱码| 麻豆成人久久精品二区三区红| 青青草国产成人99久久| 天天综合色天天综合色h| 日本欧美一区二区三区乱码| 蜜桃久久久久久久| 国产毛片精品一区| 国产精品中文字幕一区二区三区| 精品无码三级在线观看视频| 国产一区二区在线观看免费| 国产在线播放一区三区四| 五月婷婷欧美视频| 欧美精品在线观看一区二区| 欧美老女人第四色| 久久综合久久鬼色| 国产精品毛片无遮挡高清| 亚洲日本在线看| 天堂成人国产精品一区| 裸体一区二区三区| 国产99久久久国产精品免费看| 不卡一区二区在线| 欧美色欧美亚洲另类二区| 欧美一卡2卡三卡4卡5免费| 久久综合九色综合欧美98| 国产精品国产三级国产| 亚洲一二三四在线| 精品亚洲成av人在线观看| 成人综合在线观看| 欧美人妇做爰xxxⅹ性高电影| 久久综合久久综合九色| 亚洲精品国产品国语在线app| 亚瑟在线精品视频| 国产精品99久久久久久似苏梦涵 | 国内精品伊人久久久久影院对白| 国产成人亚洲综合a∨婷婷图片| 99视频一区二区| 欧美精品日韩精品| 欧美激情中文不卡| 麻豆精品一二三| 91丨九色丨蝌蚪富婆spa| 日韩午夜激情免费电影| 国产精品天美传媒沈樵| 偷拍日韩校园综合在线| 懂色av中文字幕一区二区三区| 欧美三日本三级三级在线播放| 久久亚洲一级片| 五月婷婷激情综合| av一区二区三区四区| 精品日韩在线观看| 亚洲一区二区精品视频| a在线播放不卡| 欧美一级生活片| 亚洲一区二区三区美女| 成人午夜免费电影| 日韩精品最新网址| 亚洲第一搞黄网站| 91视频你懂的| 久久精品人人做人人爽人人| 日本亚洲天堂网| 欧美日韩精品专区| 亚洲一区日韩精品中文字幕| 丁香一区二区三区| 久久众筹精品私拍模特| 青青草国产精品97视觉盛宴| 欧美中文字幕一区二区三区| 国产精品欧美久久久久无广告| 日本中文在线一区| 欧美日韩三级视频| 亚洲一区二区五区| 色综合天天综合网天天狠天天| 国产欧美一区二区三区沐欲| 国产一区二区调教| 精品99一区二区| 麻豆91在线播放| 欧美电影免费观看完整版| 五月婷婷另类国产| 欧美视频完全免费看| 亚洲午夜电影网| 欧洲av一区二区嗯嗯嗯啊| 一区二区三区在线播| 在线免费不卡电影| 一卡二卡欧美日韩|