Skip to content
Snippets Groups Projects
Commit 1dd59a11 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Transmission and reception working :)

parent 6ac0e1cc
Branches
No related tags found
No related merge requests found
......@@ -10,9 +10,6 @@ RX:
lw $a1, 48($a0) # Read nrx
la $2,x_IO_BASE_ADDR
sw $a1,0($2) # Print for debug
addiu $k1, $zero, 16
slt $k1, $a1, $k1 # If nrx >= 16 the queue is full
beq $k1, $zero, END
......@@ -34,8 +31,9 @@ RX:
nop
sb $k1, 0($a0) # Put data on RX_queue tail
la $2,x_IO_BASE_ADDR
sw $a0,0($2) # Print for debug
# lui $a0, %hi(x_IO_BASE_ADDR)
# ori $a0, $a0, %lo(x_IO_BASE_ADDR)
# sw $k1, 0($a0) # Print for debug
......
......@@ -61,26 +61,26 @@ int Putc(char); // inserts char in queue, decrements ntx
void initUd();
extern UARTDriver Ud;
volatile Tserial *uart;
int main(){
int i;
volatile int state; // tell GCC not to optimize away code
volatile Tserial *uart;
volatile Tstatus status;
volatile char c;
volatile char c, last;
uart = (void *)IO_UART_ADDR; // bottom of UART address range
Tcontrol ctrl;
uart = (void *)IO_UART_ADDR; // bottom of UART address range
ctrl.ign = 0;
ctrl.intTX = 0;
ctrl.intRX = 1;
ctrl.speed = 1; // operate at 1/2 of the highest data rate
ctrl.speed = 2; // operate at 1/2 of the highest data rate
uart->cs.ctl = ctrl;
initUd();
uart->d.tx = 'a';
//uart->d.tx = 'a';
//print(lol);
/*while(c!='\n'){
......@@ -90,8 +90,13 @@ int main(){
c=getc();
}*/
while(1)
c=getc();
last = '0';
while((c=getc()) != '\0'){
if(c != EOF) {
while(!Putc(c)); // Wait till there's space on queue
}
}
Putc(c); // Sends '\0'
return 0;
}
......@@ -127,6 +132,11 @@ char getc(){
int Putc(char c){
int sent;
if(Ud.ntx == 16) {
uart->d.tx = c;
return 1;
}
if(Ud.ntx > 0){
Ud.tx_q[Ud.tx_tl] = c;
Ud.tx_tl = (Ud.tx_tl+1)%16;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment