亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
狠狠色综合播放一区二区| 不卡的电影网站| 成人a区在线观看| 在线观看一区不卡| 国产日韩亚洲欧美综合| 亚洲午夜电影在线| 不卡电影免费在线播放一区| 69堂成人精品免费视频| 亚洲婷婷综合久久一本伊一区| 麻豆成人91精品二区三区| 色94色欧美sute亚洲线路二 | 国产日韩欧美激情| 亚洲综合一区在线| 99精品在线观看视频| 欧美精品一区二区三区很污很色的| 一区二区三区欧美在线观看| 国产电影一区二区三区| 日韩欧美视频在线| 丝袜美腿高跟呻吟高潮一区| 91丨porny丨国产入口| 国产欧美日本一区二区三区| 久久99精品久久只有精品| 91麻豆精品国产自产在线| 亚洲图片一区二区| 欧美视频一区二区三区| 亚洲精品国产成人久久av盗摄| 国产精品66部| 国产日韩欧美综合一区| 久久se精品一区二区| 日韩免费视频线观看| 日韩高清不卡在线| 欧美理论电影在线| 亚洲国产精品人人做人人爽| 在线免费av一区| 亚洲国产成人av网| 欧美三区在线视频| 日韩国产欧美在线视频| 欧美日韩国产综合一区二区三区 | 97国产精品videossex| 欧美国产综合一区二区| 成人综合婷婷国产精品久久| 久久精品一二三| 国产精品一区一区三区| 久久久青草青青国产亚洲免观| 久草热8精品视频在线观看| 日韩精品一区在线观看| 精品一区二区三区免费毛片爱| 欧美大片拔萝卜| 国产黄色精品视频| √…a在线天堂一区| 色综合久久精品| 亚洲 欧美综合在线网络| 777久久久精品| 国产美女一区二区| 欧美激情一区二区| 欧美亚洲综合色| 久久国产剧场电影| 国产精品久久久久影院色老大 | 捆绑调教一区二区三区| 日韩美女一区二区三区四区| 精品一区二区在线播放| 国产精品久久久久久久久免费桃花 | 久久综合五月天婷婷伊人| 国产一区二区精品久久99| 亚洲国产成人在线| 91黄色激情网站| 免费观看成人av| 中文天堂在线一区| 91久久人澡人人添人人爽欧美| 日本成人超碰在线观看| 国产欧美日韩精品一区| 欧美色区777第一页| 久久精品国产久精国产| 国产精品动漫网站| 91精品国产综合久久香蕉麻豆| 麻豆freexxxx性91精品| 亚洲女同ⅹxx女同tv| 欧美一区二区成人6969| 91热门视频在线观看| 蜜臀国产一区二区三区在线播放| 国产亚洲欧美在线| 制服丝袜亚洲播放| av亚洲精华国产精华精华| 美女视频免费一区| 亚洲自拍偷拍九九九| 久久久久国产一区二区三区四区| 在线亚洲高清视频| 国产盗摄一区二区| 裸体在线国模精品偷拍| 亚洲国产视频一区| 中文字幕在线不卡视频| 欧美岛国在线观看| 欧美久久久一区| 91麻豆精品视频| 国产成a人亚洲精品| 日本va欧美va瓶| 一区二区三区中文在线观看| 国产欧美精品一区二区色综合朱莉| 欧美日韩二区三区| 欧美在线观看一区二区| 暴力调教一区二区三区| 国产精品一区二区男女羞羞无遮挡| 午夜精品一区在线观看| 亚洲自拍欧美精品| 一区二区三区不卡视频在线观看| 国产日韩精品视频一区| 久久影音资源网| 日韩欧美黄色影院| 欧美大片在线观看一区二区| 欧美乱妇20p| 欧美日本一区二区在线观看| 在线视频综合导航| 91麻豆国产福利在线观看| 成人黄色电影在线| 成a人片亚洲日本久久| 成人午夜av电影| 国产91在线|亚洲| 成人一级片网址| caoporm超碰国产精品| 99热国产精品| 色国产精品一区在线观看| 一本大道av伊人久久综合| 色综合天天性综合| 色综合激情五月| 欧美午夜在线观看| 在线不卡免费欧美| 91精选在线观看| 国产亚洲欧美中文| 国产精品第一页第二页第三页| 亚洲欧美综合另类在线卡通| 亚洲柠檬福利资源导航| 亚洲成人激情自拍| 秋霞影院一区二区| 久久国产麻豆精品| 不卡高清视频专区| 欧美日韩一级黄| 日韩亚洲欧美综合| 久久久久久久精| 一区二区三区在线影院| 婷婷综合久久一区二区三区| 免费在线看成人av| 国产99久久久精品| 欧美午夜一区二区三区| 精品日韩欧美一区二区| 日本一区二区三区久久久久久久久不 | 欧美一区二区不卡视频| 久久综合九色综合欧美就去吻| 久久久久久久久岛国免费| 亚洲乱码日产精品bd| 亚洲图片欧美综合| 国产福利一区二区三区在线视频| 91在线云播放| 欧美一区二区三区免费观看视频| 欧美精品一区在线观看| 亚洲欧美一区二区三区极速播放| 日韩国产精品久久久久久亚洲| 国产呦精品一区二区三区网站| 成人av资源在线| 欧美一区中文字幕| 国产精品久久福利| 日韩电影免费在线观看网站| 福利一区福利二区| 欧美高清视频不卡网| 国产女人水真多18毛片18精品视频 | 99re热这里只有精品免费视频| 欧美视频完全免费看| 久久久久久久精| 亚洲 欧美综合在线网络| 成人中文字幕在线| 日韩精品一区二区三区中文精品| 中文字幕成人在线观看| 免费人成在线不卡| 色爱区综合激月婷婷| 国产人久久人人人人爽| 首页欧美精品中文字幕| 99精品久久只有精品| 精品福利视频一区二区三区| 亚洲精品国产无天堂网2021 | 91美女在线看| 久久综合色天天久久综合图片| 亚洲国产精品久久艾草纯爱 | 欧美视频一区在线| 国产精品美女久久久久aⅴ| 免费不卡在线观看| 欧美日韩高清在线播放| 亚洲天堂免费看| 国产99久久久国产精品免费看| 欧美电影免费观看完整版| 天天免费综合色| 欧美日韩国产综合一区二区| 亚洲欧美成人一区二区三区| 粉嫩高潮美女一区二区三区| 精品久久五月天| 全国精品久久少妇| 91精品国产综合久久精品图片| 一二三四区精品视频| 91亚洲男人天堂| 综合激情成人伊人| 色综合中文字幕国产 | 欧美三电影在线|