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

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

?? key.c

?? uCOS-II作者Jean J.Labrosse所著圖書 《嵌入式系統構件》書后光盤中的源代碼。基本設計了常用嵌入式系統的外圍硬件接口程序
?? 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一区二区三区免费野_久草精品视频
久久久精品免费观看| 欧美日韩极品在线观看一区| 日本精品裸体写真集在线观看| 日本乱码高清不卡字幕| 欧美精品粉嫩高潮一区二区| 精品国产一区二区精华| 成人免费在线视频观看| 日韩av在线播放中文字幕| 国产精品系列在线观看| 91高清视频在线| 精品三级在线看| 国产精品不卡在线| 日本va欧美va精品| 成人免费电影视频| 欧美一区二区三区在线观看 | 视频一区二区中文字幕| 国产一区在线观看麻豆| 在线看国产日韩| 久久众筹精品私拍模特| 亚洲一区在线观看免费 | 精品第一国产综合精品aⅴ| 国产精品乱码久久久久久| 三级成人在线视频| 99在线视频精品| 日韩三级视频中文字幕| 亚洲色图制服丝袜| 另类小说综合欧美亚洲| 色综合色综合色综合| 久久先锋资源网| 亚洲 欧美综合在线网络| 高潮精品一区videoshd| 自拍偷拍欧美激情| 韩国三级电影一区二区| 欧美日韩亚洲国产综合| 国产精品天天摸av网| 久久成人精品无人区| 色偷偷一区二区三区| 日本一区二区三区在线不卡| 日韩不卡一区二区三区| 欧美性做爰猛烈叫床潮| 欧美国产欧美综合| 麻豆精品新av中文字幕| 欧美性大战久久| 亚洲三级免费观看| 高清在线观看日韩| 2021久久国产精品不只是精品| 视频在线观看国产精品| 在线观看国产91| 1区2区3区国产精品| 国产乱国产乱300精品| 日韩欧美亚洲国产另类| 日韩精品电影一区亚洲| 欧美午夜精品久久久久久孕妇| 国产精品免费视频一区| 国产麻豆欧美日韩一区| 日韩视频123| 奇米精品一区二区三区在线观看一| 欧美色男人天堂| 亚洲理论在线观看| 成人中文字幕合集| 国产日韩av一区二区| 国产一区在线视频| 久久网站热最新地址| 九九精品视频在线看| 日韩精品专区在线| 美国精品在线观看| 日韩欧美久久久| 日本午夜精品一区二区三区电影 | 免费视频一区二区| 欧美精品1区2区3区| 性欧美大战久久久久久久久| 欧美亚洲日本一区| 亚洲成人在线免费| 欧美日韩dvd在线观看| 亚洲国产一区二区三区| 91久久国产最好的精华液| 亚洲欧美另类小说| 欧洲精品中文字幕| 一区二区三区免费| 精品剧情v国产在线观看在线| 9人人澡人人爽人人精品| 豆国产96在线|亚洲| 国产精品网站导航| 99久久99久久精品免费看蜜桃| 中文字幕亚洲在| 色综合久久久久综合体| 亚洲第一在线综合网站| 欧美一区日韩一区| 韩国成人福利片在线播放| 欧美经典三级视频一区二区三区| 成人精品在线视频观看| 亚洲卡通欧美制服中文| 欧美日韩亚洲另类| 奇米四色…亚洲| 国产三级三级三级精品8ⅰ区| 东方aⅴ免费观看久久av| 1024国产精品| 欧美亚一区二区| 麻豆精品一区二区三区| 国产欧美日韩亚州综合| 91理论电影在线观看| www.亚洲人| 亚洲国产成人av| 欧美精品一区二区三区一线天视频 | 韩国三级中文字幕hd久久精品| 国产视频一区二区在线| 色婷婷久久综合| 免费观看成人av| 国产精品乱码一区二区三区软件 | 午夜精品久久久久久久久久久 | 激情六月婷婷久久| 国产精品乱子久久久久| 欧美日韩国产另类一区| 国产成人午夜片在线观看高清观看| 成人欧美一区二区三区| 宅男噜噜噜66一区二区66| 国产精品中文字幕一区二区三区| 亚洲视频免费在线观看| 日韩三级视频在线观看| av在线不卡网| 免费成人av在线播放| 国产精品久久看| 日韩一区二区在线免费观看| 成人毛片老司机大片| 日韩精品成人一区二区在线| 国产精品免费看片| 欧美一区在线视频| 99久久99久久精品免费观看| 久久精品国产亚洲aⅴ| 亚洲色图20p| 久久久美女艺术照精彩视频福利播放| 91国产免费看| 成人性视频免费网站| 日韩黄色免费网站| 日韩一区在线看| 精品福利一二区| 欧美三级乱人伦电影| 波多野结衣亚洲| 久久99精品久久久久久国产越南| 一区二区视频在线看| 国产日韩欧美制服另类| 在线不卡欧美精品一区二区三区| 成人av网在线| 国产高清视频一区| 日韩高清一区在线| 亚洲激情图片一区| 欧美国产禁国产网站cc| 精品少妇一区二区| 欧美乱熟臀69xxxxxx| 色综合久久久久久久久| 国产suv精品一区二区三区| 美女精品一区二区| 亚洲高清不卡在线| 亚洲视频在线观看三级| 欧美国产日韩a欧美在线观看| 欧美mv和日韩mv国产网站| 欧美日本一区二区三区| 色综合色狠狠天天综合色| 成人免费黄色在线| 国产91在线观看| 激情综合网最新| 麻豆高清免费国产一区| 日韩不卡手机在线v区| 午夜精品久久久久| 亚洲一线二线三线久久久| 亚洲色图一区二区| 椎名由奈av一区二区三区| 国产精品欧美经典| 久久精品视频一区二区| 久久综合国产精品| 亚洲精品一区二区三区香蕉| 精品国产凹凸成av人网站| 日韩三级av在线播放| 日韩一区二区免费电影| 欧美精品日韩精品| 欧美三区免费完整视频在线观看| 色婷婷综合激情| 欧美性猛交xxxx乱大交退制版| 色婷婷综合五月| 欧美亚洲尤物久久| 91福利精品视频| 欧美日韩激情一区二区三区| 欧美日韩国产免费一区二区 | 在线这里只有精品| 日本黄色一区二区| 在线观看亚洲a| 欧美色欧美亚洲另类二区| 欧美日韩国产区一| 91精品国产综合久久精品| 91精品国产综合久久久久久久久久| 欧美精品三级日韩久久| 欧美一级免费大片| 日韩精品资源二区在线| 久久久久久久久久电影| 国产精品你懂的在线欣赏| 亚洲视频一区二区在线观看| 亚洲最大成人综合| 视频一区二区三区中文字幕| 精品一二三四区| 成人av午夜影院|