Skip to content
Snippets Groups Projects
Commit 6e50bd82 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Transmission almost complete. It works, but still has some problems

parent eee0c716
No related branches found
No related tags found
1 merge request!1Transmission
...@@ -4,4 +4,3 @@ ffffffff ...@@ -4,4 +4,3 @@ ffffffff
7C2 7C2
...@@ -31,9 +31,14 @@ RX: ...@@ -31,9 +31,14 @@ RX:
nop nop
sb $k1, 0($a0) # Put data on RX_queue tail sb $k1, 0($a0) # Put data on RX_queue tail
lui $a0, %hi(x_IO_BASE_ADDR) # lui $a0, %hi(x_IO_BASE_ADDR)
ori $a0, $a0, %lo(x_IO_BASE_ADDR) # ori $a0, $a0, %lo(x_IO_BASE_ADDR)
sw $k1, 0($a0) # Print for debug # sw $k1, 0($a0) # Print for debug
lw $k1, 0($a1)
j RX
nop
...@@ -75,5 +80,9 @@ TX: ...@@ -75,5 +80,9 @@ TX:
# ori $a0, $a0, %lo(x_IO_BASE_ADDR) # ori $a0, $a0, %lo(x_IO_BASE_ADDR)
# sw $a1, 0($a0) # Print for debug # sw $a1, 0($a0) # Print for debug
lw $k1, 0($a0)
j RX
nop
END: END:
...@@ -56,7 +56,7 @@ int probetx(void); // returns ntx ...@@ -56,7 +56,7 @@ int probetx(void); // returns ntx
int iostat(void); // returns integer with status at lsb int iostat(void); // returns integer with status at lsb
void ioctl(int); // write lsb in control register void ioctl(int); // write lsb in control register
char getc(void); // returns char in queue, decrements nrx char getc(void); // returns char in queue, decrements nrx
int Putc(char); // inserts char in queue, decrements ntx void Putc(char); // inserts char in queue, decrements ntx
int ctoi(char); // converts a character to an integer int ctoi(char); // converts a character to an integer
void initUd(); void initUd();
...@@ -76,35 +76,27 @@ int main(){ ...@@ -76,35 +76,27 @@ int main(){
ctrl.ign = 0; ctrl.ign = 0;
ctrl.intTX = 1; ctrl.intTX = 1;
ctrl.intRX = 1; 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; uart->cs.ctl = ctrl;
initUd(); initUd();
int lol;
char last = EOF; char last = EOF;
char first = EOF; // FIXME: Não tah saindo do while (por causa do ctrl.intTX =1)
while(!((c = getc()) == '\n' && c == last)) { while(!((c = getc()) == '\n' && c == last)) {
last = c;
print(c);
if(c != EOF) { if(c != EOF) {
if(!Putc(c)){ print(c);
print(0); last = c;
while(!(TXempty&uart->cs.stat.s)); Putc(c);
}
}
if(Ud.ntx < 16){
disableInterr(); disableInterr();
first = Ud.tx_q[Ud.tx_hd]; uart->d.tx = Ud.tx_q[Ud.tx_hd];
Ud.tx_hd = (Ud.tx_hd+1)%16; Ud.tx_hd = (Ud.tx_hd+1)%16;
Ud.ntx++; Ud.ntx++;
enableInterr(); enableInterr();
uart->d.tx = first;
Putc(c);
}
} }
} while(1);
// for(i=0;i<Ud.ntx;i++){
// print(Ud.tx_q[i]);
// }
// to_stdout('\n');
//uart->d.tx = '\n'; //Send STX (Start of Text)
// while((c = getc()) != '\0') { // while((c = getc()) != '\0') {
// if(c != EOF) { // if(c != EOF) {
...@@ -148,16 +140,22 @@ char getc(){ ...@@ -148,16 +140,22 @@ char getc(){
return c; return c;
} }
int Putc(char c){ void Putc(char c){
if(Ud.ntx > 0){ if(Ud.ntx > 0){
disableInterr(); disableInterr();
Ud.tx_q[Ud.tx_tl] = c; Ud.tx_q[Ud.tx_tl] = c;
Ud.tx_tl = (Ud.tx_tl+1)%16; Ud.tx_tl = (Ud.tx_tl+1)%16;
Ud.ntx--; Ud.ntx--;
enableInterr(); enableInterr();
return 1; }else{
while(!(TXempty&uart->cs.stat.s));
disableInterr();
uart->d.tx = Ud.tx_q[Ud.tx_hd];
Ud.tx_hd = (Ud.tx_hd+1)%16;
Ud.ntx++;
enableInterr();
Putc(c);
} }
return 0;
} }
int proberx(){ int proberx(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment