- added interrupt handler
git-svn-id: http://moon:8086/svn/mips@33 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+18
-8
@@ -1,28 +1,38 @@
|
||||
#include "libsys_boot.h"
|
||||
|
||||
void handler3(void)
|
||||
{
|
||||
volatile uint32_t *pUART0_stat = (uint32_t*)SYS_UART_STAT;
|
||||
volatile uint32_t *pUART0_data = (uint32_t*)SYS_UART_DATA;
|
||||
|
||||
while(0x200 & *pUART0_stat)
|
||||
{
|
||||
sputs("RX: "); print_word((int)*pUART0_data); sputs("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
uint8_t led = 0;
|
||||
volatile uint32_t *pUART0_stat = (uint32_t*)SYS_UART_STAT;
|
||||
volatile uint32_t *pGPIO = (uint32_t*)SYS_GPIO_0_DATA;
|
||||
volatile uint32_t *pGPIODIR = (uint32_t*)SYS_GPIO_0_DIR;
|
||||
volatile uint32_t *pRAM = (uint32_t*)SDRAM_BASE;
|
||||
|
||||
CP0_SR_write(0x0060000D);
|
||||
*pGPIODIR = GPIO_0_DFLT_DIR;
|
||||
uint8_t led = 0;
|
||||
|
||||
interrupt_init();
|
||||
interrupt_register(3, (void*)handler3);
|
||||
interrupt_enable(3);
|
||||
|
||||
// UART: enable RX interrupt
|
||||
*pUART0_stat |= (1 << 6);
|
||||
|
||||
CP0_SR_write(0x0060000D);
|
||||
interrupt_enable(3);
|
||||
|
||||
sputs("Hello, world!\n");
|
||||
while(1)
|
||||
{
|
||||
sputs("Iteration # ");print_word(led);sputs("\n");
|
||||
sputs("Uart status : ");print_word(*pUART0_stat);sputs("\n");
|
||||
sputs("CPU status : ");print_word(CP0_SR_read());sputs("\n");
|
||||
|
||||
*pGPIO = led;
|
||||
if(led == 0)
|
||||
|
||||
Reference in New Issue
Block a user