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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? key.c

?? 一些ucos的外圍接口原代碼,如鍵盤LCDLED
?? 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                    */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
综合在线观看色| 精品三级在线看| 国产很黄免费观看久久| 免费成人av在线| 九一九一国产精品| 韩国三级中文字幕hd久久精品| 婷婷成人激情在线网| 日韩国产欧美一区二区三区| 天堂一区二区在线| 麻豆精品一二三| 国产乱码字幕精品高清av| 丰满少妇久久久久久久| 成人aa视频在线观看| 97久久久精品综合88久久| 在线看国产日韩| 欧美精品1区2区| 精品人在线二区三区| 国产婷婷一区二区| 亚洲视频在线观看一区| 亚洲曰韩产成在线| 老司机精品视频线观看86| 精品无码三级在线观看视频| 成人av一区二区三区| 91精品91久久久中77777| 欧美日韩aaa| 26uuu久久综合| 国产精品理论片在线观看| 一区二区三区精品视频| 久久国内精品视频| av中文字幕亚洲| 91.成人天堂一区| 国产调教视频一区| 亚洲成人av电影在线| 极品少妇xxxx精品少妇偷拍| 成人激情动漫在线观看| 欧美三级电影网| 久久亚区不卡日本| 亚洲午夜免费视频| 丁香婷婷综合五月| 91精品蜜臀在线一区尤物| 国产精品网站在线播放| 午夜国产不卡在线观看视频| 国产91丝袜在线播放| 欧美日韩一区二区在线观看 | 国内外精品视频| 色婷婷综合久久久久中文 | 久久精品免费看| 成人黄色电影在线| 欧美本精品男人aⅴ天堂| 亚洲九九爱视频| 国产在线不卡一卡二卡三卡四卡| 在线精品视频一区二区三四| 久久久久久综合| 日本欧美一区二区| 色天天综合色天天久久| 中文字幕欧美日韩一区| 久久99精品国产麻豆不卡| 欧美中文字幕不卡| 国产精品传媒视频| 国产成人av电影在线观看| 日韩精品中文字幕在线一区| 亚洲电影你懂得| 在线视频观看一区| 亚洲欧洲日韩综合一区二区| 精品一区二区免费看| 欧美日韩成人综合在线一区二区| 亚洲人成电影网站色mp4| 成熟亚洲日本毛茸茸凸凹| 久久亚洲综合av| 国产精品69久久久久水密桃| 久久久久国产精品厨房| 精品一区二区免费视频| 欧美xxxxx牲另类人与| 日本系列欧美系列| 777欧美精品| 日本伊人色综合网| 欧美一区二区高清| 另类欧美日韩国产在线| 欧美一级二级在线观看| 裸体在线国模精品偷拍| 欧美成人a∨高清免费观看| 久久精品国产在热久久| 精品国产免费一区二区三区香蕉 | 日韩免费视频一区二区| 捆绑紧缚一区二区三区视频| 91精品综合久久久久久| 日精品一区二区三区| 欧美日韩国产小视频在线观看| 亚洲妇女屁股眼交7| 欧美日韩精品欧美日韩精品一综合 | 91一区二区三区在线观看| 国产精品久久久久aaaa樱花 | 日韩电影在线观看一区| 56国语精品自产拍在线观看| 免费一级片91| 午夜精品福利一区二区蜜股av| 91精品视频网| 高清不卡在线观看av| 亚洲欧美另类综合偷拍| 欧美色男人天堂| 国内精品国产成人| 日韩毛片精品高清免费| 欧美理论在线播放| 国内成人免费视频| 亚洲精品乱码久久久久久日本蜜臀| 欧洲亚洲国产日韩| 久久国产欧美日韩精品| 欧美高清在线视频| 欧美日韩国产小视频在线观看| 黄色日韩网站视频| 亚洲精品乱码久久久久久| 91精品国产全国免费观看| 国产成人8x视频一区二区 | 欧美日韩午夜在线视频| 国产在线观看一区二区| 亚洲精品一二三区| 久久久美女毛片| 欧美色视频在线观看| 国产成人亚洲综合a∨婷婷| 亚洲午夜电影在线| 国产精品少妇自拍| 欧美一区二区三区播放老司机| 成人av电影在线网| 美女视频黄a大片欧美| 亚洲另类中文字| 久久久美女毛片| 欧美一区二区三区在线看| 92精品国产成人观看免费| 精品一区二区在线观看| 亚洲成人综合网站| 久久成人久久鬼色| 亚洲自拍偷拍图区| ...av二区三区久久精品| 精品久久99ma| 91.麻豆视频| 在线亚洲欧美专区二区| caoporen国产精品视频| 国产在线一区二区| 美女在线视频一区| 午夜亚洲国产au精品一区二区| 亚洲欧美一区二区三区国产精品| 久久免费视频色| 欧美精品一区二区三| 日韩欧美专区在线| 欧美一卡二卡在线| 欧美日韩国产小视频| 欧美日韩1234| 欧美日韩久久一区二区| 欧美写真视频网站| 色婷婷久久久久swag精品| av高清久久久| aaa国产一区| 99久久99久久综合| 99re热这里只有精品视频| 不卡在线观看av| 成人成人成人在线视频| 99re热视频这里只精品| 色综合天天综合网国产成人综合天| 成人高清视频在线| 91视视频在线观看入口直接观看www| 99国产精品久久久久久久久久久| 本田岬高潮一区二区三区| 99国产精品久久久久久久久久| 国产成人av资源| 99国产一区二区三精品乱码| 91玉足脚交白嫩脚丫在线播放| 色婷婷国产精品| 777午夜精品视频在线播放| 日韩女优制服丝袜电影| 国产日韩欧美亚洲| 亚洲视频每日更新| 亚洲国产成人tv| 韩国理伦片一区二区三区在线播放 | 国产精品美女久久久久久久| 国产精品久久久久久久久久免费看 | 亚洲不卡一区二区三区| 五月天婷婷综合| 久久国产乱子精品免费女| 国产精品18久久久| 99精品视频在线观看免费| 欧美色电影在线| 欧美精品一区二| 亚洲精品久久7777| 日韩激情一区二区| 国产精品99久久久久久似苏梦涵 | 国产自产高清不卡| 成人av免费在线播放| 欧美吞精做爰啪啪高潮| 日韩欧美国产1| 亚洲精品乱码久久久久久| 青青草成人在线观看| 处破女av一区二区| 欧美久久免费观看| 亚洲国产精品99久久久久久久久 | 久久精品国产99国产精品| jvid福利写真一区二区三区| 欧美顶级少妇做爰| 国产欧美精品一区aⅴ影院| 婷婷综合久久一区二区三区| 国产suv精品一区二区883|