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

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

?? sch51.c

?? 時間觸發(fā)嵌入式系統(tǒng)設計模式源碼
?? 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精品在线观看| 手机精品视频在线观看| 中文字幕亚洲欧美在线不卡| 精品人在线二区三区| 欧美日韩视频专区在线播放| 不卡一区二区在线| 国产精品综合一区二区| 日本最新不卡在线| 亚洲成人免费影院| 中文字幕在线不卡| 国产调教视频一区| 日韩美女一区二区三区| 欧美情侣在线播放| 欧美在线综合视频| 日本韩国欧美一区二区三区| 97精品久久久午夜一区二区三区 | 国产电影一区在线| 久久er精品视频| 日韩1区2区日韩1区2区| 一区二区理论电影在线观看| 综合在线观看色| 中日韩av电影| 国产精品妹子av| 欧美激情一区二区三区在线| 久久精品水蜜桃av综合天堂| 亚洲精品在线一区二区| 日韩欧美专区在线| 日韩久久精品一区| 欧美xxxx老人做受| 亚洲精品一线二线三线无人区| 宅男在线国产精品| 欧美一区二区性放荡片| 欧美一区二区三区免费大片 | 在线免费不卡视频| 欧美调教femdomvk| 欧美三级日本三级少妇99| 欧美一a一片一级一片| 欧美日韩在线播放三区| 欧美精品免费视频| 91 com成人网| 精品人在线二区三区| 久久久99免费| 国产精品传媒在线| 一区二区三区四区在线| 亚洲一区欧美一区| 日本亚洲免费观看| 国内偷窥港台综合视频在线播放| 国产精品自拍三区| 91日韩在线专区| 欧美理论电影在线| 日韩欧美高清一区| 亚洲国产经典视频| 一区二区成人在线观看| 青青青伊人色综合久久| 国产一区二区三区综合| 成人免费高清在线| 欧美亚洲愉拍一区二区| 欧美成人女星排名| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 婷婷综合五月天| 精品在线你懂的| 不卡一区中文字幕| 欧美美女直播网站| 久久久久久久综合日本| 亚洲色图另类专区| 日本不卡一二三区黄网| 国产精品1024| 欧美网站一区二区| 精品对白一区国产伦| 中文字幕中文乱码欧美一区二区| 一区二区免费在线| 国产乱码精品一区二区三区av | 欧美理论片在线| 国产午夜精品理论片a级大结局| 一区精品在线播放| 秋霞电影网一区二区| 不卡在线视频中文字幕| 欧美一区二区人人喊爽| 国产精品久久免费看| 日韩影视精彩在线| jizz一区二区| 精品国产三级电影在线观看| 亚洲激情图片qvod| 国产一区二区三区黄视频 | 国产一区二区三区不卡在线观看 | 亚洲女爱视频在线| 国产麻豆精品theporn| 在线看不卡av| 中文字幕乱码一区二区免费| 天天影视网天天综合色在线播放| 成人国产视频在线观看| 欧美大片在线观看| 亚洲国产一区二区三区| 成人网男人的天堂| 亚洲精品在线三区| 日韩中文字幕一区二区三区| 成人动漫av在线| 久久影院午夜论| 日本不卡视频在线观看| 欧美影院一区二区| 中文字幕一区在线观看| 久久99深爱久久99精品| 欧美日韩激情一区二区三区| 亚洲免费在线观看视频| 粉嫩嫩av羞羞动漫久久久| 精品日韩一区二区| 日韩电影在线一区二区| 91久久一区二区| 亚洲欧洲精品天堂一级| 国产成人免费视频网站高清观看视频 | 99riav久久精品riav| 久久久久久久久久久99999| 免费成人在线影院| 欧美日韩高清在线| 亚洲综合色在线| 在线视频你懂得一区| 亚洲欧美日本在线| 大美女一区二区三区| 久久精品欧美一区二区三区麻豆| 韩国中文字幕2020精品| 精品免费日韩av| 精品一区二区免费| 日韩精品一区二区三区视频| 麻豆国产精品一区二区三区| 69堂亚洲精品首页| 丝袜亚洲精品中文字幕一区| 色综合天天做天天爱| 综合欧美亚洲日本| 色香蕉成人二区免费| 一区二区三区中文字幕在线观看| 91香蕉视频黄| 日本一二三不卡| 91网站在线播放| 国产精品欧美一区二区三区| 国产在线国偷精品免费看| 日韩欧美电影一区| 极品美女销魂一区二区三区免费| 日韩午夜在线影院| 麻豆91在线播放| 久久久美女艺术照精彩视频福利播放| 麻豆一区二区三区| 久久综合狠狠综合| 国产**成人网毛片九色 | 国产日产欧美精品一区二区三区| 国产福利不卡视频| 中文字幕在线观看不卡| 成人丝袜18视频在线观看| 国产精品三级电影| 色狠狠av一区二区三区| 亚洲成人1区2区| 精品久久五月天| 国产一区二区网址| 国产精品二三区| 欧美日韩一区二区三区高清 | 国产精品私房写真福利视频| 99久久婷婷国产综合精品| 亚洲蜜臀av乱码久久精品蜜桃| 91福利在线免费观看| 日韩精品乱码av一区二区| 欧美一区中文字幕| 国产白丝网站精品污在线入口| 亚洲天堂免费在线观看视频| 欧美狂野另类xxxxoooo| 国产一区二区三区最好精华液| 日韩美女视频一区二区 | 一区二区日韩电影| 日韩精品一区二区三区老鸭窝| 成人中文字幕电影| 亚洲午夜久久久久久久久电影院 | 欧美午夜精品理论片a级按摩| 五月婷婷综合在线| 国产视频一区二区在线| 欧美影视一区在线| 国产美女在线观看一区| 亚洲激情图片qvod| 久久嫩草精品久久久久| 色视频欧美一区二区三区| 久久国产精品无码网站| 亚洲婷婷国产精品电影人久久| 日韩欧美一区二区不卡| 91视频在线观看| 国产在线看一区| 一个色妞综合视频在线观看| 精品国产人成亚洲区| 在线免费不卡视频| 国产乱码精品一区二区三区忘忧草 | 青青草视频一区| 国产精品看片你懂得| 色噜噜夜夜夜综合网| 九一九一国产精品| 一区二区三区国产精品| 国产夜色精品一区二区av| 91精品国产综合久久久久久| 波多野结衣在线一区| 美女久久久精品| 亚洲一区在线观看视频| 国产精品国产三级国产普通话蜜臀|