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

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

?? timer.cpp

?? C++嵌入系統實例不是很全,總共7個分別是2,3,5,6,7,8,9
?? CPP
字號:
/**********************************************************************
 *
 * Filename:    timer.cpp
 * 
 * Description: A software timer class implemented over top of the
 *              hardware timer within the Intel 8018xEB processor.
 *
 * Notes:       Some of the constants in this file are specific to 
 *              Arcom's Target188EB hardware.
 *
 * 
 * Copyright (c) 1998 by Michael Barr.  This software is placed into
 * the public domain and may be used for any purpose.  However, this
 * notice must not be changed or removed and no warranty is either
 * expressed or implied by its publication or distribution.
 **********************************************************************/

#include <dos.h>                     // For enable() and disable().

#include "i8018xEB.h"
#include "timer.h"


#ifndef NULL
#define NULL  (void *) 0L
#endif


#define CYCLES_PER_TICK 6250       // Number of clock cycles per tick.
#define MS_PER_TICK     1          // Number of milliseconds per tick.


class TimerList
{
    public:

        TimerList();

        void     insert(Timer * pTimer);
        Timer *  remove(Timer * pTimer);

        void     tick(void);
 
    private:

        Timer *  pTop;

};

TimerList timerList;


/**********************************************************************
 *
 * Function:    TimerList()
 * 
 * Description: Create and initialize a linked list of timers.
 *
 * Notes:       
 *
 * Returns:     None defined.
 *
 **********************************************************************/
TimerList::TimerList(void)
{
    pTop = NULL;

}   /* TimerList() */


/**********************************************************************
 *
 * Method:      insert()
 *
 * Description: Insert a timer into an ordered linked list.
 *
 * Notes:       This routine disables interrupts.
 * 
 * Returns:     None defined.
 *
 **********************************************************************/
void
TimerList::insert(Timer * pTimer)
{
    Timer **  ppPrev = &this->pTop;


    disable();

    //
    // Initialize the new timer's tick count.
    //
    pTimer->count = pTimer->length;

    //
    // Walk down the timer list, subtracting ticks as we go.
    //
    while (*ppPrev != NULL && pTimer->count >= (*ppPrev)->count)
    {
        pTimer->count -= (*ppPrev)->count;
        ppPrev = &(*ppPrev)->pNext;
    }
    
    // 
    // Insert the new timer at this point in the timer list.
    //
    pTimer->pNext = *ppPrev;
    *ppPrev = pTimer;
  
    //
    // Adjust the tick count of the next timer (if any).
    //
    if (pTimer->pNext != NULL)
    {
        pTimer->pNext->count -= pTimer->count;
    } 

    enable();

}   /* insert() */


/**********************************************************************
 *
 * Method:      remove()
 *
 * Description: Remove a timer from the timer list.
 *
 * Notes:       This routine disables interrupts.
 * 
 * Returns:     A pointer to the removed timer, NULL if it wasn't
 *              found in the timer list.
 *
 **********************************************************************/
Timer *
TimerList::remove(Timer * pTimer)
{
    Timer **  ppPrev = &this->pTop;


    disable();

    //
    // Walk down the linked list until the dead timer is found.
    //
    while (*ppPrev != NULL && *ppPrev != pTimer)
    {
        ppPrev = &(*ppPrev)->pNext;
    }

    //
    // Remove the dead timer from the linked list.
    //
    if (*ppPrev != NULL)
    {
        *ppPrev = pTimer->pNext;
        (*ppPrev)->count += pTimer->count;
    }

    enable();

    return (*ppPrev);

}   /* remove() */


/**********************************************************************
 *
 * Method:      tick()
 *
 * Description: Update the linked list of timers for a clock tick.
 *
 * Notes:       The caller is responsible for disabling interrupts.
 * 
 * Returns:     None defined.
 *
 **********************************************************************/
void
TimerList::tick()
{
    Timer **  ppTop  = &this->pTop;


    if (*ppTop != NULL)
    {
        //
        // Decrement the tick count of the first timer in the list.
        //
        (*ppTop)->count--;

        //
        // Mark all of the expired timers done and remove them.
        //
        while (*ppTop != NULL && (*ppTop)->count == 0)
        {
            (*ppTop)->state = Done;
            *ppTop = (*ppTop)->pNext;
        }                                   
    }

}   /* tick() */


/**********************************************************************
 * 
 * Method:      Interrupt()
 *
 * Description: An interrupt handler for the timer hardware.
 *
 * Notes:       This method is declared static, so that we cannot 
 *              inadvertently modify any of the software timers.
 *
 * Returns:     None defined.
 *
 **********************************************************************/
void interrupt
Timer::Interrupt()
{
    //
    // Decrement the active timer's count.
    //
    timerList.tick();

    //
    // Acknowledge the timer interrupt.
    //
    gProcessor.pPCB->intControl.eoi = EOI_NONSPECIFIC;

    //
    // Clear the Maximum Count bit (to start the next cycle). 
    //
    gProcessor.pPCB->timer[2].control &= ~TIMER_MAXCOUNT;

}   /* Interrupt() */


/**********************************************************************
 * 
 * Method:      Timer()
 *
 * Description: Constructor for the Timer class.
 *
 * Notes:    
 *
 * Returns:     None defined.
 *
 **********************************************************************/
Timer::Timer(void)
{
    static int bInitialized = 0;


    //
    // Initialize the new software timer.
    //
    state  = Idle;
    type   = OneShot;
    length = 0;
    count  = 0;
    pNext  = NULL;

    //
    // Initialize the timer hardware, if not previously done.
    //
    if (!bInitialized)
    {
        //
        // Install the interrupt handler and enable timer interrupts.
        //
        gProcessor.installHandler(TIMER2_INT, Timer::Interrupt);
        gProcessor.pPCB->intControl.timerControl &= 
                                 ~(TIMER_MASK | TIMER_PRIORITY);

        // 
        // Initialize the hardware device (use Timer #2).
        // 
        gProcessor.pPCB->timer[2].count = 0;
        gProcessor.pPCB->timer[2].maxCountA = CYCLES_PER_TICK;
        gProcessor.pPCB->timer[2].control = TIMER_ENABLE 
                                          | TIMER_INTERRUPT
                                          | TIMER_PERIODIC;

        //
        // Mark the timer hardware initialized.
        //
        bInitialized = 1;
    }

}   /* Timer() */


/**********************************************************************
 * 
 * Method:      ~Timer()
 *
 * Description: Destructor for the Timer class.
 *
 * Notes:       This routine ensures that the timer isn't left dangling
 *              in the timer list.
 *
 * Returns:     None defined.
 *
 **********************************************************************/
Timer::~Timer(void)
{
    //
    // Cancel the timer.
    //
    this->cancel();

}   /* ~Timer() */


/**********************************************************************
 * 
 * Method:      start()
 *
 * Description: Start a software timer, based on the tick from the
 *              underlying hardware timer.
 *
 * Notes:    
 *
 * Returns:     0 on success, -1 if the timer is already in use.
 *
 **********************************************************************/
int
Timer::start(unsigned int nMilliseconds, TimerType timerType)
{
    if (state != Idle)
    {
        return (-1);
    }

    //
    // Initialize the software timer.
    //
    type   = timerType;
    length = nMilliseconds / MS_PER_TICK;
    state  = Active;

    //
    // Add this timer to the active timer list.
    //
    timerList.insert(this);

    return (0);

}   /* start() */


/**********************************************************************
 * 
 * Method:      waitfor()
 *
 * Description: Wait for the software timer to finish.
 *
 * Notes:    
 *
 * Returns:     0 on success, -1 if the timer is not running.
 *
 **********************************************************************/
int
Timer::waitfor()
{
    if (state != Active)
    {
        return (-1);
    }

    //
    // Wait for the timer to expire.
    //
    while (state != Done);

    //
    // Restart or idle the timer, depending on its type.
    //
    if (type == Periodic)
    {
        state = Active;
        timerList.insert(this);
    }
    else
    {
        state = Idle;
    }

    return (0);

}   /* waitfor() */


/**********************************************************************
 * 
 * Method:      cancel()
 *
 * Description: Stop a running timer.
 *
 * Notes:
 *
 * Returns:     None defined.
 *
 **********************************************************************/
void
Timer::cancel(void)
{
    // 
    // Remove the timer from the timer list.
    //
    if (state == Active)
    {
        timerList.remove(this);
    }

    //
    // Reset the timer's state.
    //
    state = Idle; 

}   /* cancel() */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
人人狠狠综合久久亚洲| 激情五月播播久久久精品| 国产欧美日韩在线| 久久久久久久久久久电影| 日韩免费看的电影| 精品久久久久久综合日本欧美| 欧美一区二区性放荡片| 欧美日韩中文字幕精品| 欧美精品一级二级| 欧美白人最猛性xxxxx69交| 日韩精品资源二区在线| 国产午夜亚洲精品羞羞网站| 亚洲综合另类小说| 久久精品久久久精品美女| 久久精品噜噜噜成人av农村| 高清av一区二区| 欧美日韩一区二区三区视频| 日韩视频123| 亚洲色图一区二区三区| 偷偷要91色婷婷| 99久久免费国产| 欧美精品日韩一本| 国产精品色哟哟| 麻豆精品国产91久久久久久| 成年人国产精品| 日韩视频在线永久播放| 成人欧美一区二区三区在线播放| 七七婷婷婷婷精品国产| 精品一区二区综合| 久久亚洲一级片| 国产精品免费视频观看| 午夜精品一区二区三区电影天堂 | 欧美男同性恋视频网站| 青青草国产成人av片免费| 欧美肥胖老妇做爰| 亚洲国产va精品久久久不卡综合| 成人的网站免费观看| 一区二区中文字幕在线| 粗大黑人巨茎大战欧美成人| 亚洲国产成人午夜在线一区| 国产精品一区二区久激情瑜伽| 精品美女一区二区| 国内精品国产成人| 国产蜜臀av在线一区二区三区| 国产宾馆实践打屁股91| 精品在线你懂的| 日韩欧美一级特黄在线播放| 精品中文av资源站在线观看| 国产精品久久久久久福利一牛影视| 成人一区二区视频| 亚洲福利一区二区三区| 精品国产网站在线观看| 成人丝袜高跟foot| 亚洲成人一二三| 26uuu久久天堂性欧美| k8久久久一区二区三区| 亚洲高清免费观看| 久久久久久久综合色一本| 国产在线精品一区二区三区不卡 | 日本高清不卡视频| 在线免费不卡电影| 国产成人在线免费| 美女国产一区二区| 午夜欧美在线一二页| 久久―日本道色综合久久| 91.com在线观看| 一本色道久久综合亚洲91| 国产99久久久久| 国产精品中文字幕日韩精品 | 欧美久久免费观看| 亚洲成人免费视| 久久综合精品国产一区二区三区 | yourporn久久国产精品| 日韩不卡免费视频| 国产揄拍国内精品对白| 亚洲午夜一二三区视频| 三级亚洲高清视频| 国产精品综合一区二区三区| www..com久久爱| 在线视频中文字幕一区二区| 日本亚洲免费观看| 国产精品一区二区在线观看不卡| 久久久国产精品午夜一区ai换脸| 欧美亚洲动漫精品| 岛国精品在线观看| 青青青伊人色综合久久| 欧美经典一区二区| 91精品国产高清一区二区三区蜜臀 | 国产校园另类小说区| 国产精品自在欧美一区| 性欧美疯狂xxxxbbbb| 亚洲影院理伦片| 亚洲三级电影全部在线观看高清| 欧美精品一区二区三区一线天视频| 91国模大尺度私拍在线视频| 91亚洲精华国产精华精华液| 国产乱码精品一区二区三区五月婷| 亚洲在线成人精品| 亚洲午夜免费福利视频| 亚洲h在线观看| 夜色激情一区二区| 91蝌蚪porny成人天涯| 久久99国内精品| 欧美日韩亚洲综合在线| 日韩免费高清电影| 精品国产乱码久久久久久久| 日韩精品一区二区在线观看| 99久久伊人网影院| 久久91精品国产91久久小草| 亚洲一区自拍偷拍| 国产成人在线电影| 久久九九99视频| 91小视频在线免费看| 国产成人自拍在线| 色94色欧美sute亚洲线路一ni | 亚洲第一激情av| 黄色成人免费在线| 91浏览器打开| 精品国产成人系列| 亚洲日本丝袜连裤袜办公室| 蜜臀久久99精品久久久久宅男| 成人午夜av影视| 91精品国产乱| 亚洲激情中文1区| 国产一区二区不卡| 欧美亚洲禁片免费| 国产精品日韩成人| 青青草视频一区| 91精品办公室少妇高潮对白| 欧美精品一区二区不卡 | 亚洲国产岛国毛片在线| 日本午夜一区二区| 波多野结衣一区二区三区| 日韩精品中文字幕在线一区| 亚洲免费av高清| 国产成a人亚洲精品| 在线播放91灌醉迷j高跟美女| 中文字幕在线免费不卡| 久草精品在线观看| 欧美日韩激情一区| 国产精品久久久99| 狠狠狠色丁香婷婷综合激情| 欧美性一级生活| 国产精品国产三级国产普通话蜜臀 | 美脚の诱脚舐め脚责91 | 蜜桃av一区二区三区| 色94色欧美sute亚洲线路二| 国产精品丝袜91| 国产原创一区二区| 69p69国产精品| 一区二区成人在线观看| 丁香六月综合激情| 久久久精品国产免费观看同学| 日韩av在线发布| 欧美自拍丝袜亚洲| 樱桃视频在线观看一区| 国产精品1024| 精品捆绑美女sm三区| 日韩和欧美一区二区| 欧美三级电影在线看| 洋洋成人永久网站入口| 色婷婷av久久久久久久| 亚洲欧美日本在线| 91亚洲大成网污www| 日韩伦理免费电影| 99免费精品视频| 国产喂奶挤奶一区二区三区| 欧美一区二区视频在线观看2020| 99精品欧美一区二区三区小说| 亚洲免费视频成人| 丁香五精品蜜臀久久久久99网站| 国产亚洲欧美一级| 国产美女久久久久| 国产欧美精品区一区二区三区 | 亚洲国产精品一区二区久久恐怖片| 色噜噜狠狠色综合欧洲selulu| 亚洲欧洲精品一区二区三区 | 久久午夜免费电影| 国内成+人亚洲+欧美+综合在线| 精品成人佐山爱一区二区| 九色综合国产一区二区三区| 精品对白一区国产伦| 国产一区二区日韩精品| 国产欧美精品一区aⅴ影院| www.欧美日韩国产在线| 亚洲色图都市小说| 一本大道av一区二区在线播放| 亚洲主播在线播放| 欧美群妇大交群中文字幕| 轻轻草成人在线| 国产无一区二区| 91论坛在线播放| 日韩av网站在线观看| 久久嫩草精品久久久久| 成人99免费视频| 亚洲福中文字幕伊人影院| 欧美sm美女调教| 国产精品一区二区x88av| 国产精品私房写真福利视频| 91福利区一区二区三区|