Software serial, for when you are out of serial pins

Dependents:   BufferedSoftSerial neurGAI_Seeed_BLUETOOTH LPC-SD-35 ESP-WROOM-02_test ... more

Revision:
4:c010265ed202
Parent:
3:7238e9bb74d2
Child:
5:acfd0329f648
--- a/SoftSerial.h	Sat Apr 26 16:35:20 2014 +0000
+++ b/SoftSerial.h	Sat Apr 26 20:04:49 2014 +0000
@@ -65,7 +65,9 @@
      *  @param fptr A pointer to a void function, or 0 to set as none
      *  @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
      */
-    void attach(void (*fptr)(void), IrqType type=RxIrq);
+    void attach(void (*fptr)(void), IrqType type=RxIrq) {
+        fpointer[type].attach(fptr);
+    }
 
     /** Attach a member function to call whenever a serial interrupt is generated
      *
@@ -74,7 +76,9 @@
      *  @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
      */
     template<typename T>
-    void attach(T* tptr, void (T::*mptr)(void), IrqType type=RxIrq);
+    void attach(T* tptr, void (T::*mptr)(void), IrqType type=RxIrq) {
+        fpointer[type].attach(tptr, mptr);
+    }
 
     /** Generate a break condition on the serial line
      */
@@ -89,6 +93,9 @@
     int _bits, _stop_bits, _total_bits;
     Parity _parity;
     
+    FunctionPointer fpointer[2];
+    
+    //rx
     void rx_gpio_irq_handler(void);
     void rx_handler(void);
     int read_buffer, rx_bit;