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

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

?? sch51.c

?? 51系列具有PWM斷口的單片機PWM調制程序.
?? 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一区二区三区免费野_久草精品视频
色综合天天综合网国产成人综合天 | 国产在线精品免费| 99re成人在线| 日韩无一区二区| 一区在线中文字幕| 国产剧情一区二区| 欧美卡1卡2卡| 亚洲色图都市小说| 国产精品亚洲一区二区三区在线| 欧美日韩一级片网站| 中文字幕在线不卡| 国产激情91久久精品导航| 欧美一级日韩免费不卡| 中文在线一区二区| 国产一区二区三区不卡在线观看 | 日韩精品一区国产麻豆| 亚洲一区二区三区精品在线| 成人动漫在线一区| 日本一区二区久久| 韩国v欧美v日本v亚洲v| 欧美一区二区三区日韩视频| 天堂在线一区二区| 欧美日韩一区三区| 亚洲一区二区三区四区中文字幕| 成人高清视频在线| 日韩美女视频一区二区| 99久久精品免费观看| 国产精品国产三级国产三级人妇| 福利91精品一区二区三区| 国产日产欧美一区| 国产91丝袜在线18| 国产精品网站在线播放| 成人免费av网站| **网站欧美大片在线观看| 94色蜜桃网一区二区三区| 亚洲视频网在线直播| 91丝袜高跟美女视频| 依依成人精品视频| 欧美亚洲图片小说| 日韩高清在线观看| 欧美大片拔萝卜| 国产在线麻豆精品观看| 中文字幕免费在线观看视频一区| 丁香激情综合五月| 亚洲另类色综合网站| 欧美三级中文字| 青青草97国产精品免费观看无弹窗版| 欧美一区二区三区在线| 国产在线麻豆精品观看| 国产精品久久久久永久免费观看 | 国产精品99久久久久久久女警 | 偷拍与自拍一区| 日韩欧美一卡二卡| 粉嫩嫩av羞羞动漫久久久 | 久久久亚洲综合| 99久久精品情趣| 亚洲成av人片在线观看| 2020国产成人综合网| 91性感美女视频| 日本中文一区二区三区| 中文字幕精品三区| 欧美四级电影网| 国产精品一区二区视频| 亚洲综合精品自拍| 久久久不卡网国产精品一区| 色菇凉天天综合网| 国内精品久久久久影院薰衣草| 亚洲天堂免费看| 日韩女优制服丝袜电影| 99re这里都是精品| 久久精品99国产精品日本| 亚洲精品久久久久久国产精华液| 日韩午夜在线观看| 不卡欧美aaaaa| 美腿丝袜亚洲色图| 亚洲另类在线视频| 国产日韩亚洲欧美综合| 欧美一区二区三区在线| 97久久精品人人澡人人爽| 另类小说色综合网站| 一区二区三区在线免费观看| 久久久精品黄色| 欧美成va人片在线观看| 欧美性猛片aaaaaaa做受| 国产乱码精品1区2区3区| 亚洲午夜久久久久久久久久久 | 亚洲福利电影网| 日本一二三四高清不卡| 日韩美女主播在线视频一区二区三区| 91成人免费在线| av中文字幕一区| 丰满少妇久久久久久久| 狠狠网亚洲精品| 日韩不卡一区二区三区| 亚洲成人一二三| 亚洲愉拍自拍另类高清精品| 亚洲视频在线观看三级| 国产精品毛片大码女人| 26uuu久久综合| 欧美mv日韩mv国产网站| 777奇米成人网| 精品视频1区2区| 欧美性色aⅴ视频一区日韩精品| www.亚洲在线| 91亚洲永久精品| 91天堂素人约啪| 91在线观看成人| 99在线视频精品| 99久久精品久久久久久清纯| 成人永久免费视频| 成人黄色免费短视频| 国产91丝袜在线18| 成人av免费网站| 99re成人在线| 欧美性猛交xxxxxx富婆| 欧美自拍偷拍午夜视频| 欧美日韩一级二级三级| 欧美日韩国产成人在线免费| 欧美日本一区二区三区四区| 欧美欧美午夜aⅴ在线观看| 欧美日韩一区久久| 91精品国产91久久久久久一区二区| 欧美美女喷水视频| 欧美第一区第二区| 精品成人免费观看| 国产精品久久久久久亚洲毛片| 日韩理论片在线| 亚洲永久精品大片| 蜜桃91丨九色丨蝌蚪91桃色| 精品一区二区三区在线播放视频 | 亚洲国产精品黑人久久久| 国产精品久久久久久亚洲毛片| 亚洲手机成人高清视频| 亚洲成人动漫精品| 久久国产精品区| 岛国一区二区三区| 欧美三级视频在线观看| 欧美变态口味重另类| 国产精品久久久久影院色老大| 亚洲一区影音先锋| 精品一区二区三区久久| 成人v精品蜜桃久久一区| 欧美亚洲国产一区二区三区va| 欧美一区二区大片| 国产精品乱码人人做人人爱 | 国产在线国偷精品产拍免费yy| 成人黄色一级视频| 欧美久久久久久久久久| 久久久久国产一区二区三区四区| 日韩毛片在线免费观看| 日韩精品午夜视频| 成人不卡免费av| 日韩免费一区二区| 亚洲日本在线天堂| 久久精品国产免费| 在线亚洲一区二区| 久久综合精品国产一区二区三区| 亚洲色图欧美激情| 国产专区综合网| 欧美猛男gaygay网站| 中文字幕av一区二区三区高| 日韩vs国产vs欧美| 日本福利一区二区| 国产日韩精品久久久| 免费在线成人网| 色一情一乱一乱一91av| www国产精品av| 日本不卡视频在线| 91传媒视频在线播放| 欧美—级在线免费片| 久久99热99| 欧美精选一区二区| 一区二区三区在线免费视频| 国产suv一区二区三区88区| 欧美美女一区二区三区| 一区二区三区在线观看网站| 成人黄色片在线观看| 久久精品视频一区| 精品一区二区三区日韩| 欧美日韩国产高清一区二区三区 | 欧美大片一区二区三区| 五月婷婷久久丁香| 色偷偷久久一区二区三区| 欧美极品aⅴ影院| 国产精品亚洲专一区二区三区| 欧美一区二区三区色| 日韩精品欧美成人高清一区二区| 色天使色偷偷av一区二区| 中文字幕亚洲一区二区av在线| 国产精品123| 国产三级欧美三级| 国产精品白丝jk黑袜喷水| 精品国产1区二区| 久久狠狠亚洲综合| 精品国产乱码久久久久久免费 | 日本不卡高清视频| 91精品啪在线观看国产60岁| 五月天亚洲婷婷| 欧美一区二区三区免费| 久久精品理论片|