MODSERIAL with support for more devices

Dependents:   1D-Pong BMT-K9_encoder BMT-K9-Regelaar programma_filter ... more

Check the cookbook page for more information: https://mbed.org/cookbook/MODSERIAL

Did you add a device? Please send a pull request so we can keep everything in one library instead of many copies. In that case also send a PM, since currently mbed does not inform of new pull requests. I will then also add you to the developers of this library so you can do other changes directly.

Revision:
4:28de979b77cf
Parent:
2:b936b4acbd92
Child:
5:8365c4cf8f33
--- a/PUTC.cpp	Sun Nov 21 13:58:53 2010 +0000
+++ b/PUTC.cpp	Sun Nov 21 14:44:02 2010 +0000
@@ -29,29 +29,27 @@
 MODSERIAL::__putc(int c, bool block) {
     uint32_t lsr = (uint32_t)*((char *)_base + MODSERIAL_LSR);
     
-    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;
+    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;
         }
     }
-    
+      
     return 0;
 }