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

📄 drvsio.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
字号:
#include <stdarg.h>
#include "winav.h"
#include "comdef.h"
#include "sysdebug.h"

void DRVSIO_SerialPortISR(void);
void _printf(char *fmt, ...);

extern BYTE _bBinMode;
/****************************************************************************
 ** Function:           DRVSIO_SerialPortISR
 ** Description:        ISR for serial port of 8051.
 ** Parameters:         none.
 ** Return:             none.
 ***************************************************************************/
#ifdef SYSTEM_8051
void DRVSIO_SerialPortISR(void) interrupt 4 using 2
{
#ifdef SERIAL_DEBUG
    if (RI == 1)
    {
        RI = 0;
        SYSDEBUG_SerialIntHandler();            
    }
#endif    
}
#endif //SYSTEM_8051

/****************************************************************************
 ** Function:           _printf
 ** Description:        mini printf versionm
 ** Parameters:         the same as printf
 ** Return:             none.
 ** Note:               Only support the following type:
 **                       WORD: d, i, o, u, x, X ==> all are output in Hex
 **                       DWORD: ld, li, lo, lu, lx, lX ==> all are output in Hex
 **                       BYTE: hd, hi, ho, hu, hx, hX ==> all are output in Hex
 **                       char: c
 **                       string: s
 **                     flag, width, precision will be ignored
 ***************************************************************************/
#if defined (SERIAL_DEBUG) || defined(SUPPORT_PRINTF)
void _printf(char *fmt, ...)
{
    va_list ap;
    // Micky0.95, remove the "data" usage, as stack size is not enough.
    // JVC-> select 2(Still picture)-> select 1, system will hang
    char *sval;
    long ival;
    char cval;
    unsigned char index; // format string max is 255
/*
    data char *sval;
    data long ival;
    data char cval;
    data unsigned char index; // format string max is 255
*/
    bit bPercent, bLong, bByte;

    if (!_bBinMode)
    {        
        va_start(ap, fmt);
        
        bPercent = 0;
        bLong = 0;
        bByte = 0;
        index = 0;
        while(cval = fmt[index++])
        {
            if (cval != '%' && !bPercent)
            {
                putchar_SBUF(cval);
                if (cval == 0x0a) // new line
                    putchar_SBUF(0x0d); // send an extra CR
                continue;
            }else if (bPercent)
                index--;
            
            bPercent = 1;
            
            switch(fmt[index++])
            {
            case 'd':
            case 'i':
            case 'o':
            case 'u':
            case 'x':
            case 'X':
                if (bLong)
                {
                    ival = va_arg( ap, long );
                    put_DWORD(ival);
                }
                else if (bByte)
                {
                    ival = va_arg( ap, unsigned char );
                    putHEX(ival);
                }
                else // WORD
                {
                    ival = va_arg( ap, int );
                    put_WORD(ival);
                }
                break;
            case 'c':
                //cval = va_arg( ap, int ); // in vc6.0, char is int 
                cval = va_arg( ap, char );
                putchar_SBUF(cval);
                break;
            case 's':
                for (sval=va_arg(ap, char *); *sval; sval++)
                    putchar_SBUF(*sval);
                break;
            case 'l':
                bLong = 1;
                continue;
            case 'h':
                bByte = 1;
                continue;
            case '%':
                putchar_SBUF('%');
                break;
            default:
                continue;
            }
            bLong = 0;
            bByte = 0;
            bPercent = 0;
            
        }
        va_end(ap);
    }
}

#endif //#if defined (SERIAL_DEBUG) || defined(SUPPORT_PRINTF)

⌨️ 快捷键说明

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