getkey.c

来自「mstar 776 开发的车载dvd」· C语言 代码 · 共 59 行

C
59
字号
/***********************************************************************/
/*  This file is part of the C51 Compiler package                      */
/*  Copyright KEIL ELEKTRONIK GmbH 1993 - 2002                         */
/***********************************************************************/
/*                                                                     */
/*  GETKEY.C:  This routine is the general character input of C51.     */
/*  You may add this file to a uVision2 project.                       */
/*                                                                     */
/*  To translate this file use C51 with the following invocation:      */
/*     C51 GETKEY.C  <memory model>                                    */
/*                                                                     */
/*  To link the modified GETKEY.OBJ file to your application use the   */
/*  following Lx51 invocation:                                         */
/*     Lx51 <your object file list>, GETKEY.OBJ <controls>             */
/*                                                                     */
/***********************************************************************/

#include <mreg51.h>

#include "board.h"
#include "sysinfo.h"

char _getkey( void )
{
    char c;

    if ( ENABLE_UART0 && !ENABLE_UART0_INTERRUPT && STDIN_DEVICE == IO_DEV_UART0 )
    {
        while ( !RI0 ) ;

        c = S0BUF;
        RI0 = 0;
    }
    else if ( ENABLE_UART1 && !ENABLE_UART1_INTERRUPT && STDIN_DEVICE == IO_DEV_UART1 )
    {
        while ( !(S1CON & BIT0) ) ;

        c = S1BUF;
        S1CON &= ~BIT0;
    }
    else
    {
        c = 0;
    }
    return c;
}

char kbhit( void )
{
    if ( ENABLE_UART0 && !ENABLE_UART0_INTERRUPT && STDIN_DEVICE == IO_DEV_UART0 )
    {
        return RI0;
    }
    else if ( ENABLE_UART1 && !ENABLE_UART1_INTERRUPT && STDIN_DEVICE == IO_DEV_UART1 )
    {
        return (S1CON & BIT0);
    }
    return 0;
}

⌨️ 快捷键说明

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