- dbg_putchar() and dbg_getchar() don't call any common sub routines
git-svn-id: http://moon:8086/svn/mips@81 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -26,6 +26,8 @@ con_if_t con_if =
|
||||
con_if_entry, ARRAYSIZE(con_if_entry)
|
||||
};
|
||||
|
||||
uart_if_t const *dbg_uart = NULL;
|
||||
|
||||
void dbg_uart_setup();
|
||||
|
||||
void board_init(void)
|
||||
@@ -54,44 +56,53 @@ extern void dbg_handler(struct xcptcontext * xcp);
|
||||
void dbg_uart_isr(struct xcptcontext *xcp);
|
||||
void dbg_uart_setup()
|
||||
{
|
||||
uart_if_t *pUart = (uart_if_t*)con_getInstanceByName("UART-1");
|
||||
const int UART_INT = SYS_INT_UART1;
|
||||
dbg_uart = (uart_if_t*)con_getInterfaceByName("UART-1")->pInst;
|
||||
|
||||
*pUart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||
interrupt_register(SYS_INT_UART1, dbg_uart_isr);
|
||||
interrupt_enable(SYS_INT_UART1);
|
||||
*dbg_uart->pCTRL = SYS_UART_BIT_RX_INTEN;
|
||||
interrupt_register(UART_INT, dbg_uart_isr);
|
||||
interrupt_enable(UART_INT);
|
||||
}
|
||||
|
||||
void dbg_uart_isr(struct xcptcontext *xcp)
|
||||
{
|
||||
uart_if_t *pUart = (uart_if_t*)con_getInstanceByName("UART-1");
|
||||
|
||||
if(SYS_UART_BIT_RX_AVAIL & *pUart->pCTRL)
|
||||
if(SYS_UART_BIT_RX_AVAIL & *dbg_uart->pCTRL)
|
||||
{
|
||||
char c = *pUart->pDATA;
|
||||
char c = *dbg_uart->pDATA;
|
||||
if (c == 3)
|
||||
{
|
||||
// Disable UART interrupt
|
||||
// to prevent consuming uart data in ISR during single step
|
||||
// Interrupts mask bits are recovered on return from exception
|
||||
//interrupt_disable(SYS_INT_UART1);
|
||||
//uint32_t im = 1 << SYS_INT_UART1;
|
||||
//xcp->sr &= ~(SR_MASK_IM & (im << 8));
|
||||
//*pUart->pCTRL &= ~SYS_UART_BIT_RX_INTEN;
|
||||
dbg_handler(xcp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void _dbg_writechar(uart_if_t const *pUart, char c)
|
||||
{
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pUart->pCTRL) != 0);
|
||||
|
||||
*pUart->pDATA = (uint32_t)c;
|
||||
|
||||
}
|
||||
|
||||
inline char _dbg_readchar(uart_if_t const *pUart)
|
||||
{
|
||||
// busy read
|
||||
while(!(SYS_UART_BIT_RX_AVAIL & *pUart->pCTRL));
|
||||
|
||||
return (*pUart->pDATA & 0xFF);
|
||||
|
||||
}
|
||||
|
||||
void dbg_putchar(char c)
|
||||
{
|
||||
if (c == 0x0A)
|
||||
{
|
||||
writechar(4, 0x0D);
|
||||
_dbg_writechar(dbg_uart, 0x0D);
|
||||
}
|
||||
writechar(4, c);
|
||||
_dbg_writechar(dbg_uart, c);
|
||||
}
|
||||
|
||||
char dbg_getchar()
|
||||
{
|
||||
return (char)readchar(4);
|
||||
return (char)_dbg_readchar(dbg_uart);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user