This is the mail archive of the ecos-discuss@sourceware.cygnus.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

inital patch for PID driver



Hi,
	Please find attached a cleanup patch for the pid driver in CVS, 

it does two things, cleans up #defines as was done for AEB driver before,
fixes a bug I think exists,

if the UART receives a byte and raises the interrupt line but the CPU
has interrupts disabled (for some reason), and the UART receives a second
byte (which it sticks in the FIFO), now the CPU comes along and see the
interrupt and only takes one byte from the FIFO, does the UART keep the
line raised until the FIFO has emptied?? if not then we are always a byte
behind, so I've stuck in a while loop to read all the bytes from the
receiver FIFO, 

I'm not sure if the second piece is needed but it helps some code I'm
working on here run better...

Dave.


-- 
      David Airlie, Software Engineer, Parthus Technologies plc.,
       Mary Rosse Centre, National Tech Park, Limerick, Ireland.
   t: +353-61-508116 / f: +353-61-508101 / David.Airlie@parthus.com
diff -ur packages.orig/devs/serial/arm/pid/current/src/pid_serial.h packages/devs/serial/arm/pid/current/src/pid_serial.h
--- packages.orig/devs/serial/arm/pid/current/src/pid_serial.h	Tue Apr 18 22:52:04 2000
+++ packages/devs/serial/arm/pid/current/src/pid_serial.h	Tue Jun  6 17:33:59 2000
@@ -53,29 +53,29 @@
 // Little-endian version
 #if (CYG_BYTEORDER == CYG_LSBFIRST)
 
-#define reg(n) _byte[n*4]
+#define REG(n) _byte[n*4]
 
 #else // Big-endian version
 
-#define reg(n) _byte[(n*4)^3]
+#define REG(n) _byte[(n*4)^3]
 
 #endif
 
-// Receive control registers
-#define rhr reg(0)    // Receive holding register
-#define isr reg(2)    // Interrupt status register
-#define lsr reg(5)    // Line status register
-#define msr reg(6)    // Modem status register
-#define scr reg(7)    // Scratch register
-
-// Transmit control registers
-#define thr reg(0)    // Transmit holding register
-#define ier reg(1)    // Interrupt enable register
-#define fcr reg(2)    // FIFO control register
-#define lcr reg(3)    // Line control register
-#define mcr reg(4)    // Modem control register
-#define ldl reg(0)    // LSB of baud rate
-#define mdl reg(1)    // MSB of baud rate
+// Receive control Registers
+#define REG_rhr REG(0)    // Receive holding register
+#define REG_isr REG(2)    // Interrupt status register
+#define REG_lsr REG(5)    // Line status register
+#define REG_msr REG(6)    // Modem status register
+#define REG_scr REG(7)    // Scratch register
+
+// Transmit control Registers
+#define REG_thr REG(0)    // Transmit holding register
+#define REG_ier REG(1)    // Interrupt enable register
+#define REG_fcr REG(2)    // FIFO control register
+#define REG_lcr REG(3)    // Line control register
+#define REG_mcr REG(4)    // Modem control register
+#define REG_ldl REG(0)    // LSB of baud rate
+#define REG_mdl REG(1)    // MSB of baud rate
 
 // Interrupt Enable Register
 #define IER_RCV 0x01
@@ -107,7 +107,7 @@
 #define MCR_RTS 0x02
 #define MCR_INT 0x08   // Enable interrupts
 
-// Interrupt status register
+// Interrupt status Register
 #define ISR_Tx  0x02
 #define ISR_Rx  0x04
 #define ISR_RxTO  0x0C
diff -ur packages.orig/devs/serial/arm/pid/current/src/pid_serial_with_ints.c packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c
--- packages.orig/devs/serial/arm/pid/current/src/pid_serial_with_ints.c	Tue Apr 18 22:52:04 2000
+++ packages/devs/serial/arm/pid/current/src/pid_serial_with_ints.c	Tue Jun  6 17:35:34 2000
@@ -168,26 +168,26 @@
     unsigned short baud_divisor = select_baud[new_config->baud];
     unsigned char _lcr, _ier;
     if (baud_divisor == 0) return false;  // Invalid configuration
-    _ier = port->ier;
-    port->ier = 0;  // Disable port interrupts while changing hardware
+    _ier = port->REG_ier;
+    port->REG_ier = 0;  // Disable port interrupts while changing hardware
     _lcr = select_word_length[new_config->word_length - CYGNUM_SERIAL_WORD_LENGTH_5] | 
         select_stop_bits[new_config->stop] |
         select_parity[new_config->parity];
-    port->lcr = _lcr;
-    port->lcr |= LCR_DL;
-    port->mdl = baud_divisor >> 8;
-    port->ldl = baud_divisor & 0xFF;
-    port->lcr &= ~LCR_DL;
+    port->REG_lcr = _lcr;
+    port->REG_lcr |= LCR_DL;
+    port->REG_mdl = baud_divisor >> 8;
+    port->REG_ldl = baud_divisor & 0xFF;
+    port->REG_lcr &= ~LCR_DL;
     if (init) {
-        port->fcr = 0x07;  // Enable and clear FIFO
+        port->REG_fcr = 0x07;  // Enable and clear FIFO
         if (chan->out_cbuf.len != 0) {
-            port->ier = IER_RCV;
+            port->REG_ier = IER_RCV;
         } else {
-            port->ier = 0;
+            port->REG_ier = 0;
         }
-        port->mcr = MCR_INT|MCR_DTR|MCR_RTS;  // Master interrupt enable
+        port->REG_mcr = MCR_INT|MCR_DTR|MCR_RTS;  // Master interrupt enable
     } else {
-        port->ier = _ier;
+        port->REG_ier = _ier;
     }
     if (new_config != &chan->config) {
         chan->config = *new_config;
@@ -238,9 +238,9 @@
 {
     pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv;
     volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base;
-    if (port->lsr & LSR_THE) {
+    if (port->REG_lsr & LSR_THE) {
 // Transmit buffer is empty
-        port->thr = c;
+        port->REG_thr = c;
         return true;
     } else {
 // No space
@@ -255,8 +255,8 @@
     unsigned char c;
     pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv;
     volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base;
-    while ((port->lsr & LSR_RSR) == 0) ;   // Wait for char
-    c = port->rhr;
+    while ((port->REG_lsr & LSR_RSR) == 0) ;   // Wait for char
+    c = port->REG_rhr;
     return c;
 }
 
@@ -273,7 +273,7 @@
 {
     pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv;
     volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base;
-    port->ier |= IER_XMT;  // Enable xmit interrupt
+    port->REG_ier |= IER_XMT;  // Enable xmit interrupt
 }
 
 // Disable the transmitter on the device
@@ -282,7 +282,7 @@
 {
     pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv;
     volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base;
-    port->ier &= ~IER_XMT;  // Disable xmit interrupt
+    port->REG_ier &= ~IER_XMT;  // Disable xmit interrupt
 }
 
 // Serial I/O - low level interrupt handler (ISR)
@@ -304,13 +304,14 @@
     pid_serial_info *pid_chan = (pid_serial_info *)chan->dev_priv;
     volatile struct serial_port *port = (volatile struct serial_port *)pid_chan->base;
     unsigned char isr;
-    while ((isr = port->isr & 0x0E) != 0) {
+    while ((isr = port->REG_isr & 0x0E) != 0) {
         if (isr == ISR_Tx) {
             (chan->callbacks->xmt_char)(chan);
         } else if (isr == ISR_RxTO) {
-            (chan->callbacks->rcv_char)(chan, port->rhr);
+            (chan->callbacks->rcv_char)(chan, port->REG_rhr);
         } else if (isr == ISR_Rx) {
-            (chan->callbacks->rcv_char)(chan, port->rhr);
+	  while(port->REG_lsr & LSR_RSR)
+            (chan->callbacks->rcv_char)(chan, port->REG_rhr);
         }
     }
     cyg_drv_interrupt_unmask(pid_chan->int_num);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]