diff --git a/features/unsupported/USBDevice/USBAudio/USBAudio.h b/features/unsupported/USBDevice/USBAudio/USBAudio.h index f1bdbe6d48..e72f42e559 100644 --- a/features/unsupported/USBDevice/USBAudio/USBAudio.h +++ b/features/unsupported/USBDevice/USBAudio/USBAudio.h @@ -152,7 +152,7 @@ public: * */ void attach(void(*fptr)(void)) { - updateVol.attach(fptr); + updateVol = Callback(fptr); } /** attach a handler to Tx Done * @@ -160,7 +160,7 @@ public: * */ void attachTx(void(*fptr)(void)) { - txDone.attach(fptr); + txDone = Callback(fptr); } /** attach a handler to Rx Done * @@ -168,7 +168,7 @@ public: * */ void attachRx(void(*fptr)(void)) { - rxDone.attach(fptr); + rxDone = Callback(fptr); } /** Attach a nonstatic void/void member function to update the volume @@ -179,15 +179,52 @@ public: */ template void attach(T *tptr, void(T::*mptr)(void)) { - updateVol.attach(tptr, mptr); + updateVol = Callback(tptr, mptr); } + /** Attach a nonstatic void/void member function to Tx Done + * + * @param tptr Object pointer + * @param mptr Member function pointer + * + */ template void attachTx(T *tptr, void(T::*mptr)(void)) { - txDone.attach(tptr, mptr); + txDone = Callback(tptr, mptr); } + /** Attach a nonstatic void/void member function to Rx Done + * + * @param tptr Object pointer + * @param mptr Member function pointer + * + */ template void attachRx(T *tptr, void(T::*mptr)(void)) { - rxDone.attach(tptr, mptr); + rxDone = Callback(tptr, mptr); + } + + /** Attach a Callback to update the volume + * + * @param cb Callback to attach + * + */ + void attach(Callback &cb) { + updateVol = cb; + } + /** attach a Callback to Tx Done + * + * @param cb Callback to attach + * + */ + void attachTx(Callback &cb) { + txDone = cb; + } + /** attach a Callback to Rx Done + * + * @param cb Callback to attach + * + */ + void attachRx(Callback &cb) { + rxDone = cb; } diff --git a/features/unsupported/USBDevice/USBSerial/USBSerial.h b/features/unsupported/USBDevice/USBSerial/USBSerial.h index 825b03caf6..69ed61abf5 100644 --- a/features/unsupported/USBDevice/USBSerial/USBSerial.h +++ b/features/unsupported/USBDevice/USBSerial/USBSerial.h @@ -127,7 +127,7 @@ public: template void attach(T* tptr, void (T::*mptr)(void)) { if((mptr != NULL) && (tptr != NULL)) { - rx.attach(tptr, mptr); + rx = Callback(mptr, tptr); } } @@ -138,10 +138,19 @@ public: */ void attach(void (*fptr)(void)) { if(fptr != NULL) { - rx.attach(fptr); + rx = Callback(fptr); } } + /** + * Attach a Callback called when a packet is received + * + * @param cb Callback to attach + */ + void attach(Callback &cb) { + rx = cb; + } + /** * Attach a callback to call when serial's settings are changed. *