Merge pull request #139 from geky/callback-fixes

Small fixes for issues with Callback class
Martin Kojtal 2016-05-27 09:14:02 +01:00
commit 08ecdb296b
4 changed files with 55 additions and 7 deletions

View File

@ -218,8 +218,20 @@ public:
* @param method pointer to the member function to be called
* @param event Which CAN interrupt to attach the member function to (CAN::RxIrq for message received, TxIrq for transmitted or aborted, EwIrq for error warning, DoIrq for data overrun, WuIrq for wake-up, EpIrq for error passive, AlIrq for arbitration lost, BeIrq for bus error)
*/
template<typename T>
void attach(T* obj, void (T::*method)(void), IrqType type=RxIrq) {
template<typename T>
void attach(T* obj, void (T::*method)(), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}
/** Attach a member function to call whenever a CAN frame received interrupt
* is generated.
*
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to be called
* @param event Which CAN interrupt to attach the member function to (CAN::RxIrq for message received, TxIrq for transmitted or aborted, EwIrq for error warning, DoIrq for data overrun, WuIrq for wake-up, EpIrq for error passive, AlIrq for arbitration lost, BeIrq for bus error)
*/
template<typename T>
void attach(T* obj, void (*method)(T*), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}

View File

@ -106,6 +106,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2, a3, a4);
}
@ -244,6 +247,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2, A3 a3) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2, a3);
}
@ -382,6 +388,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2);
}
@ -520,6 +529,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1);
}
@ -658,6 +670,9 @@ public:
/** Call the attached function
*/
R call(A0 a0) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0);
}
@ -796,7 +811,7 @@ public:
/** Call the attached function
*/
R call() {
if (NULL == _thunk) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func);

View File

@ -100,8 +100,19 @@ public:
* @param method pointer to the member function to be called
* @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
*/
template<typename T, typename M>
void attach(T *obj, M method, IrqType type=RxIrq) {
template<typename T>
void attach(T *obj, void (T::*method)(), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}
/** Attach a member function to call whenever a serial interrupt is generated
*
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to be called
* @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 *obj, void (*method)(T*), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}

View File

@ -149,8 +149,18 @@ public:
* @param method pointer to the member function to call
* @param type Which serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)
*/
template <typename T, typename M>
void attach(T *obj, M method, IrqType type=RxIrq) {
template <typename T>
void attach(T *obj, void (T::*method)(), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}
/** Attach a member function to call whenever a serial interrupt is generated
* @param obj pointer to the object to call the member function on
* @param method pointer to the member function to call
* @param type Which serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)
*/
template <typename T>
void attach(T *obj, void (*method)(T*), IrqType type=RxIrq) {
attach(Callback<void()>(obj, method), type);
}
};