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

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

?? task.c

?? mcs51,2051,x86系列MCU
?? C
字號:
/*
 *  ApBUILDER CODE FILE - Intel Corporation
 *
 *
 *  Purpose:      Task control code.
 *                TASK_CONTROL_BLOCK
 *
 *                The TCB functionality is a simple task scheduling system utilizing
 *                a single timer to provide multiple timed events at various intervals.
 *
 *                The system is flexible, but has the needed efficiency for embedded
 *                applications.
 *
 *                In main(), you will find the main task loop, where the task controller
 *                function iterates through the available task control lists.
 *                Each list contains TCB entries.  A TCB entry is composed of 2 items.
 *                First, is the Timer variable.  This is a 1 byte counter that is in 1
 *                of 3 states:
 *
 *                -1    Not Active
 *                0     Active
 *                >0    In the process of counting down to 0, prior to activation.
 *
 *                Second, is a function associated with the timer variable.  The function
 *                is executed each time the task controller iterates through the entry,
 *                and the assocoated timer is set to 0.  Each TCB list contains as many
 *                TCB entries as you wish.  Each TCB list has it's timer variables
 *                decremented periodicly.  The rate at which the block timers are
 *                decremented should be evident by the name of the list..
 *                ie..  Tenth_sec..  has all of its timers decremented every 100ms.
 *                By utilizing the TCB lists, you can schedule functions to execute on
 *                various cycles.  These functions can reset their respective timer
 *                variables to repeat the cycle, or can set the timer variables to -1
 *                to deactivate, effectivly causing a 1-shot type operation.
 *
 *                It is the responsibility of the hardware timer to decrement the most
 *                frequently updated task-list timer variables. (Hundredth_sec) at the
 *                required rate.  A routine in this TCB list is responsible for
 *                decrementing all the Tenth_sec timers at the appropriate rate.
 *                A routine in the Tenth_sec TCB list is responsible for decrementing
 *                all the Whole_sec timers.  In this way, you can acheive 3 lists, each
 *                with differing cycles, but all driven by a single timer resource.
 *
 *                By turning on the TASK_CONTROL_BLOCK_ENABLED switch in global.h,
 *                you enable the feature.
 *
 *
 *                The Software is provided "AS IS."
 *
 *                LIMITATION OF LIABILITY:    NEITHER INTEL NOR ITS VENDORS OR AGENTS
 *                SHALL BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
 *                INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
 *                CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
 *                OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 *                While we have made every attempt to completely test this code, we request that
 *                you personally test it completely prior to actual inclusion in your own projects.
 *
 *  Compiler:     Developed using Compass251 from Production Languages corporation.
 *
 *  Ext Packages: None
 *
 *  Author:       Brad B.
 *
 *  Revisions:
 *
 *
 */


#include "global.h"
#include "main.h"



#ifdef TASK_CONTROL_BLOCK_ENABLED
/* Function prototypes */
static void interrupt timer1_handler(void);     /* Called every 100ms */
static void Hundredth_sec_timer(void);
static void Tenth_sec_timer(void);
static void Stop_Beep(void);                    /* example use function */
static void Flash_led(void);                    /* example use function */
static void Debounce_handler(void);             /* example use function */
static void Task_controller(TCB *);
/* Task timer variables */
static char Tmt_Hundredth_sec = 0;
static char Tmt_Tenth_sec = 10;
static char Tmt_Beep = TASK_DISABLED;    /* example function, 1/2 second single self-terminating beep */
static char Tmt_flash = 2;               /* Toggle a port-bit every 2 seconds (this is an example usage) */
static char Debounce_timer = 2, Debounce_state = 0, Button_state = NOT_PRESSED;

/* Functions, whose execution timers are decremented each hundredth-second (by the hardware timer) */
static const TCB Hundredth_sec[] =
{
   &(Tmt_Hundredth_sec), Hundredth_sec_timer,
   &(Debounce_timer), Debounce_handler,
   END_LIST,0
};
/* Functions, whose execution timers are decremented each tenth-second (by the Hundredth_sec_timer) */
static const TCB Tenth_sec[] =
{
   &(Tmt_Tenth_sec), Tenth_sec_timer,
   &(Tmt_Beep), Stop_Beep,
   END_LIST,0
};
/* Functions, whose execution timers are decremented each whole second (by the Tenth_sec_timer) */
static const TCB Whole_sec[] =
{
   &(Tmt_flash), Flash_led,            /* alternativly, could put this in Tenth_sec TCB, but set Tmt_flash to 20 */
   END_LIST,0
};
#endif      /* end TASK_CONTROL_BLOCK_ENABLED */


/* Below are example routines and necessary control functions for using the TCB functionality */
#ifdef TASK_CONTROL_BLOCK_ENABLED

/* -----------------7/30/96 9:55AM-------------------
   Function: timer1_handler()

   If using TCB functionality, we use Timer1 as the base timer-tick that cycles at 10ms interval, providing
   the 1/100 sec timer decrementing.  Remember, the 10ms timing is not set up by ApBUILDER, you must fill in
   appropriate values in the sfrs[] array at top of file

 * --------------------------------------------------*/

static void interrupt timer1_handler(void)       /* Called every 10ms */
{
   TCB *ptr;

   /* Decrement all timers in Hundredth_sec TCB list */
   for (ptr = &(Hundredth_sec[0]); ptr ->task_flag != END_LIST; ptr ++)
   {
      if (*(ptr -> task_flag) > 0)
      {
         *(ptr -> task_flag) -= 1;
      }
   }
}

/* -----------------7/30/96 9:44AM-------------------
   Function: Task_controller()

   This function is used to iterate through the TCB via it's passed pointer.
   While iterating through the passed TCB, if it finds the task is enabled
   via it's task-flag being set to TASK_ENABLED, it will call the task.

 * --------------------------------------------------*/

static void Task_controller(TCB *tcb_list)
{
   while(tcb_list -> task_flag != END_LIST)        /* while not at end of TCB list */
   {
      if(*tcb_list -> task_flag == TASK_ENABLED)   /* if the timer says the task is ready to execute */
      {
         tcb_list -> task_action();                /* execute the timed task */
      }
      tcb_list++;                                  /* move on to next timed element in the list */
   }
}

/* -----------------7/30/96 9:46AM-------------------
   Function: Hundredth_sec_timer()

   This function is responsible for decrementing all the timer variables
   in the Tenth_sec TCB list.  This allows a single timer to cascade
   through various different TCB lists.

 * --------------------------------------------------*/

static void Hundredth_sec_timer(void)
{
   TCB *ptr;
   Tmt_Hundredth_sec = 10;                             /* Reset timer-variable to re-execute this routine in 1/10 second */

   /* Decrement all timers in Tenth_sec TCB list every 1/10 second */
   for (ptr = &(Tenth_sec[0]); ptr ->task_flag != END_LIST; ptr ++)
   {
      if (*(ptr -> task_flag) > 0)
      {
         *(ptr -> task_flag) -= 1;
      }
   }
}

/* -----------------7/30/96 9:46AM-------------------
   Function: Tenth_sec_timer()

   This function is responsible for decrementing all the timer variables
   in the Whole_sec TCB list.  This allows a single timer to cascade
   through various different TCB lists.

 * --------------------------------------------------*/

static void Tenth_sec_timer(void)
{
   TCB *ptr;
   Tmt_Tenth_sec = 10;                             /* Reset timer-variable to re-execute this routine in 1 second */

   /* Decrement all whole_sec timers every 1/10 second */
   for (ptr = &(Whole_sec[0]); ptr ->task_flag != END_LIST; ptr ++)
   {
      if (*(ptr -> task_flag) > 0)
      {
         *(ptr -> task_flag) -= 1;
      }
   }
}

/* -----------------7/30/96 9:48AM-------------------
   Function: Flash_led()

   Example function, toggles simulated LED on P0.3,
   then re-sets the timer for another 2-second interval.
 * --------------------------------------------------*/

static void Flash_led(void)
{
   Tmt_flash = 2;                /* Count-down and Reset timer.. Reset for 2 second execution again */
   P0 ^= 0x08;                   /* Toggle some bit each 2 seconds */
}

/* -----------------7/30/96 9:49AM-------------------
   Function: beep_it()

   Example function, turns on beep, and sets a timer to expire
   and turn off the beep in 1/2 second.
   Assumes some beeper is activated by setting bit0 of P0 high.
 * --------------------------------------------------*/

static void beep_it(void)
{
   P0 |= 0x01;
   Tmt_Beep = 5;                 /* 5 * 1/10 second = 1/2 second beep */
}

/* -----------------7/30/96 9:50AM-------------------
   Function: Stop_Beep()

   This routine called by Task_controller when Tmt_Beep times
   out (becomes 0).  It simulates turning off a beeper
   by clearing P0.0, and then disables the task timer..
   one-shot usage, non-auto-repeating
 * --------------------------------------------------*/

static void Stop_Beep(void)
{
   Tmt_Beep = TASK_DISABLED;     /* Count-down and terminate timer.. Activated elsewhere */
   P0 &= 0xfe;                   /* Turn off the beeper */
}


/* -----------------7/30/96 9:51AM-------------------
   Function: get_button_push()

   Example function.. Retrieves the state of a button on P0.5
 * --------------------------------------------------*/

void get_button_push(void)
{
   return(Button_state);                           /* PRESSED, or NOT_PRESSED */
}

/* -----------------7/30/96 9:51AM-------------------
   Function: Debounce_handler()

   Simulated active-high button on P0.5.
   Uses state-machine to check button state, utilizing debounce-time
   to ensure we don't respond to a glitch/noise, or get
   multiple responses due to key-bounce.
   This routine Called every 20ms, via 10ms TCB timer, and a timer
   variable (Debounce_timer) set to 2.
 * --------------------------------------------------*/

static void Debounce_handler(void)
{
   static char prev_state = NOT_PRESSED;  /* state variable must have static duration */
   char input_bit;

   Debounce_timer = 2;                    /* reset timer for 20ms delay */

   switch(Debounce_state)
   {
      case 0:                             /* while in state 0, we are looking for an initial transition on P0.5 */
         input_bit =  _BIT(P0,5);
         if (input_bit != prev_state)     /* if signal has transitioned from previous stable state */
         {
            Debounce_state++;             /* move on to next state */
            prev_state = input_bit;
         }
      break;

      case 1:
      case 2:
         Debounce_state++;                /* wait a while to let contacts settle */
      break;

      case 3:
         input_bit = _BIT(P0,5);
         if (input_bit == prev_state)     /* ok, now check to see if it's still in same condition as in state 0 */
         {
            Button_state = prev_state;    /* if it is, then set button state to match it */
         }
         else
         {
            prev_state = input_bit;       /* if it isn't, then we may have received a glitch.. reset prev_state */
         }
         Debounce_state = 0;
      break;
   }
}

#endif      /* TASK_CONTROL_BLOCK_ENABLED */




?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷亚洲一区二区三区| 粉嫩aⅴ一区二区三区四区| 亚洲午夜视频在线| 欧美成人精品福利| 高清国产一区二区三区| 国产一区二区三区视频在线播放| 99久久精品国产一区二区三区| 欧美日韩国产小视频在线观看| 国产午夜精品福利| 日韩精品福利网| 一本色道综合亚洲| 国产精品色哟哟网站| 捆绑紧缚一区二区三区视频| 欧美亚洲国产一区二区三区 | 日韩一级欧美一级| 亚洲精品一二三四区| 国产99一区视频免费| 精品国产一区二区国模嫣然| 日韩精品一卡二卡三卡四卡无卡| 在线看一区二区| 亚洲欧美日韩久久| 色综合色综合色综合色综合色综合 | 一区二区在线看| 奇米精品一区二区三区在线观看一 | 日韩一区二区免费高清| 亚洲色图欧洲色图| eeuss鲁一区二区三区| 久久久精品人体av艺术| 激情五月播播久久久精品| 日韩免费视频一区| 老司机免费视频一区二区 | 中文字幕一区二区三区四区不卡 | 成人开心网精品视频| 久久亚洲精华国产精华液| 美女任你摸久久 | 最新日韩在线视频| 国产精品欧美综合在线| 欧美日本国产视频| 欧美美女视频在线观看| 久久久美女艺术照精彩视频福利播放| 美女性感视频久久| 精品国产乱码91久久久久久网站| 美脚の诱脚舐め脚责91 | 香蕉乱码成人久久天堂爱免费| 91国产成人在线| 日韩电影在线免费看| 日韩女优毛片在线| 风间由美一区二区av101| 国产精品久久久久久亚洲伦| youjizz久久| 首页亚洲欧美制服丝腿| 精品日本一线二线三线不卡| 高清av一区二区| 亚洲欧美视频在线观看视频| 欧美色中文字幕| 九色综合狠狠综合久久| 亚洲国产成人一区二区三区| 91福利区一区二区三区| 麻豆成人av在线| 中文字幕在线一区二区三区| 欧美亚洲高清一区二区三区不卡| 日韩成人免费电影| 欧美—级在线免费片| 欧美日韩免费观看一区三区| 九九**精品视频免费播放| 国产精品毛片a∨一区二区三区 | 色综合久久久久综合99| 免费欧美日韩国产三级电影| 国产欧美日韩三区| 欧美日韩一本到| 懂色av一区二区三区免费看| 亚洲国产成人tv| 国产情人综合久久777777| 欧美在线视频全部完| 国产资源在线一区| 亚洲高清中文字幕| 久久综合久久综合亚洲| 欧美性猛交xxxxxxxx| 国产精品一区二区视频| 性欧美大战久久久久久久久| 中文字幕一区二区三区在线播放 | 亚洲图片欧美综合| 久久久久久影视| 欧美精品日日鲁夜夜添| 99re视频这里只有精品| 日日欢夜夜爽一区| 国产精品黄色在线观看| 日韩欧美精品在线视频| 欧美日韩免费电影| 成人免费看的视频| 韩国一区二区视频| 日本在线不卡视频| 一区二区三区精品| 国产精品毛片久久久久久| 日韩美女视频在线| 欧美日韩日本视频| 成人黄动漫网站免费app| 蜜臂av日日欢夜夜爽一区| 亚洲成人免费视频| 亚洲五月六月丁香激情| 亚洲国产精品成人综合| 精品国产一区a| 日韩亚洲电影在线| 91福利资源站| 91久久精品一区二区| 风间由美一区二区av101| 国产一区二区三区四区五区入口| 裸体歌舞表演一区二区| 另类中文字幕网| 麻豆国产精品777777在线| 日韩精品91亚洲二区在线观看| 午夜精品在线看| 日日摸夜夜添夜夜添精品视频 | 美美哒免费高清在线观看视频一区二区| 亚洲视频狠狠干| 亚洲欧美偷拍三级| 一级中文字幕一区二区| 亚洲视频资源在线| 777亚洲妇女| 成人国产在线观看| 97se亚洲国产综合在线| av不卡一区二区三区| 91视视频在线直接观看在线看网页在线看 | 欧美一区二区国产| 日韩一区二区三区观看| 精品国产亚洲在线| 久久精品亚洲麻豆av一区二区| 欧美国产精品一区二区三区| 国产精品初高中害羞小美女文| 亚洲色图色小说| 舔着乳尖日韩一区| 另类小说视频一区二区| 国产99精品国产| 97久久精品人人爽人人爽蜜臀| 在线观看日韩国产| 欧美一级片在线看| 国产欧美一区二区精品秋霞影院| 亚洲欧洲美洲综合色网| 亚洲一卡二卡三卡四卡无卡久久 | aaa国产一区| 欧美日韩国产美女| 久久精品在这里| 亚洲欧洲成人av每日更新| 午夜在线成人av| 国产一区二区三区黄视频| 99精品1区2区| 日韩亚洲欧美一区二区三区| 国产精品久线观看视频| 亚洲成av人片一区二区| 国产成人免费9x9x人网站视频| 91福利视频网站| 精品不卡在线视频| 一区二区三区在线视频免费| 国产精品视频看| 国产日韩欧美精品在线| 一区二区三区高清不卡| 国产一区二区三区免费播放| 91久久精品日日躁夜夜躁欧美| 欧美mv日韩mv| 亚洲高清视频在线| 不卡的av中国片| 日韩小视频在线观看专区| 亚洲乱码国产乱码精品精的特点| 蜜臀av亚洲一区中文字幕| 97se狠狠狠综合亚洲狠狠| 日韩精品一区二区三区老鸭窝| 亚洲乱码日产精品bd| 粉嫩av亚洲一区二区图片| 欧美一卡2卡三卡4卡5免费| 亚洲人快播电影网| 国产精品亚洲第一区在线暖暖韩国| 欧美日韩五月天| 中文字幕日本不卡| 国产高清不卡一区| 欧美成人bangbros| 日韩经典中文字幕一区| 色综合天天综合色综合av| 国产亚洲精品aa| 精品在线视频一区| 91精品国产色综合久久不卡电影 | 国产在线播放一区| 欧美一区二区网站| 午夜伦欧美伦电影理论片| 色婷婷久久久久swag精品| 国产精品国产三级国产普通话99 | 在线精品视频免费播放| 国产精品乱码一区二区三区软件| 日韩久久久久久| 成熟亚洲日本毛茸茸凸凹| 中文av字幕一区| 99re免费视频精品全部| 亚洲在线成人精品| 制服丝袜成人动漫| 精品在线播放免费| 中文字幕欧美一| 日本精品免费观看高清观看| 亚洲一区在线观看网站| 欧美日韩国产高清一区二区三区 | 国产欧美日韩综合精品一区二区| 日本中文字幕一区二区视频 |