From fd3ddc7e4c2fae5189765e7c4319af94f690fb24 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Wed, 27 May 2015 21:39:55 +0000 Subject: [PATCH] - added interrupt handler git-svn-id: http://moon:8086/svn/mips@33 a8ebac50-d88d-4704-bea3-6648445a41b3 --- src/bootloader/test.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/bootloader/test.c b/src/bootloader/test.c index 6180cfd..da8b5ca 100644 --- a/src/bootloader/test.c +++ b/src/bootloader/test.c @@ -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)