Skip to content
Snippets Groups Projects
Commit dd35e7cb authored by Jedian Marcos Brambilla's avatar Jedian Marcos Brambilla
Browse files

proberx correto, falta fazer funcionar de verdade so

parent 023d33a1
No related branches found
No related tags found
No related merge requests found
...@@ -67,8 +67,6 @@ UARTrxinter: ...@@ -67,8 +67,6 @@ UARTrxinter:
sw $a1, 2*4($k0) # and return from interrupt sw $a1, 2*4($k0) # and return from interrupt
addiu $a1, $zero, 1 addiu $a1, $zero, 1
sw $a1, 3*4($k0) # Signal new arrival sw $a1, 3*4($k0) # Signal new arrival
# Jedian: when a new char is on the UART's buffer,
# i have to enqueue it and update nrx.
# check if queue is full, maybe increment # check if queue is full, maybe increment
lui $5, %hi(nrx) lui $5, %hi(nrx)
......
...@@ -10,6 +10,8 @@ extern Tproberx proberxs ; ...@@ -10,6 +10,8 @@ extern Tproberx proberxs ;
volatile Tserial *uart; // tell GCC not to optimize away code volatile Tserial *uart; // tell GCC not to optimize away code
int proberx () { int proberx () {
if(proberxs.overun)
return -1;
return Ud.nrx; return Ud.nrx;
} }
...@@ -144,15 +146,15 @@ int main(void) { // receive a string through the UART serial interface ...@@ -144,15 +146,15 @@ int main(void) { // receive a string through the UART serial interface
uart = (void *)IO_UART_ADDR; // bottom of UART address range uart = (void *)IO_UART_ADDR; // bottom of UART address range
Ud.ntx = 16; // initializing number of empty spaces in tx queue Ud.ntx = 16; // initializing number of empty spaces in tx queue
ioctl(ctrl_util(1, 1, 1, 1)); // Speed = 2, intRX = 1, intTX = 1, rts = 1 ioctl(ctrl_util(2, 1, 1, 1)); // Speed = 2, intRX = 1, intTX = 1, rts = 1
do { do {
state++; // state is a volatile variable just for optimize blocking state++; // state is a volatile variable just for optimize blocking
while(!proberx()) to_stdout('-'); // wait until first reception while(!proberx()) to_stdout('-'); // wait until first reception
if(proberxs.overun){ if(proberx() == -1){
to_stdout('e'); to_stdout('E');
to_stdout('r'); to_stdout('R');
to_stdout('r'); to_stdout('R');
to_stdout('\0'); to_stdout('\0');
return state; return state;
} }
...@@ -177,8 +179,14 @@ int main(void) { // receive a string through the UART serial interface ...@@ -177,8 +179,14 @@ int main(void) { // receive a string through the UART serial interface
j = -1; j = -1;
do { do {
j++; j++;
while(((rxz = proberx())<10) && !(q=Putc(p[j]))); while(((rxz = proberx())<10 && (rxz >= 0)) && !(q=Putc(p[j])));
if(rxz == -1){
to_stdout('E');
to_stdout('R');
to_stdout('R');
to_stdout('\0');
return state;
}
while((c=Getc()) != -1){ while((c=Getc()) != -1){
filona[tlona] = c; filona[tlona] = c;
tlona++; tlona++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment