MAX3100, an external serial device to add additional serial ports via SPI

Dependents:   FLIGHT_CONTROL_AND_COMMUNICATIONS_SYSTEM

Revision:
2:2a49171453d5
Parent:
1:46c8c60e744a
--- a/MAX3100.h	Mon Jan 17 01:14:16 2011 +0000
+++ b/MAX3100.h	Fri Aug 03 12:28:27 2012 +0000
@@ -143,6 +143,13 @@
     MAX3100Dummy  *_cs_obj;
     void (MAX3100Dummy::*_cs_method)(int, int);
 
+    // C style callback function pointer for user isr callback.    
+    void (*_isr_user_function)(int); 
+
+    // C++ style callback method pointer for external CS control
+    MAX3100Dummy  *_isr_user_obj;
+    void (MAX3100Dummy::*_isr_user_method)(int);
+    
     // Internal CS control.
     void cs_value(int);
     
@@ -154,6 +161,12 @@
 
 public:
     
+    static const int ISR    = 0;
+    
+    static const int ISR_RX = 1;
+    
+    static const int ISR_TX = 2;
+    
     /** Constructor
      */
     MAX3100() { error( "No pins supplied to constructor" ); }
@@ -319,6 +332,21 @@
         _cs_obj = (MAX3100Dummy *)item; _cs_method = (void (MAX3100Dummy::*)(int, int))method; 
     }
     
+    /** attach_isr_user
+     * is controlling the chip CS line.
+     * @param function A C function pointer
+     */
+    void attach_isr_user(void (*function)(int) = 0) { _isr_user_function = function; }
+    
+    /** attach_isr_user
+     * @param object An object that conatins the callback method.
+     * @param method The method within the object to call.
+     */
+    template<class T> 
+    void attach_isr_user(T* item, void (T::*method)(int)) { 
+        _isr_user_obj = (MAX3100Dummy *)item; _isr_user_method = (void (MAX3100Dummy::*)(int))method; 
+    }
+    
 };
 
 }; // namespace AjK ends.