diff --git a/features/net/network-socket/Socket.h b/features/net/network-socket/Socket.h index c481930440f..f09f8ed9603 100644 --- a/features/net/network-socket/Socket.h +++ b/features/net/network-socket/Socket.h @@ -169,8 +169,13 @@ class Socket { * @param obj Pointer to object to call method on * @param method Method to call on state change */ - template - void attach(T *obj, M method) { + template + void attach(T *obj, void (T::*method)()) { + attach(mbed::Callback(obj, method)); + } + + template + void attach(T *obj, void (*method)(T*)) { attach(mbed::Callback(obj, method)); } diff --git a/hal/api/CallChain.h b/hal/api/CallChain.h index 473ff12a144..21552bbab60 100644 --- a/hal/api/CallChain.h +++ b/hal/api/CallChain.h @@ -88,8 +88,13 @@ class CallChain { * @returns * The function object created for 'obj' and 'method' */ - template - pFunctionPointer_t add(T *obj, M method) { + template + pFunctionPointer_t add(T *obj, void (T::*method)()) { + return add(Callback(obj, method)); + } + + template + pFunctionPointer_t add(T *obj, void (*method)(T*)) { return add(Callback(obj, method)); } @@ -110,8 +115,13 @@ class CallChain { * @returns * The function object created for 'tptr' and 'mptr' */ - template - pFunctionPointer_t add_front(T *obj, M method) { + template + pFunctionPointer_t add_front(T *obj, void (T::*method)()) { + return add_front(Callback(obj, method)); + } + + template + pFunctionPointer_t add_front(T *obj, void (*method)(T*)) { return add_front(Callback(obj, method)); } diff --git a/hal/api/InterruptIn.h b/hal/api/InterruptIn.h index 3758ab5ca34..ad0e31948ba 100644 --- a/hal/api/InterruptIn.h +++ b/hal/api/InterruptIn.h @@ -89,8 +89,15 @@ class InterruptIn { * @param obj pointer to the object to call the member function on * @param method pointer to the member function to be called */ - template - void rise(T *obj, M method) { + template + void rise(T *obj, void (T::*method)()) { + core_util_critical_section_enter(); + rise(Callback(obj, method)); + core_util_critical_section_exit(); + } + + template + void rise(T *obj, void (*method)(T*)) { core_util_critical_section_enter(); rise(Callback(obj, method)); core_util_critical_section_exit(); @@ -107,8 +114,15 @@ class InterruptIn { * @param obj pointer to the object to call the member function on * @param method pointer to the member function to be called */ - template - void fall(T *obj, M method) { + template + void fall(T *obj, void (T::*method)()) { + core_util_critical_section_enter(); + fall(Callback(obj, method)); + core_util_critical_section_exit(); + } + + template + void fall(T *obj, void (*method)(T*)) { core_util_critical_section_enter(); fall(Callback(obj, method)); core_util_critical_section_exit(); diff --git a/hal/api/Ticker.h b/hal/api/Ticker.h index 496e469fa6b..09fcae09f03 100644 --- a/hal/api/Ticker.h +++ b/hal/api/Ticker.h @@ -80,8 +80,13 @@ class Ticker : public TimerEvent { * @param method pointer to the member function to be called * @param t the time between calls in seconds */ - template - void attach(T *obj, M method, float t) { + template + void attach(T *obj, void (T::*method)(), float t) { + attach(Callback(obj, method), t); + } + + template + void attach(T *obj, void (*method)(T*), float t) { attach(Callback(obj, method), t); } @@ -101,8 +106,13 @@ class Ticker : public TimerEvent { * @param mptr pointer to the member function to be called * @param t the time between calls in micro-seconds */ - template - void attach_us(T *obj, M method, timestamp_t t) { + template + void attach_us(T *obj, void (T::*method)(), float t) { + attach_us(Callback(obj, method), t); + } + + template + void attach_us(T *obj, void (*method)(T*), float t) { attach_us(Callback(obj, method), t); } diff --git a/rtos/rtos/RtosTimer.h b/rtos/rtos/RtosTimer.h index 5f133a3058d..c61a3eefe82 100644 --- a/rtos/rtos/RtosTimer.h +++ b/rtos/rtos/RtosTimer.h @@ -62,8 +62,13 @@ class RtosTimer { @param method member function to be executed by this timer. @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) */ - template - RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) { + template + RtosTimer(T *obj, void (T::*method)(), os_timer_type type=osTimerPeriodic) { + constructor(mbed::Callback(obj, method), type); + } + + template + RtosTimer(T *obj, void (*method)(T*), os_timer_type type=osTimerPeriodic) { constructor(mbed::Callback(obj, method), type); } diff --git a/rtos/rtos/Thread.h b/rtos/rtos/Thread.h index aab4296f238..365e4758c89 100644 --- a/rtos/rtos/Thread.h +++ b/rtos/rtos/Thread.h @@ -156,8 +156,13 @@ class Thread { @param method function to be executed by this thread. @return status code that indicates the execution status of the function. */ - template - osStatus start(T *obj, M method) { + template + osStatus start(T *obj, void (T::*method)()) { + return start(mbed::Callback(obj, method)); + } + + template + osStatus start(T *obj, void (*method)(T*)) { return start(mbed::Callback(obj, method)); }