📄 epp.c
字号:
/*
** FILE
** epp.c
**
** DESCRIPTION
** Support EPP (ok, this is only a standard bi-directional
** parallel port interface, but who cares?) send/receive
** functions.
*/
#include "config.h"
#include "regmap.h"
#include "global.h"
#include "dma.h"
#include "uart.h"
#include "stdlib.h"
#ifdef SUPPORT_EPP_DBG
#if UART_DEBUG
#define EPP_GETC() (regs0->uart0_data)
#define EPP_PUTC(c) (write_uart0(c))
#define IsEPPRxEmpty() (!UART0_rx_rdy())
#define IsEPPTxFull() (is_uart0_fifo_full())
#define IsEPPTxEmpty() (is_uart0_fifo_empty())
#else
#define EPP_STATUS (regs0->epp_status)
#define EPP_GETC() (regs0->epp_data)
#define EPP_PUTC(c) (regs0->epp_data = c)
#define IsEPPRxFull() (EPP_STATUS & RF_EPP_IN_FULL)
#define IsEPPRxEmpty() (EPP_STATUS & RF_EPP_IN_EMPTY)
#define IsEPPTxFull() (EPP_STATUS & RF_EPP_OUT_FULL)
#define IsEPPTxEmpty() (EPP_STATUS & RF_EPP_OUT_EMPTY)
#endif
#endif
#if (SUPPORT_EPP==0)
#undef IsEPPRxEmpty()
#undef EPP_GETC()
#undef IsEPPTxFull()
#undef IsEPPTxEmpty()
#undef EPP_PUTC()
#define IsEPPRxEmpty() (1)
#define EPP_GETC() (0)
#define IsEPPTxFull() (0)
#define IsEPPTxEmpty() (1)
#define EPP_PUTC(c) ((void)(c))
#endif
//JJDing 2002/08/28
#if CONFIG==CONFIG_COMBO_SVCD
#define UART_BUF_START 0x88000000+1024*2036+512
#else
#define UART_BUF_START 0x88000000+1024*7+512
#endif
BYTE *uart_buf = (BYTE *) (UART_BUF_START);
#ifdef SUPPORT_EPP_DBG
#define CMD_LENGTH 16
char cmdbuf[CMD_LENGTH];
static int mon_in();
void UART_Response();
int polling_epp(void)
{
if(uart_rp != uart_wp)
{
if(!IsUARTCmdTxFull())
{
regs0->uart0_data = uart_buf[uart_rp];
uart_rp++;
uart_rp &= FIFOS;
}
}
#ifdef SUPPORT_DOUBLEWAY_DBG
mon_in();
#endif
return 0;
}
void epp_write_wait(const char *s)
{
int c;
while(1)
{
c = *s++;
if(c == 0)
break;
if(c == '\n')
{
uart_buf[uart_wp] = '\r';
uart_wp++;
uart_wp &= FIFOS;
}
uart_buf[uart_wp] = c;
uart_wp++;
uart_wp &= FIFOS;
}
}
void reset_epp(void)
{
}
void epp_flush(void)
{
}
void epp_write(const char *s)
{
epp_write_wait(s);
}
void epp_write_slow(const char *s)
{
epp_write_wait(s);
}
#define MON_OUT(c) (regs0->epp_data=(c))
#define MON_IN() (regs0->epp_data)
#define MON_EMPTY() (regs0->epp_status & RF_EPP_IN_EMPTY)
#define MON_OUT_FULL() (regs0->epp_status & RF_EPP_OUT_FULL)
#ifndef NULL
#define NULL ((void *)0)
#endif
#ifdef SUPPORT_DOUBLEWAY_DBG
static int mon_in()
{
static int i=0;
while (1)
{
BYTE c,d;
if (IsUARTCmdRxEmpty())
return;
c = UART_DATA;
d = regs0->epp_status;
if (c==27)
return -1;
if (c=='\r' || c=='\n')
{
cmdbuf[i] = '\0';
UART_Response();
i=0;
break;
}
else
{
cmdbuf[i++] = c;
if(i==CMD_LENGTH)
i=0;
}
}
return 0;
}
void UART_Response()
{
epp_write_wait("Cmd: ");
epp_write_wait(cmdbuf);
epp_write_wait("\n");
/*switch(cmdbuf[0])
{
case 'R':
{
UINT32 REG;
asm volatile ("mfc0 $16, $13; nop; move %0, $16":"=r" (REG)::"$16");
psprintf(linebuf, "CAUSE %08x\n", REG);
epp_write_wait(linebuf);
}
break;
}*/
if(strcmp(cmdbuf,"cause")==0)
{
UINT32 REG;
asm volatile ("mfc0 $16, $13; nop; move %0, $16":"=r" (REG)::"$16");
psprintf(linebuf, "CAUSE %08x\n", REG);
epp_write_wait(linebuf);
}
return;
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -