diff --git a/lib/CPUs/MIPS/bsp/examples/test_irq.c b/lib/CPUs/MIPS/bsp/examples/test_irq.c index 9a3a32a..e5f5b35 100644 --- a/lib/CPUs/MIPS/bsp/examples/test_irq.c +++ b/lib/CPUs/MIPS/bsp/examples/test_irq.c @@ -2,6 +2,9 @@ #include #include #include "irq.h" + +#define CPU_FREQ_HZ 100000000 + #include "libsys.h" char buffer[16384]; @@ -27,15 +30,25 @@ void handler2(void) void handler3(void) { - volatile char *pUART_stat = (char*)sys_uart_stat; - volatile char *pUART_data = (char*)sys_uart_data; + volatile UINT32 *pUART0_stat = (UINT32*)sys_uart0_stat; + volatile UINT32 *pUART0_data = (UINT32*)sys_uart0_data; + volatile UINT32 *pUART1_stat = (UINT32*)sys_uart1_stat; + volatile UINT32 *pUART1_data = (UINT32*)sys_uart1_data; - while((0x10 & *pUART_stat)) + while(0x200 & *pUART0_stat) { // sputs("w: "); print_word((int)pPtr_w); sputs("\n"); if (pPtr_w == &buffer[16383]) pPtr_w = buffer; - *(pPtr_w++) = *pUART_data; + *(pPtr_w++) = *pUART0_data; + } + + while(0x200 & *pUART1_stat) + { +// sputs("w: "); print_word((int)pPtr_w); sputs("\n"); + if (pPtr_w == &buffer[16383]) + pPtr_w = buffer; + *(pPtr_w++) = *pUART1_data; } } @@ -63,6 +76,12 @@ void handler7(void) int main(void) { + volatile UINT32 *pUART0_stat = (UINT32*)sys_uart0_stat; + volatile UINT32 *pUART1_stat = (UINT32*)sys_uart1_stat; + volatile UINT32 *pUART0_baud = (UINT32*)sys_uart0_baud; + volatile UINT32 *pUART1_baud = (UINT32*)sys_uart1_baud; + + UART1_setbaud(460800); printf("Hello\n"); memset(buffer, 0, sizeof(buffer)); pPtr_r = buffer; @@ -76,6 +95,17 @@ int main(void) interrupt_register(2, handler2); interrupt_enable(2); + printf("UART0 Status = 0x%8.8X\n", *pUART0_stat); + printf("UART0 Baud = 0x%8.8X\n", *pUART0_baud); + printf("UART1 Status = 0x%8.8X\n", *pUART1_stat); + printf("UART1 Baud = 0x%8.8X\n", *pUART1_baud); + + // enable RX interrupt + *pUART0_stat |= (1 << 6); + *pUART1_stat |= (1 << 6); + printf("UART0 Status = 0x%8.8X\n", *pUART0_stat); + printf("UART1 Status = 0x%8.8X\n", *pUART1_stat); + interrupt_register(3, handler3); interrupt_enable(3);