diff --git a/cMIPS/include/handlers.s b/cMIPS/include/handlers.s index 59d06e1840b31098c09430f1f0b12fe89c070f2c..f981f56f575f674bf775ede6744a6032836cda19 100644 --- a/cMIPS/include/handlers.s +++ b/cMIPS/include/handlers.s @@ -70,7 +70,7 @@ extCounter: # interrupt handler for UART attached to IP6=HW4 # for UART's address see vhdl/packageMemory.vhd # - .global Ud, _uart_buff + .global Ud, _uart_buff, proberxs .bss .align 2 Ud: @@ -83,6 +83,12 @@ tx_q: .space 16 # transmission queue and pointers nrx: .space 4 # characters in RX_queue ntx: .space 4 # spaces left in TX_queue +proberxs: +framing:.space 1 +overun: .space 1 +ign22: .space 22 +rxnum: .space 8 + _uart_buff: .space 16*4 # up to 16 registers to be saved here .set UART_rx_irq,0x08 diff --git a/cMIPS/include/structUart.h b/cMIPS/include/structUart.h index c2fa9080934f9ba3d81e9ecb6f3ef0032f247d94..296b6af21662c07e2299e60c2cd14becb985cdc8 100644 --- a/cMIPS/include/structUart.h +++ b/cMIPS/include/structUart.h @@ -47,4 +47,13 @@ typedef struct serial { TctlStat cs; // @ (int *)IO_UART_ADDR Tdata d; // @ (int *)(IO_UART_ADDR+1) } Tserial; + +typedef struct proberx { + unsigned int + framing : 1, // framing error + overun : 1, // overrun + ign22 : 22, // padding + rxnum : 8; // até 255 caracteres na fila (são <= 16) +} Tproberx; + #endif diff --git a/cMIPS/tests/handlerUART.s b/cMIPS/tests/handlerUART.s index 2c4d73912e3fe8009bd0e30cc5acf761aa8e0433..627910a98aaddbd2017be055663048db962ace6d 100644 --- a/cMIPS/tests/handlerUART.s +++ b/cMIPS/tests/handlerUART.s @@ -106,8 +106,18 @@ UARTrxinter: nop overrun: - jal print - li $a0, 64017 + lui $5, %hi(proberxs) + ori $5, $5, %lo(proberxs) + lw $7, 0($5) + nop + + la $6, 0x40000000 + or $6, $6, $7 + sw $6, 0($5) + nop + + #jal print + #move $a0, $6 # move $a0, $7 # do something if rx queue is full or tx is empty # set overrun bit on uart statusReg diff --git a/cMIPS/tests/jedidafu.c b/cMIPS/tests/jedidafu.c index 14f95ae404f2cda49509b3cc7178cb6794b48857..5aaa726f66ecc09f648fb1892c8ef002ecda1a56 100644 --- a/cMIPS/tests/jedidafu.c +++ b/cMIPS/tests/jedidafu.c @@ -5,6 +5,8 @@ #define MAXPOW 7 extern UARTdriver Ud ; +extern Tproberx proberxs ; + volatile Tserial *uart; // tell GCC not to optimize away code int proberx () { @@ -142,13 +144,18 @@ int main(void) { // receive a string through the UART serial interface uart = (void *)IO_UART_ADDR; // bottom of UART address range Ud.ntx = 16; // initializing number of empty spaces in tx queue - ioctl(ctrl_util(2, 1, 1, 1)); // Speed = 2, intRX = 1, intTX = 1, rts = 1 + ioctl(ctrl_util(1, 1, 1, 1)); // Speed = 2, intRX = 1, intTX = 1, rts = 1 do { state++; // state is a volatile variable just for optimize blocking - while(!proberx()) to_stdout('-'); // wait until first reception - + if(proberxs.overun){ + to_stdout('e'); + to_stdout('r'); + to_stdout('r'); + to_stdout('\0'); + return state; + } while((c=Getc()) != -1){ // dump the reception queue to the big queue filona[tlona] = c; tlona++;