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

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

?? sch51.c

?? 單片機串口RS485的讀寫操作,應用在多處理器中
?? 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一区二区三区免费野_久草精品视频
蜜桃91丨九色丨蝌蚪91桃色| 亚洲蜜臀av乱码久久精品蜜桃| 偷拍一区二区三区| 欧美日韩中文另类| 亚洲一区二区三区四区在线| 欧美亚洲国产一区二区三区| 亚洲国产中文字幕在线视频综合| 欧美亚洲国产一区二区三区| 亚洲妇熟xx妇色黄| 日韩欧美在线不卡| 国产69精品久久99不卡| 国产精品不卡在线| 在线区一区二视频| 美女视频黄 久久| 国产亚洲欧美日韩日本| 99r国产精品| 图片区日韩欧美亚洲| 亚洲精品一线二线三线无人区| 国产成人在线视频网址| 亚洲综合一区二区| 精品日韩一区二区三区| av动漫一区二区| 亚洲已满18点击进入久久| 国产精品国产三级国产有无不卡| 色婷婷亚洲一区二区三区| 午夜欧美在线一二页| 久久午夜电影网| 91福利在线观看| 久久99精品久久久久久| 日韩美女视频一区二区| 日韩三级在线免费观看| 色综合天天综合网国产成人综合天| 国产麻豆视频精品| 亚洲欧美二区三区| 精品sm捆绑视频| 色综合久久久久久久久久久| 看国产成人h片视频| ●精品国产综合乱码久久久久| 欧美日韩成人在线一区| 成人污视频在线观看| 日韩国产一区二| 《视频一区视频二区| 日韩欧美在线影院| 日本精品视频一区二区三区| 国产精品1区2区3区| 午夜精品久久久| 曰韩精品一区二区| 国产欧美精品在线观看| 91精品麻豆日日躁夜夜躁| 色综合视频一区二区三区高清| 经典三级视频一区| 日韩av成人高清| 亚洲午夜免费视频| 国产精品久久久久久亚洲伦 | 成人亚洲精品久久久久软件| 日韩在线一区二区三区| 亚洲自拍偷拍欧美| 自拍偷拍亚洲欧美日韩| 国产欧美精品一区二区三区四区 | 国产真实乱对白精彩久久| 亚洲一二三四在线观看| 亚洲色图欧洲色图| 国产精品麻豆久久久| 国产欧美日韩亚州综合| 日韩精品专区在线影院重磅| 欧美日韩精品一区二区三区蜜桃| 91在线观看地址| 成人h动漫精品| 国产精品一二三在| 狠狠色丁香婷婷综合久久片| 日韩av电影免费观看高清完整版 | 久久久久99精品国产片| 日韩精品资源二区在线| 日韩久久久精品| 日韩免费看的电影| 欧美不卡一区二区三区四区| 日韩一级片网址| 91精品国产一区二区三区蜜臀| 91黄色激情网站| 在线亚洲免费视频| 在线观看亚洲精品| 欧美人牲a欧美精品| 欧美一区中文字幕| 日韩你懂的在线播放| 精品理论电影在线观看| 久久色中文字幕| 欧美激情在线一区二区三区| 国产精品久久午夜夜伦鲁鲁| 国产精品成人网| 亚洲在线视频免费观看| 午夜一区二区三区在线观看| 天天综合色天天| 另类小说欧美激情| 国产在线一区观看| 不卡一区二区中文字幕| 一本久久a久久精品亚洲| 精品视频999| 日韩久久免费av| 国产精品三级视频| 一区二区三区欧美亚洲| 日韩中文字幕不卡| av激情亚洲男人天堂| 91传媒视频在线播放| 91精品免费观看| 久久精品这里都是精品| 日韩一区欧美小说| 亚洲国产精品嫩草影院| 久国产精品韩国三级视频| 国产乱码一区二区三区| 91日韩在线专区| 欧美一区二区三区色| 欧美国产97人人爽人人喊| 一区二区三区在线视频观看58| 五月婷婷久久丁香| 国产精品白丝jk白祙喷水网站| 色综合天天狠狠| 精品日产卡一卡二卡麻豆| 中文字幕亚洲综合久久菠萝蜜| 亚洲永久免费av| 国产麻豆精品在线观看| 欧美性大战久久久久久久蜜臀| 精品精品国产高清一毛片一天堂| 最新久久zyz资源站| 日韩—二三区免费观看av| av电影在线不卡| 日韩欧美一区中文| 夜夜嗨av一区二区三区网页| 精品一二三四在线| 在线日韩av片| 国产精品免费视频观看| 免费高清成人在线| 91国产精品成人| 中文字幕第一区| 日韩二区三区在线观看| 91同城在线观看| 久久婷婷色综合| 日本高清免费不卡视频| 国产欧美一区二区三区鸳鸯浴| 日韩和欧美的一区| 91成人国产精品| 中文字幕乱码亚洲精品一区| 伦理电影国产精品| 欧美精品精品一区| 亚洲人精品午夜| 成人a区在线观看| 亚洲精品在线三区| 美女一区二区视频| 欧美日本一区二区| 一区二区三区免费| 成人黄色小视频| 久久久天堂av| 九一九一国产精品| 4438x亚洲最大成人网| 艳妇臀荡乳欲伦亚洲一区| 成人在线综合网| 久久久国产午夜精品| 国产在线播放一区二区三区 | 欧美变态凌虐bdsm| 午夜精品123| 欧美日韩成人综合| 性欧美疯狂xxxxbbbb| 欧美日韩一区二区在线观看 | 综合在线观看色| 99久久国产综合精品麻豆| 国产精品每日更新| 成人网男人的天堂| 国产精品私人自拍| 成人动漫av在线| 日韩理论片一区二区| 99久久国产综合精品女不卡| 中文字幕欧美一区| 成人高清免费观看| 中文字幕中文字幕一区| 成人久久18免费网站麻豆| 中文字幕的久久| 99精品1区2区| 亚洲午夜三级在线| 欧美色偷偷大香| 青青青爽久久午夜综合久久午夜| 制服.丝袜.亚洲.另类.中文 | 捆绑变态av一区二区三区| 欧美xxxxxxxxx| 国产一区视频网站| 久久精品人人做人人爽97| 白白色 亚洲乱淫| 一级做a爱片久久| 欧美片在线播放| 国产中文字幕精品| 中文在线一区二区| 在线视频你懂得一区| 琪琪一区二区三区| 欧美xxxxxxxx| gogo大胆日本视频一区| 夜夜操天天操亚洲| 91精品国产色综合久久不卡蜜臀 | 国产·精品毛片| ...av二区三区久久精品| 精品视频999| 韩国一区二区三区| 亚洲人成在线播放网站岛国|