smc_kbd.h

来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C头文件 代码 · 共 195 行

H
195
字号
/*
 * Copyright 1997, 1998, 1999 Motorola.  All Rights Reserved.
 */

/*************************************************************************
 *
 * File:  smc_kbd.h
 *
 * Description:
 *    Prototypes and defines for SMC Keyboard driver.
 *
 *************************************************************************/


#undef SMC_KBD_DEBUG    /* Debug mode for SMC driver */


typedef unsigned char BOOLEAN;


/**********************************************************************
 * Buffers for Tx and Rx - SHOULD BE IN CACHE_INHIBITED SPACE !!!!!
 *
 *    - Keyboard receiver sends 4 byte packets per character/event
 *
 *    - IR Receiver has LEDS (CAPS_LOCK, SCROLL_LOCK, NUM_LOCK) which
 *       require transmitter to send data -
 *
 * NOTE:
 *    - NUMBER of buffer should be less than the MAX_xX_BDS (smc_kbd.h)
 *       Otherwise, DEBUG versions could corrupt memory.
 *
 ***********************************************************************
 * These buffers should be allocated dynamically for the WinCE driver.
 ***********************************************************************/

#define RX_BUFFER_SIZE     4
#define NUMBER_RX_BUFFERS  16

/* Tx buffer will only be ONE char - pad for isolation for debug */
#define TX_BUFFER_SIZE     4
#define NUMBER_TX_BUFFERS  1


/************************************************************************
 * SMC Rx and Tx buffer descriptors for Keyboard operation
 ************************************************************************/

// put data buffers in Dual Port RAM

// Use a single structure to reference DPRAM
//   using the Physical address of the IMMR
//   as the base for deriving BOTH the offset
//   to the BD RING in the PRAM
//     - AND  -
//   the FULL address of the data buffers
//   in the DPRAM.

typedef struct RxTxBufferDescriptors
{
    SMC_BD rxbd[NUMBER_RX_BUFFERS];    /* Rx BD ring */
    SMC_BD txbd[NUMBER_TX_BUFFERS];    /* Tx BD */
}
RTXBD;


/*
 * Define maximum number of BDs to be used by an SMC channel
 */

#define MAX_TX_BDS 1
#define MAX_RX_BDS 16

/*
 * Defines for SMC channel operation and debugging
 */

typedef struct smc_channel
{
    unsigned int SmcNum;
    unsigned int BRGCnum;

    unsigned short PortpinMask;
    unsigned short CpmChNum;

    unsigned int SiModeShift;
    unsigned int Rs232Enable;
    unsigned int SiModeBrgSelect;

    int PramOffset;
    int RegsOffset;

    struct smc_regs *RegsPtr;
    struct smc_uart_pram *PramPtr;

/* pointers to base Buffer Descriptors */
    SMC_BD *RxBDbase;
    SMC_BD *TxBDbase;

/* pointers to SMC PRAM "rbptr/tbptr" parameters       */
/* - these parameters are offsets into the dual port   */
/*   RAM to the current BDs for Rx/Tx -                */
    unsigned short *CurRxBDptr;
    unsigned short *CurTxBDptr;

/* BD awaiting process OR being processed by application */
    SMC_BD *ProcRxBD;
    SMC_BD *ProcTxBD;

/* pointers to LAST Buffer Descriptors in rings */
    SMC_BD *LastRxBD;
    SMC_BD *LastTxBD;

/* Tx event expected flag */
    BOOLEAN txEventExpected;

#ifdef SMC_KBD_DEBUG

/* last event register read value */
    unsigned char last_event;

/* Counters for events */
    int rx_event_count;
    int tx_event_count;

/* Counters for packets/characters, etc. */
    int tx_count;
    int rx_count;
    int pkt_count;
    int key_count;
    int mouse_count;
    int keycode_count;

/* Buffer descriptor structure pointers */
    unsigned char *v_rtxbd_ptr;
    unsigned char *p_rtxbd_ptr;

/* Data Buffer base addresses */
    unsigned char *tx_buf_base;
    unsigned char *rx_buf_base;

/* Buffer pointers */
    unsigned char *tx_buf_ptr[MAX_TX_BDS];
    unsigned char *rx_buf_ptr[MAX_RX_BDS];

    unsigned short rx_bd_status;
    PM_IR_RCVR_PKT *cur_rx_pkt;
#endif
}
SMC_CHANNEL;


/*
 * Driver internal prototypes
 */

UINT32
IrScanCodeToVKey(
    UINT8 ScanCode,
    UINT8 KeyStates
    );

BOOLEAN
SmcKbd_SmcInit(
    SMC_CHANNEL *smc
    );

BOOLEAN
SmcKbd_SmcIrKbdRcvrInit(
    SMC_CHANNEL *smc
    );

BOOLEAN
SmcKbd_InitializeAddresses(
    SMC_CHANNEL *smc
    );

BOOLEAN
SmcKbd_Poll(
    SMC_CHANNEL *smc,
    unsigned char *event
    );

BOOL
SmcKbd_PutChar(
    SMC_CHANNEL *smc,
    unsigned char ch
    );

void
SmcKbd_Debug(
    SMC_CHANNEL *smc,
    char *error_msg
    );

⌨️ 快捷键说明

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