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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? sch51.c

?? 基于時間觸發(fā)調(diào)度器的直流電機閉環(huán)控制
?? 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久久香蕉国产日韩欧美9色| 精品国产网站在线观看| 久久精品国产99国产| 亚洲美腿欧美偷拍| 国产精品高潮久久久久无| 久久精品无码一区二区三区| 精品国产亚洲在线| 亚洲午夜精品在线| 日日骚欧美日韩| 亚洲国产aⅴ成人精品无吗| 成人晚上爱看视频| 丁香天五香天堂综合| 国产成人免费在线观看不卡| 粉嫩一区二区三区在线看| 欧美喷潮久久久xxxxx| 欧美日本不卡视频| 亚洲免费观看在线观看| 波多野洁衣一区| 91麻豆视频网站| 欧美日韩国产天堂| 亚洲卡通动漫在线| 婷婷综合另类小说色区| 国产另类ts人妖一区二区| 成人ar影院免费观看视频| 欧美色大人视频| 日韩丝袜情趣美女图片| 精品久久人人做人人爽| 中文字幕一区二区三区不卡| 亚洲va国产va欧美va观看| 国产ts人妖一区二区| 久久久久国产精品厨房| 亚洲成av人片一区二区梦乃 | hitomi一区二区三区精品| 久久夜色精品国产噜噜av| 亚洲人成伊人成综合网小说| 国产高清无密码一区二区三区| 久久亚洲精精品中文字幕早川悠里| 日韩国产欧美在线观看| 国产丶欧美丶日本不卡视频| 久久精品夜色噜噜亚洲a∨| 国产一区二区久久| 色菇凉天天综合网| 一区二区高清视频在线观看| 国产一区二区在线观看视频| 日韩精品在线网站| 亚洲国产精品人人做人人爽| 色狠狠av一区二区三区| 午夜欧美大尺度福利影院在线看| 欧美日韩国产乱码电影| 美女网站视频久久| 欧美性大战xxxxx久久久| 国产精品免费人成网站| 麻豆极品一区二区三区| 久久久久久久久久久电影| 成人精品国产一区二区4080| 亚洲精品一卡二卡| 欧美一区二区在线免费观看| 亚洲精品免费看| 欧美精品日韩综合在线| 亚洲一区在线观看免费 | 午夜精品福利在线| 久久美女艺术照精彩视频福利播放 | 欧美极品美女视频| 九一久久久久久| 欧美一区二区三区在线观看| 国产精品77777| 亚洲综合av网| 久久在线观看免费| 91免费观看在线| 日韩成人免费在线| 国产精品久久看| 666欧美在线视频| 亚洲一区二区三区影院| 久久只精品国产| 日本韩国精品在线| 国产成人自拍网| 天天操天天色综合| 亚洲欧洲av在线| 欧美刺激脚交jootjob| 99国产一区二区三精品乱码| 中文字幕一区二区三区四区 | 日韩**一区毛片| 国产精品久久综合| 欧美xxxxx裸体时装秀| 欧美视频一区二区三区在线观看| 国产成人综合视频| 蜜桃视频在线一区| 亚洲一区二区三区四区在线观看| 国产婷婷一区二区| 日韩免费观看2025年上映的电影| 一本久久a久久免费精品不卡| 中文字幕一区二区三区精华液| 欧美成人精品3d动漫h| 在线观看亚洲a| 蜜臀精品久久久久久蜜臀| 亚洲精品日产精品乱码不卡| 国产亚洲婷婷免费| 精品国产制服丝袜高跟| 欧美午夜影院一区| 91伊人久久大香线蕉| 风流少妇一区二区| 国产裸体歌舞团一区二区| 久久国产精品99久久人人澡| 丝袜亚洲精品中文字幕一区| 亚洲精品欧美激情| 亚洲婷婷综合久久一本伊一区| 欧美午夜一区二区三区免费大片| av电影在线观看不卡| 成人免费视频网站在线观看| 国产一区二区福利视频| 韩国v欧美v日本v亚洲v| 亚洲男同性恋视频| 亚洲欧洲国产日本综合| 国产精品国产三级国产aⅴ无密码| 国产性天天综合网| 国产欧美精品国产国产专区| 色视频欧美一区二区三区| 99精品偷自拍| 91浏览器在线视频| 欧美日韩一区二区三区四区五区| 在线观看91视频| 欧美精品日韩综合在线| 欧美一区二区三区播放老司机| 欧美一级国产精品| 久久综合资源网| 日本一区二区免费在线 | 精品美女被调教视频大全网站| 欧美一区二区免费视频| 精品国产乱码久久久久久久久| 精品久久久久久久一区二区蜜臀| 欧美福利视频一区| 久久9热精品视频| 久久精品国产精品亚洲综合| 久久国产麻豆精品| 国产精品伊人色| 99视频国产精品| 在线视频亚洲一区| 欧美一区二区二区| 日韩久久精品一区| 国产精品毛片无遮挡高清| 亚洲视频在线观看一区| 亚洲一区中文在线| 日本午夜精品视频在线观看| 国产麻豆91精品| 色婷婷av久久久久久久| 91精品欧美久久久久久动漫 | 亚洲福利一区二区三区| 免费在线成人网| 亚洲国产一区二区a毛片| 午夜电影一区二区| 国产成人综合亚洲91猫咪| 91久久免费观看| 久久综合九色综合久久久精品综合| 欧美激情综合五月色丁香小说| 亚洲综合网站在线观看| 久久国产欧美日韩精品| 在线亚洲欧美专区二区| 欧美mv日韩mv| 亚洲一区二区三区四区在线| 国内精品写真在线观看| 色网综合在线观看| 久久一二三国产| 亚洲国产aⅴ天堂久久| 丁香天五香天堂综合| 欧美一区欧美二区| 亚洲靠逼com| 风流少妇一区二区| 91精品国产综合久久香蕉麻豆| 国产精品青草久久| 精品在线视频一区| 欧美精品一级二级三级| 综合分类小说区另类春色亚洲小说欧美 | 精品国产青草久久久久福利| 亚洲精品国产第一综合99久久 | 视频一区在线视频| 99精品一区二区| 亚洲国产精品av| 狠狠色丁香婷婷综合| 4438亚洲最大| 午夜精品在线看| 在线观看免费一区| 中文字幕免费观看一区| 久久99精品久久久| 日韩情涩欧美日韩视频| 亚洲高清一区二区三区| 在线精品视频免费观看| 国产精品久久久久aaaa樱花| 国产99一区视频免费| 久久人人超碰精品| 极品少妇一区二区三区精品视频| 欧美一区二区三区视频在线观看 | 在线观看av一区| 亚洲激情图片一区| 色综合天天综合在线视频| 精品成a人在线观看| 日韩高清在线一区| 欧美人xxxx| 日本伊人色综合网| 欧美高清视频一二三区 | 欧美午夜寂寞影院|