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

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

?? key.c

?? DMDD的嵌入式系統(tǒng)構件源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                    Embedded Systems Building Blocks
*                                 Complete and Ready-to-Use Modules in C
*
*                                         Matrix Keyboard Driver
*
*                            (c) Copyright 1999, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* Filename   : KEY.C
* Programmer : Jean J. Labrosse
*********************************************************************************************************
*                                             DESCRIPTION
*
*    The keyboard is assumed to be a matrix having 4 rows by 6 columns.  However, this code works for any
* matrix arrangements up to an 8 x 8 matrix.  By using from one to three of the column inputs, the driver
* can support "SHIFT" keys.  These keys are: SHIFT1, SHIFT2 and SHIFT3.
*
*    Your application software must declare (see KEY.H):
*
*    KEY_BUF_SIZE            Size of the KEYBOARD buffer
*
*    KEY_MAX_ROWS            The maximum number of rows    on the keyboard
*    KEY_MAX_COLS            The maximum number of columns on the keyboard
*
*    KEY_RPT_DLY             Number of scan times before auto repeat executes the function again
*    KEY_RPT_START_DLY       Number of scan times before auto repeat function engages
*
*    KEY_SCAN_TASK_DLY       The number of milliseconds between keyboard scans
*    KEY_SCAN_TASK_PRIO      Sets the priority of the keyboard scanning task
*    KEY_SCAN_TASK_STK_SIZE  The size of the keyboard scanning task stack
*
*    KEY_SHIFT1_MSK          The mask which determines which column input handles the SHIFT1 key
*                                (A 0x00 indicates that a SHIFT1 key is not present)
*    KEY_SHIFT1_OFFSET       The scan code offset to add when the SHIFT1 key is pressed
*
*    KEY_SHIFT2_MSK          The mask which determines which column input handles the SHIFT2 key
*                                (A 0x00 indicates that an SHIFT2 key is not present)
*    KEY_SHIFT2_OFFSET       The scan code offset to add when the SHIFT2 key is pressed
*
*    KEY_SHIFT3_MSK          The mask which determines which column input handles the SHIFT3 key
*                                (A 0x00 indicates that a SHIFT3 key is not present)
*    KEY_SHIFT3_OFFSET       The scan code offset to add when the SHIFT3 key is pressed
*
*
*    KEY_PORT_ROW            The port address of the keyboard matrix ROWs
*    KEY_PORT_COL            The port address of the keyboard matrix COLUMNs
*    KEY_PORT_CW             The port address of the keyboard I/O ports control word
*
*    KeyInitPort, KeySelRow() and KeyGetCol() are the only three hardware specific functions.  This has
*    been done to localize the interface to the hardware in only these two functions and thus make is
*    easier to adapt to your application.
*********************************************************************************************************
*/

/*$PAGE*/
/*
*********************************************************************************************************
*                                              INCLUDE FILES
*********************************************************************************************************
*/

#include "includes.h"

/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define KEY_STATE_UP                 1      /* Key scanning states used in KeyScan()                   */
#define KEY_STATE_DEBOUNCE           2
#define KEY_STATE_RPT_START_DLY      3
#define KEY_STATE_RPT_DLY            4

/*
*********************************************************************************************************
*                                            GLOBAL VARIABLES
*********************************************************************************************************
*/

static  INT8U     KeyBuf[KEY_BUF_SIZE];     /* Keyboard buffer                                         */
static  INT8U     KeyBufInIx;               /* Index into key buf where next scan code will be inserted*/
static  INT8U     KeyBufOutIx;              /* Index into key buf where next scan code will be removed */
static  INT16U    KeyDownTmr;               /* Counts how long key has been pressed                    */
static  INT8U     KeyNRead;                 /* Number of keys read from the keyboard                   */

static  INT8U     KeyRptStartDlyCtr;        /* Number of scan times before auto repeat is started      */
static  INT8U     KeyRptDlyCtr;             /* Number of scan times before auto repeat executes again  */

static  INT8U     KeyScanState;             /* Current state of key scanning function                  */

static  OS_STK    KeyScanTaskStk[KEY_SCAN_TASK_STK_SIZE];  /* Keyboard scanning task stack             */

static  OS_EVENT *KeySemPtr;                               /* Pointer to keyboard semaphore            */

/*
*********************************************************************************************************
*                                       LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static  void      KeyBufIn(INT8U code);     /* Insert scan code into keyboard buffer                   */
static  INT8U     KeyDecode(void);          /* Get scan code from current key pressed                  */
static  BOOLEAN   KeyIsKeyDown(void);       /* See if key has been pressed                             */
static  void      KeyScanTask(void *data);  /* Keyboard scanning task                                  */

/*$PAGE*/
/*
*********************************************************************************************************
*                                INSERT KEY CHARACTER INTO KEYBOARD BUFFER
*
* Description : This function inserts a key character into the keyboard buffer
* Arguments   : code    is the keyboard scan code to insert into the buffer
* Returns     : none
*********************************************************************************************************
*/

static  void  KeyBufIn (INT8U code)
{
    OS_ENTER_CRITICAL();                         /* Start of critical section of code, disable ints    */
    if (KeyNRead < KEY_BUF_SIZE) {               /* Make sure that we don't overflow the buffer        */
        KeyNRead++;                              /* Increment the number of keys read                  */
        KeyBuf[KeyBufInIx++] = code;             /* Store the scan code into the buffer                */
        if (KeyBufInIx >= KEY_BUF_SIZE) {        /* Adjust index to the next scan code to put in buffer*/
            KeyBufInIx = 0;
        }
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */
        OSSemPost(KeySemPtr);                    /* Signal sem if scan code inserted in the buffer     */
    } else {                                     /* Buffer is full, key scan code is lost              */
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           DECODE KEYBOARD
*
* Description : This function is called to determine the key scan code of the key pressed.
* Arguments   : none
* Returns     : the key scan code
*********************************************************************************************************
*/

static  INT8U  KeyDecode (void)
{
    INT8U   col;
    INT8U   row;
    INT8U   offset;
    BOOLEAN done;
    INT8U   col_id;
    INT8U   msk;


    done = FALSE;
    row  = 0;
    while (row < KEY_MAX_ROWS && !done) {             /* Find out in which row key was pressed         */
        KeySelRow(row);                               /* Select a row                                  */
        if (KeyIsKeyDown()) {                         /* See if key is pressed in this row             */
            done = TRUE;                              /* We are done finding the row                   */
        } else {
            row++;                                    /* Select next row                               */
        }
    }
    col    = KeyGetCol();                             /* Read columns                                  */
    offset = 0;                                       /* No SHIFT1, SHIFT2 or SHIFT3 key pressed       */
    if (col & KEY_SHIFT1_MSK) {                       /* See if SHIFT1 key was also pressed            */
        offset += KEY_SHIFT1_OFFSET;
    }
    if (col & KEY_SHIFT2_MSK) {                       /* See if SHIFT2 key was also pressed            */
        offset += KEY_SHIFT2_OFFSET;
    }
    if (col & KEY_SHIFT3_MSK) {                       /* See if SHIFT3 key was also pressed            */
        offset += KEY_SHIFT3_OFFSET;
    }
    msk    = 0x01;                                    /* Set bit mask to scan for the column           */
    col_id =    0;                                    /* Set column value (0..7)                       */
    done   = FALSE;
    while (col_id < KEY_MAX_COLS && !done) {          /* Go through all columns                        */
        if (col & msk) {                              /* See if key was pressed in this columns        */
            done  = TRUE;                             /* Done, i has column value of the key (0..7)    */
        } else {
            col_id++;
            msk <<= 1;
        }
    }
    return (row * KEY_MAX_COLS + offset + col_id);    /* Return scan code                              */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         FLUSH KEYBOARD BUFFER
*
* Description : This function clears the keyboard buffer
* Arguments   : none
* Returns     : none
*********************************************************************************************************
*/

void  KeyFlush (void)
{
    while (KeyHit()) {                           /* While there are keys in the buffer...              */
        KeyGetKey(0);                            /* ... extract the next key from the buffer           */
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                                 GET KEY
*
* Description : Get a keyboard scan code from the keyboard driver.
* Arguments   : 'to'     is the amount of time KeyGetKey() will wait (in number of ticks) for a key to be
*                        pressed.  A timeout of '0' means that the caller is willing to wait forever for
*                        a key to be pressed.
* Returns     : != 0xFF  is the key scan code of the key pressed
*               == 0xFF  indicates that there is no key in the buffer within the specified timeout
*********************************************************************************************************
*/

INT8U  KeyGetKey (INT16U to)
{
    INT8U code;
    INT8U err;


    OSSemPend(KeySemPtr, to, &err);              /* Wait for a key to be pressed                       */
    OS_ENTER_CRITICAL();                         /* Start of critical section of code, disable ints    */
    if (KeyNRead > 0) {                          /* See if we have keys in the buffer                  */
        KeyNRead--;                              /* Decrement the number of keys read                  */
        code = KeyBuf[KeyBufOutIx];              /* Get scan code from the buffer                      */
        KeyBufOutIx++;
        if (KeyBufOutIx >= KEY_BUF_SIZE) {       /* Adjust index into the keyboard buffer              */
            KeyBufOutIx = 0;
        }
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲影院理伦片| 欧美一区二区三区日韩视频| 精品视频在线视频| 国产风韵犹存在线视精品| 免费三级欧美电影| 日韩一区欧美二区| 日韩国产成人精品| 高清不卡一区二区| 粗大黑人巨茎大战欧美成人| 成人免费电影视频| 成人国产精品免费观看视频| 成人黄色小视频在线观看| 99久久国产综合色|国产精品| 99精品视频在线观看免费| 色综合天天性综合| 欧美日韩一区在线观看| 日韩丝袜美女视频| 国产亚洲欧美日韩在线一区| 国产精品美女久久久久久久久久久 | 93久久精品日日躁夜夜躁欧美| 成人性生交大片免费看中文网站| 成人激情综合网站| 97精品视频在线观看自产线路二| 成人av网址在线| 欧美手机在线视频| 精品捆绑美女sm三区| 国产精品视频免费看| 中文字幕在线一区免费| 亚洲图片欧美一区| 精品在线播放免费| 成人av网站在线观看| 在线中文字幕不卡| 2020日本不卡一区二区视频| 亚洲欧美乱综合| 美女一区二区在线观看| 国产成人免费高清| 欧美女孩性生活视频| 国产欧美日产一区| 亚洲va在线va天堂| 成人97人人超碰人人99| 欧美成人一区二区三区| 一区二区三区在线播放| 国产在线精品视频| 欧美日韩在线播| 国产精品三级av| 美女诱惑一区二区| 欧美日韩另类国产亚洲欧美一级| 亚洲gay无套男同| 成人性生交大片免费看中文网站| 欧美一级夜夜爽| 亚洲欧美一区二区久久| 久久精品国产99国产| 99视频精品免费视频| 欧美不卡在线视频| 五月天视频一区| 国产成人精品一区二区三区四区 | 欧美一区二区三区视频在线观看| 国产亚洲一区二区三区| 无码av免费一区二区三区试看| 成人免费精品视频| 精品剧情在线观看| 奇米色777欧美一区二区| 一本大道综合伊人精品热热| 亚洲国产成人私人影院tom| 久久av老司机精品网站导航| 91老师片黄在线观看| 国产欧美日韩在线看| 久久99精品久久久久久久久久久久 | 欧美日韩国产色站一区二区三区| 国产精品色眯眯| 国产成人综合自拍| 久久综合九色综合97婷婷| 日韩av电影一区| 5月丁香婷婷综合| 性做久久久久久| 欧美亚州韩日在线看免费版国语版| 国产精品久久久久久久午夜片 | 亚洲美女视频一区| 麻豆一区二区99久久久久| 欧美精品少妇一区二区三区| 玉足女爽爽91| 欧美性猛片aaaaaaa做受| 亚洲精品国产精华液| 色av成人天堂桃色av| 最新国产の精品合集bt伙计| 色综合久久久久综合99| 亚洲综合偷拍欧美一区色| 91国模大尺度私拍在线视频| 亚洲午夜电影在线| 3atv一区二区三区| 另类人妖一区二区av| 欧美岛国在线观看| 国产成人av电影在线观看| 中文字幕乱码久久午夜不卡| 暴力调教一区二区三区| 一区二区三区在线视频播放| 欧美日韩成人在线一区| 狠狠色丁香久久婷婷综合_中 | 欧美乱妇一区二区三区不卡视频| 亚洲精品视频在线观看免费| 欧美日韩国产在线观看| 麻豆高清免费国产一区| 欧美国产精品专区| 在线日韩一区二区| 免费av成人在线| 中文一区在线播放| 精品视频全国免费看| 午夜欧美视频在线观看| 久久九九全国免费| 91蜜桃视频在线| 美腿丝袜在线亚洲一区| 国产日韩成人精品| 欧美日韩国产精品成人| 狠狠色狠狠色综合日日91app| 国产精品成人在线观看| 欧美日韩成人综合在线一区二区| 国产麻豆成人传媒免费观看| 亚洲精品伦理在线| 日韩免费高清电影| 在线亚洲欧美专区二区| 国产综合久久久久久鬼色| 一区二区欧美视频| 久久亚洲免费视频| 欧美日韩黄色一区二区| 成人av资源在线| 九九精品一区二区| 亚洲区小说区图片区qvod| 精品日韩在线一区| 欧美少妇xxx| 99精品久久久久久| 精品中文字幕一区二区| 一二三四社区欧美黄| 久久久一区二区三区| 欧美日韩另类一区| 91视频.com| 丰满白嫩尤物一区二区| 日本欧美加勒比视频| 中文字幕亚洲区| 欧美精品一区二区三区一线天视频| 在线观看www91| 99re这里都是精品| 国产精品一级在线| 亚洲一区二区三区免费视频| 国产精品乱人伦| 久久精品视频一区二区| 欧美成人综合网站| 91精品国产91久久久久久一区二区| 成人av第一页| 国产91高潮流白浆在线麻豆| 精品一区二区三区在线观看 | 亚洲成人av电影在线| 日韩码欧中文字| 国产欧美精品国产国产专区| 欧美成人女星排名| 在线成人av网站| 欧美日韩精品系列| 欧美精选一区二区| 欧美日韩国产综合视频在线观看| 欧美在线影院一区二区| 91国产福利在线| 欧美日韩一区二区在线观看| 色系网站成人免费| 91国产福利在线| 欧美色综合天天久久综合精品| 久久精品日产第一区二区三区高清版| 欧美日韩日日摸| 日韩天堂在线观看| 精品国免费一区二区三区| 精品乱人伦一区二区三区| 久久久不卡网国产精品二区| 久久一二三国产| 国产精品视频一二三区| 国产精品久久久久影院亚瑟 | hitomi一区二区三区精品| 国产盗摄一区二区| www.欧美.com| 色哟哟国产精品| 欧美精三区欧美精三区| 精品国产髙清在线看国产毛片| 欧美大片一区二区| 国产色产综合产在线视频| 国产精品不卡一区| 亚洲国产视频在线| 蜜臀精品一区二区三区在线观看 | 欧美三级电影一区| 91精品国产综合久久精品| 欧美一级在线视频| 中文字幕乱码亚洲精品一区| 一区二区三区在线视频免费| 日本一区中文字幕| 豆国产96在线|亚洲| 色噜噜夜夜夜综合网| 91精品视频网| 久久久九九九九| 亚洲免费在线播放| 午夜精品久久久久久久久久| 久久91精品久久久久久秒播| 成人激情图片网| 欧美日韩中文字幕精品| 欧美成人一级视频|