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:
27:9c93ce7cb9d8
Parent:
22:c11ea36f17f9
--- a/GETC.cpp	Mon Jun 10 19:06:21 2013 +0000
+++ b/GETC.cpp	Thu Jul 11 13:34:53 2013 +0000
@@ -32,8 +32,8 @@
     // Note, we must block in this case and ignore bool "block" 
     // so as to maintain compat with Mbed Serial.
     if (buffer_size[RxIrq] == 0 || buffer[RxIrq] == (char *)NULL) {
-        while(! MODSERIAL_RBR_HAS_DATA ) ;
-        return (int)(_RBR & 0xFF);
+        while(! MODSERIAL_READABLE ) ;
+        return (int)(MODSERIAL_READ_REG & 0xFF);
     }
 
     if (block) { while ( MODSERIAL_RX_BUFFER_EMPTY ) ; } // Blocks.
@@ -50,10 +50,10 @@
     // Temporarily disable the RX IRQ so that we do not re-enter 
     // it under interrupts.
     if ( ! MODSERIAL_RX_BUFFER_FULL ) {
-        uint32_t ier = _IER;
-        _IER &= ~(1UL << 0);
+        uint32_t irq_reg = MODSERIAL_IRQ_REG;
+        DISABLE_RX_IRQ;
         isr_rx();    
-        _IER = ier;
+        MODSERIAL_IRQ_REG = irq_reg;
     }
     
     __disable_irq();