Skip to content
Snippets Groups Projects
Commit 968857b3 authored by Roberto Hexsel's avatar Roberto Hexsel
Browse files

UART now has an independent register for clearing individual IRQs -- files missing

parent 460d2a4b
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,15 @@ typedef struct control { // control register fields (uses only ls byte)
speed : 3; // 4,8,16... {tx,rx}clock data rates (bits 0..2)
} Tcontrol;
typedef struct interr { // interrupt clear bits (uses only ls byte)
unsigned int ign : 24, // ignore uppermost 3 bytes
rts : 1, // Request to Send output (bit 7)
ign2 : 2, // bits 6,5 ignored
clrTX : 1, // interrupt on TX buffer empty (bit 4)
clrRX : 1, // interrupt on RX buffer full (bit 3)
ign3 : 3; // bits 2..0 ignored
} Tinterr;
typedef struct status { // status register fields (uses only ls byte)
unsigned int ign : 24, // ignore uppermost 3 bytes
cts : 1, // Clear To Send input=1 (bit 7)
......@@ -20,19 +29,16 @@ typedef struct status { // status register fields (uses only ls byte)
overun : 1; // overun error (bit 0)
} Tstatus;
typedef union ctlStat { // control + status on same address
Tcontrol ctl; // write-only
Tstatus stat; // read-only
} TctlStat;
typedef union data { // data registers on same address
int tx; // write-only
int rx; // read-only
} Tdata;
typedef struct serial {
TctlStat cs; // address is (int *)IO_UART_ADDR
Tdata d; // address is (int *)(IO_UART_ADDR+1)
Tcontrol ctl; // read-writ, address is (int *)IO_UART_ADDR
Tstatus stat; // read-only, address is (int *)(IO_UART_ADDR+1)
Tinterr interr; // write-only, address is (int *)(IO_UART_ADDR+2)
Tdata d; // read-write, address is (int *)(IO_UART_ADDR+3)
} Tserial;
......
......@@ -39,7 +39,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl.intTX = 0;
ctrl.intRX = 0;
ctrl.speed = SPEED;
uart->cs.ctl = ctrl; // initizlize UART
uart->ctl = ctrl; // initizlize UART
// handler sets flag=[U_FLAg] to 1 after new character is received;
// this program resets the flag on fetching a new character from buffer
......@@ -50,7 +50,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl.intTX = 0;
ctrl.intRX = 1; // do generate interrupts on RXbuffer full
ctrl.speed = SPEED; // operate at 1/4 of the highest data rate
uart->cs.ctl = ctrl;
uart->ctl = ctrl;
do {
while ( (c = (char)bfr[U_FLAG]) == 0 ) // check flag in Ud[]
......
......@@ -35,7 +35,7 @@ int main(void) { // receive a string through the UART serial interface
ctrl.intTX = 0;
ctrl.intRX = 0;
ctrl.speed = SPEED; // operate at the second highest data rate
uart->cs.ctl = ctrl;
uart->ctl = ctrl;
i = -1;
......@@ -45,19 +45,20 @@ int main(void) { // receive a string through the UART serial interface
ctrl.intTX = 0;
ctrl.intRX = 0;
ctrl.speed = SPEED; // operate at the second highest data rate
uart->cs.ctl = ctrl;
uart->ctl = ctrl;
do {
i = i+1;
while ( (state = (int)uart->cs.stat.rxFull) == 0 )
delay_cycle(1); // just do something
while ( (state = (int)uart->stat.rxFull) == 0 )
delay_cycle(1); // just do something
s[i] = (char)uart->d.rx;
if (s[i] != EOT)
if (s[i] != EOT) {
to_stdout( s[i] ); // and print new char
else
to_stdout( '\n' ); // and print new-line
} else {
to_stdout( '\n' ); // print new-line
to_stdout( EOT ); // and signal End Of Transmission
}
} while (s[i] != EOT);
return(state);
......
......@@ -62,13 +62,13 @@ int main(void) { // send a string through the UART serial interface
ctrl.ign2 = 0;
ctrl.ign = 0;
ctrl.rts = 0; // make RTS=0 so RemoteUnit won't transmit, just receive
uart->cs.ctl = ctrl;
uart->ctl = ctrl;
i = -1;
do {
i = i+1;
while ( (state = (int)uart->cs.stat.txEmpty) == 0 )
while ( (state = (int)uart->stat.txEmpty) == 0 )
delay_cycle(1); // do something
uart->d.tx = (int)s[i];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment