亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久成人免费电影| 日韩一区二区三区四区| 成人18视频日本| 国产.欧美.日韩| 国产91精品露脸国语对白| 国产高清在线精品| 国产91精品久久久久久久网曝门| 国产精品一二三| 成人午夜短视频| 9色porny自拍视频一区二区| 91丨国产丨九色丨pron| 91蜜桃婷婷狠狠久久综合9色| 91玉足脚交白嫩脚丫在线播放| 色综合久久中文综合久久牛| 色欧美片视频在线观看| 欧美高清激情brazzers| 欧美不卡在线视频| 久久网这里都是精品| 国产精品色哟哟网站| 亚洲欧美日韩在线| 亚洲成a人片在线不卡一二三区 | 亚洲国产aⅴ成人精品无吗| 亚洲一级在线观看| 日韩成人一区二区| 国产资源精品在线观看| 成人黄色片在线观看| 欧美日韩在线电影| 精品国产区一区| 国产精品私人自拍| 一区二区成人在线| 久久精品免费看| 国产成a人无v码亚洲福利| 色先锋久久av资源部| 日韩午夜电影av| 中文字幕欧美激情| 亚洲国产你懂的| 国产一区二区三区免费看| av一区二区久久| 欧美一级欧美三级在线观看| 国产亚洲精品超碰| 亚洲亚洲精品在线观看| 黄网站免费久久| 色美美综合视频| 精品国产在天天线2019| 《视频一区视频二区| 免费观看在线色综合| 成人国产精品免费网站| 欧美精品乱人伦久久久久久| 中文字幕av一区二区三区| 亚洲成人免费电影| 成人午夜看片网址| 日韩欧美一级在线播放| 成人欧美一区二区三区白人 | 波多野结衣欧美| 7777女厕盗摄久久久| 国产精品欧美综合在线| 色综合天天综合| 欧美电视剧在线看免费| 亚洲色图.com| 久久99久久精品| 日韩avvvv在线播放| 成人精品国产一区二区4080| 欧美久久久久免费| 自拍视频在线观看一区二区| 精品一区二区免费看| 在线亚洲一区观看| 国产精品视频一区二区三区不卡| 日韩综合小视频| 97久久精品人人爽人人爽蜜臀| 精品国产自在久精品国产| 五月激情丁香一区二区三区| 9久草视频在线视频精品| 久久久99久久精品欧美| 日韩avvvv在线播放| 欧洲一区在线观看| 国产精品进线69影院| 国产一本一道久久香蕉| 日韩欧美在线网站| 午夜精品福利在线| 欧洲视频一区二区| 亚洲人妖av一区二区| 粉嫩av一区二区三区在线播放| 欧美大片在线观看一区二区| 亚洲成av人片在线观看无码| 99精品视频一区| 国产欧美视频在线观看| 久久99精品久久久久久久久久久久| 欧美美女一区二区三区| 一区二区三区国产豹纹内裤在线| 精品电影一区二区三区| 久久综合九色综合97婷婷| 天天做天天摸天天爽国产一区 | 色噜噜狠狠成人中文综合| 国产欧美日韩不卡| 国产精品小仙女| 精品国产91乱码一区二区三区| 日本不卡高清视频| 欧美一级高清大全免费观看| 亚洲成人av福利| 欧美精品黑人性xxxx| 亚洲福利视频导航| 欧美午夜精品一区二区三区| 一区二区三区在线视频观看| 91久久精品一区二区三| 亚洲精品乱码久久久久| 色综合色综合色综合色综合色综合| 日韩理论片中文av| 91视频一区二区三区| 亚洲天堂免费看| 一本色道**综合亚洲精品蜜桃冫| 中文字幕一区在线| 91啪九色porn原创视频在线观看| 日韩毛片视频在线看| 一本一道久久a久久精品| 亚洲一区二区在线免费观看视频| 欧美体内she精视频| 视频一区二区三区中文字幕| 成人激情动漫在线观看| 成人丝袜视频网| 国产精品午夜春色av| 久久免费偷拍视频| 福利一区二区在线| |精品福利一区二区三区| 色天使久久综合网天天| 天天做天天摸天天爽国产一区 | 亚洲一区二区三区自拍| 欧美日韩成人高清| 蜜臀av在线播放一区二区三区| 久久夜色精品国产欧美乱极品| 成人黄色免费短视频| 玉米视频成人免费看| 欧美喷水一区二区| 国内成人自拍视频| 亚洲欧美一区二区久久 | 亚洲欧美偷拍卡通变态| 欧美日韩另类国产亚洲欧美一级| 美女任你摸久久| 国产精品视频免费看| 欧美中文字幕一区二区三区亚洲| 美国十次综合导航| 亚洲欧美怡红院| 日韩欧美中文字幕精品| www.66久久| 日韩高清欧美激情| 欧美国产日本韩| 欧美午夜精品理论片a级按摩| 91精品视频网| 国产成人精品免费一区二区| 亚洲欧美日韩中文字幕一区二区三区 | 国产蜜臀97一区二区三区 | 亚洲免费在线观看| 日韩三级免费观看| 99热在这里有精品免费| 日本美女视频一区二区| 国产精品二三区| 日韩亚洲欧美一区二区三区| 成人av电影观看| 全国精品久久少妇| 综合欧美亚洲日本| 2欧美一区二区三区在线观看视频| 一本色道久久加勒比精品| 国内精品国产成人| 婷婷国产v国产偷v亚洲高清| 国产精品美女久久久久久久久| 欧美久久久久久蜜桃| 91色九色蝌蚪| 国产精品综合二区| 日韩国产高清影视| 亚洲品质自拍视频网站| 国产亚洲成aⅴ人片在线观看| 欧美久久久久久久久中文字幕| 成人av片在线观看| 韩国在线一区二区| 日韩极品在线观看| 艳妇臀荡乳欲伦亚洲一区| 国产精品久久久久久妇女6080 | 一区二区三区在线视频观看| 欧美国产日韩亚洲一区| 精品久久久久久久久久久久包黑料 | 久久精品日韩一区二区三区| 欧美日韩在线观看一区二区| av电影在线观看完整版一区二区| 激情五月播播久久久精品| 亚洲高清免费在线| 综合亚洲深深色噜噜狠狠网站| 久久女同互慰一区二区三区| 欧美一级午夜免费电影| 欧美日韩视频在线一区二区 | 一区二区三区国产精品| 亚洲视频一区在线| 成人免费在线视频| 国产亚洲制服色| 久久综合九色综合97婷婷 | 麻豆成人av在线| 日本欧美一区二区| 日韩在线a电影| 日韩国产精品久久久久久亚洲| 亚洲国产精品精华液网站 | 91国产免费观看| 色呦呦一区二区三区|