⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbd_support.c

📁 Intel XScale PXA255 引导Linux的Redboot 版bootloader源代码!
💻 C
📖 第 1 页 / 共 2 页
字号:
//==========================================================================////        kbd_support.c////        Cirrus Logic EDB7xxx eval board ASCII keyboard support functions////==========================================================================//####COPYRIGHTBEGIN####//                                                                          // -------------------------------------------                              // The contents of this file are subject to the Red Hat eCos Public License // Version 1.1 (the "License"); you may not use this file except in         // compliance with the License.  You may obtain a copy of the License at    // http://www.redhat.com/                                                   //                                                                          // Software distributed under the License is distributed on an "AS IS"      // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the // License for the specific language governing rights and limitations under // the License.                                                             //                                                                          // The Original Code is eCos - Embedded Configurable Operating System,      // released September 30, 1998.                                             //                                                                          // The Initial Developer of the Original Code is Red Hat.                   // Portions created by Red Hat are                                          // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.                             // All Rights Reserved.                                                     // -------------------------------------------                              //                                                                          //####COPYRIGHTEND####//==========================================================================//#####DESCRIPTIONBEGIN####//// Author(s):     gthomas// Contributors:  gthomas// Date:          1999-05-15// Description:   Functions used to support ASCII keyboard//####DESCRIPTIONEND####static char kbd_server_stack[STACK_SIZE];static cyg_thread kbd_server_thread_data;static cyg_handle_t kbd_server_thread_handle;static cyg_interrupt kbd_interrupt;static cyg_handle_t  kbd_interrupt_handle;static cyg_mbox      kbd_events_mbox;static cyg_handle_t  kbd_events_mbox_handle;static cyg_sem_t     kbd_sem;static cyg_uint8 col_state[8];static cyg_uint8 ext_state[8];static voidkbd_delay(void){    volatile int i;    for (i = 0;  i < 250;  i++) ;}static voidkbd_scan(void){    int i;    cyg_uint8 port_data, ext_data;    // Turn off drive (de-select) all columns    *(volatile cyg_uint32 *)SYSCON1 = (*(volatile cyg_uint32 *)SYSCON1 & ~SYSCON1_KBD_CTL) |        SYSCON1_KBD_LOW;    for (i = 0;  i < 8;  i++) {        // Select column 'i'        *(volatile cyg_uint32 *)SYSCON1 = (*(volatile cyg_uint32 *)SYSCON1 & ~SYSCON1_KBD_CTL) |            SYSCON1_KBD_COL(i);        // Small pause to let the wires charge up :-)        kbd_delay();        // Grab the data        col_state[i] = port_data = *(volatile cyg_uint8 *)PADR;        ext_state[i] = ext_data = *(volatile cyg_uint8 *)KBD_PORT;        // De-Select column 'i'        *(volatile cyg_uint32 *)SYSCON1 = (*(volatile cyg_uint32 *)SYSCON1 & ~SYSCON1_KBD_CTL) |            SYSCON1_KBD_TRISTATE;        // Allow line to go slack        kbd_delay();    }    // Turn on drive (select) all columns - necessary to see interrupts    *(volatile cyg_uint32 *)SYSCON1 = (*(volatile cyg_uint32 *)SYSCON1 & ~SYSCON1_KBD_CTL) |        SYSCON1_KBD_HIGH;}static cyg_uint8     kbd_state[128];      // Known state of each keystatic cyg_uint8     kbd_new_state[128];  // Current state of each key// Row #1#define KBD_Escape     0x00#define KBD_F1         0x01#define KBD_F2         0x02#define KBD_F3         0x03#define KBD_F4         0x04#define KBD_F5         0x05#define KBD_F6         0x06#define KBD_F7         0x07#define KBD_F8         0x08#define KBD_F9         0x09#define KBD_F10        0x0A#define KBD_NumLock    0x0B#define KBD_SysReq     0x0C#define KBD_ScrlLock   0x0D#define KBD_Break      0x0E// Row #2#define KBD_1          0x10#define KBD_2          0x11#define KBD_3          0x12#define KBD_4          0x13#define KBD_5          0x14#define KBD_6          0x15#define KBD_7          0x16#define KBD_8          0x17#define KBD_9          0x18#define KBD_0          0x19#define KBD_Hyphen     0x1A#define KBD_Equals     0x1B#define KBD_BackSpace  0x1C#define KBD_Home       0x1D// Row #3#define KBD_Tab        0x20#define KBD_Q          0x21#define KBD_W          0x22#define KBD_E          0x23#define KBD_R          0x24#define KBD_T          0x25#define KBD_Y          0x26#define KBD_U          0x27#define KBD_I          0x28#define KBD_O          0x29#define KBD_P          0x2A#define KBD_LeftBrkt   0x2B#define KBD_RightBrkt  0x2C#define KBD_BackSlash  0x2D#define KBD_PageUp     0x2E// Row #4#define KBD_CapsLock   0x30#define KBD_A          0x31#define KBD_S          0x32#define KBD_D          0x33#define KBD_F          0x34#define KBD_G          0x35#define KBD_H          0x36#define KBD_J          0x37#define KBD_K          0x38#define KBD_L          0x39#define KBD_SemiColon  0x3A#define KBD_Quote      0x3B#define KBD_Enter      0x3C#define KBD_PageDown   0x3D// Row #5#define KBD_LeftShift  0x40#define KBD_Z          0x41#define KBD_X          0x42#define KBD_C          0x43#define KBD_V          0x44#define KBD_B          0x45#define KBD_N          0x46#define KBD_M          0x47#define KBD_Comma      0x48#define KBD_Period     0x49#define KBD_Slash      0x4A#define KBD_RightShift 0x4B#define KBD_UpArrow    0x4C#define KBD_End        0x4D// Row #6#define KBD_Ctrl       0x50#define KBD_Function   0x51#define KBD_LeftAlt    0x52#define KBD_Accent     0x53#define KBD_Space      0x54#define KBD_RightAlt   0x55#define KBD_Ins        0x56#define KBD_Del        0x57#define KBD_LeftArrow  0x58#define KBD_DownArrow  0x59#define KBD_RightArrow 0x5A#define KBD_Press      0x80  // Event has this bit when the key is pressed#define KBD_Empty      0xFF// Map column, bit -> keycodestatic cyg_uint32    kbd_map[8][16] = {    // Column #0    {KBD_Escape,    KBD_1,          KBD_Tab,        KBD_CapsLock,     KBD_BackSlash, KBD_Space,      KBD_LeftArrow,  KBD_UpArrow,     KBD_DownArrow, KBD_RightArrow, KBD_LeftShift,  KBD_Ctrl,      KBD_Function,  KBD_LeftAlt,    KBD_RightAlt,   KBD_RightShift },    // Column #1    {KBD_F5,        KBD_6,          KBD_T,          KBD_G,       KBD_B,         KBD_Slash,      KBD_SemiColon,  KBD_P,       KBD_Hyphen,    KBD_F10,        KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty     },    // Column #2    {KBD_F4,        KBD_5,          KBD_R,          KBD_F,       KBD_V,         KBD_Del,        KBD_Quote,      KBD_LeftBrkt,       KBD_Equals,    KBD_NumLock,    KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },    // Column #3    {KBD_F3,        KBD_4,          KBD_E,          KBD_D,       KBD_C,         KBD_Ins,        KBD_Empty,      KBD_RightBrkt,       KBD_BackSpace, KBD_SysReq,     KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },    // Column #4    {KBD_F2,        KBD_3,          KBD_W,          KBD_S,       KBD_X,         KBD_Empty,      KBD_Enter,      KBD_Empty,     KBD_Empty,     KBD_ScrlLock,   KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },    // Column #5    {KBD_F1,        KBD_2,          KBD_Q,          KBD_A,       KBD_Z,         KBD_End,        KBD_PageDown,   KBD_PageUp,     KBD_Home,      KBD_Break,      KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },    // Column #6    {KBD_F6,        KBD_7,          KBD_Y,          KBD_H,       KBD_N,         KBD_Period,     KBD_L,          KBD_O,       KBD_0,         KBD_F9,         KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },    // Column #7    {KBD_F7,        KBD_8,          KBD_U,          KBD_J,       KBD_M,         KBD_Comma,      KBD_K,          KBD_I,       KBD_9,         KBD_F8,         KBD_Empty,      KBD_Empty,     KBD_Empty,     KBD_Empty,      KBD_Empty,      KBD_Empty },};static cyg_uint8 kbd_chars[96] = {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -