MODSERIAL with support for more devices

Fork of MODSERIAL by Erik -

Revision:
2:b936b4acbd92
Parent:
0:eb2522b41db8
Child:
4:28de979b77cf
diff -r b7e435fbfe8e -r b936b4acbd92 PUTC.cpp
--- a/PUTC.cpp	Sun Nov 21 02:15:07 2010 +0000
+++ b/PUTC.cpp	Sun Nov 21 03:31:51 2010 +0000
@@ -29,24 +29,26 @@
 MODSERIAL::__putc(int c, bool block) {
     uint32_t lsr = (uint32_t)*((char *)_base + MODSERIAL_LSR);
     
-    if (lsr & 0x20 && MODSERIAL_TX_BUFFER_EMPTY ) {
-        _THR = (uint32_t)c;
-    }
-    else {
-        if (buffer[TxIrq] != (char *)NULL) {
-            if (block) while ( MODSERIAL_TX_BUFFER_FULL ) ; // Blocks!
-            else if( MODSERIAL_TX_BUFFER_FULL ) {
-                buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer.
-                _isr[TxOvIrq].call();
-                return -1;
+    if ( dmaInUse[TxIrq] == NotInUse ) {
+        if (lsr & 0x20 && MODSERIAL_TX_BUFFER_EMPTY ) {
+            _THR = (uint32_t)c;
+        }
+        else {
+            if (buffer[TxIrq] != (char *)NULL) {
+                if (block) while ( MODSERIAL_TX_BUFFER_FULL ) ; // Blocks!
+                else if( MODSERIAL_TX_BUFFER_FULL ) {
+                    buffer_overflow[TxIrq] = c; // Oh dear, no room in buffer.
+                    _isr[TxOvIrq].call();
+                    return -1;
+                }
+                buffer[TxIrq][buffer_in[TxIrq]] = c;
+                buffer_count[TxIrq]++;
+                buffer_in[TxIrq]++;
+                if (buffer_in[TxIrq] >= buffer_size[TxIrq]) {
+                    buffer_in[TxIrq] = 0;
+                }            
+                _IER |= 0x2;
             }
-            buffer[TxIrq][buffer_in[TxIrq]] = c;
-            buffer_count[TxIrq]++;
-            buffer_in[TxIrq]++;
-            if (buffer_in[TxIrq] >= buffer_size[TxIrq]) {
-                buffer_in[TxIrq] = 0;
-            }            
-            _IER |= 0x2;
         }
     }