mbed library sources

Dependents:   PA_Boost_test

Fork of mbed-src by mbed official

Revision:
36:ab3ee77451e7
Parent:
35:371630885ad6
Child:
69:49e45cb70de1
diff -r 371630885ad6 -r ab3ee77451e7 api/InterruptIn.h
--- a/api/InterruptIn.h	Mon Oct 21 11:45:04 2013 +0100
+++ b/api/InterruptIn.h	Wed Oct 23 14:15:04 2013 +0100
@@ -22,9 +22,7 @@
 
 #include "gpio_api.h"
 #include "gpio_irq_api.h"
-
 #include "FunctionPointer.h"
-#include "CallChain.h"
 
 namespace mbed {
 
@@ -73,167 +71,37 @@
     /** Attach a function to call when a rising edge occurs on the input
      *
      *  @param fptr A pointer to a void function, or 0 to set as none
-     *
-     *  @returns
-     *  The function object created for 'fptr'
      */
-    pFunctionPointer_t rise(void (*fptr)(void));
-
-    /** Add a function to be called when a rising edge occurs at the end of the call chain
-     *
-     *  @param fptr the function to add
-     *
-     *  @returns
-     *  The function object created for 'fptr'
-     */
-    pFunctionPointer_t rise_add(void (*fptr)(void)) {
-        return rise_add_common(fptr);
-    }
-
-    /** Add a function to be called when a rising edge occurs at the beginning of the call chain
-     *
-     *  @param fptr the function to add
-     *
-     *  @returns
-     *  The function object created for 'fptr'
-     */
-    pFunctionPointer_t rise_add_front(void (*fptr)(void)) {
-        return rise_add_common(fptr, true);
-    }
+    void rise(void (*fptr)(void));
 
     /** Attach a member function to call when a rising edge occurs on the input
      *
      *  @param tptr pointer to the object to call the member function on
      *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
-     */
-    template<typename T>
-    pFunctionPointer_t rise(T* tptr, void (T::*mptr)(void)) {
-        _rise.clear();
-        pFunctionPointer_t pf = _rise.add(tptr, mptr);
-        gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
-        return pf;
-    }
-
-    /** Add a function to be called when a rising edge occurs at the end of the call chain
-     *
-     *  @param tptr pointer to the object to call the member function on
-     *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
      */
     template<typename T>
-    pFunctionPointer_t rise_add(T* tptr, void (T::*mptr)(void)) {
-        return rise_add_common(tptr, mptr);
+    void rise(T* tptr, void (T::*mptr)(void)) {
+        _rise.attach(tptr, mptr);
+        gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
     }
 
-    /** Add a function to be called when a rising edge occurs at the beginning of the call chain
-     *
-     *  @param tptr pointer to the object to call the member function on
-     *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
-     */
-    template<typename T>
-    pFunctionPointer_t rise_add_front(T* tptr, void (T::*mptr)(void)) {
-        return rise_add_common(tptr, mptr, true);
-    }
-
-    /** Remove a function from the list of functions to be called when a rising edge occurs
-     *
-     *  @param pf the function object to remove
-     *
-     *  @returns
-     *  true if the function was found and removed, false otherwise
-     */
-    bool rise_remove(pFunctionPointer_t pf);
-
     /** Attach a function to call when a falling edge occurs on the input
      *
      *  @param fptr A pointer to a void function, or 0 to set as none
-     *
-     *  @returns
-     *  The function object created for 'fptr'
      */
-    pFunctionPointer_t fall(void (*fptr)(void));
-
-     /** Add a function to be called when a falling edge occurs at the end of the call chain
-     *
-     *  @param fptr the function to add
-     *
-     *  @returns
-     *  The function object created for 'fptr'
-     */
-    pFunctionPointer_t fall_add(void (*fptr)(void)) {
-        return fall_add_common(fptr);
-    }
-
-    /** Add a function to be called when a falling edge occurs at the beginning of the call chain
-     *
-     *  @param fptr the function to add
-     *
-     *  @returns
-     *  The function object created for 'fptr'
-     */
-    pFunctionPointer_t fall_add_front(void (*fptr)(void)) {
-        return fall_add_common(fptr, true);
-    }
+    void fall(void (*fptr)(void));
 
     /** Attach a member function to call when a falling edge occurs on the input
      *
      *  @param tptr pointer to the object to call the member function on
      *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
-     */
-    template<typename T>
-    pFunctionPointer_t fall(T* tptr, void (T::*mptr)(void)) {
-        _fall.clear();
-        pFunctionPointer_t pf = _fall.add(tptr, mptr);
-        gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
-        return pf;
-    }
-
-    /** Add a function to be called when a falling edge occurs at the end of the call chain
-     *
-     *  @param tptr pointer to the object to call the member function on
-     *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
      */
     template<typename T>
-    pFunctionPointer_t fall_add(T* tptr, void (T::*mptr)(void)) {
-        return fall_add_common(tptr, mptr);
+    void fall(T* tptr, void (T::*mptr)(void)) {
+        _fall.attach(tptr, mptr);
+        gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
     }
 
-    /** Add a function to be called when a falling edge occurs at the beginning of the call chain
-     *
-     *  @param tptr pointer to the object to call the member function on
-     *  @param mptr pointer to the member function to be called
-     *
-     *  @returns
-     *  The function object created for 'tptr' and 'mptr'
-     */
-    template<typename T>
-    pFunctionPointer_t fall_add_front(T* tptr, void (T::*mptr)(void)) {
-        return fall_add_common(tptr, mptr, true);
-    }
-
-    /** Remove a function from the list of functions to be called when a falling edge occurs
-     *
-     *  @param pf the function object to remove
-     *
-     *  @returns
-     *  true if the function was found and removed, false otherwise
-     */
-    bool fall_remove(pFunctionPointer_t pf);
-
     /** Set the input pin mode
      *
      *  @param mode PullUp, PullDown, PullNone
@@ -251,27 +119,11 @@
     static void _irq_handler(uint32_t id, gpio_irq_event event);
 
 protected:
-    pFunctionPointer_t rise_add_common(void (*fptr)(void), bool front=false);
-    pFunctionPointer_t fall_add_common(void (*fptr)(void), bool front=false);
-
-    template<typename T>
-    pFunctionPointer_t rise_add_common(T* tptr, void (T::*mptr)(void), bool front=false) {
-        pFunctionPointer_t pf = front ? _rise.add_front(tptr, mptr) : _rise.add(tptr, mptr);
-        gpio_irq_set(&gpio_irq, IRQ_RISE, 1);
-        return pf;
-    }
-    template<typename T>
-    pFunctionPointer_t fall_add_common(T* tptr, void (T::*mptr)(void), bool front=false) {
-        pFunctionPointer_t pf = front ? _fall.add_front(tptr, mptr) : _fall.add(tptr, mptr);
-        gpio_irq_set(&gpio_irq, IRQ_FALL, 1);
-        return pf;
-    }
-
     gpio_t gpio;
     gpio_irq_t gpio_irq;
 
-    CallChain _rise;
-    CallChain _fall;
+    FunctionPointer _rise;
+    FunctionPointer _fall;
 };
 
 } // namespace mbed