USBDevice for STM support

Dependents:   Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more

This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).

Revision:
3:d9c7334e2183
Parent:
1:2a3ae13b45ef
Child:
4:50ec00aa4515
--- a/USBAudio/USBAudio.h	Thu Dec 15 17:40:59 2016 +0100
+++ b/USBAudio/USBAudio.h	Wed Feb 15 09:48:15 2017 +0100
@@ -108,6 +108,14 @@
     bool readNB(uint8_t * buf);
 
     /**
+     * read last received packet if some.
+     * @param buf pointer on a buffer which will be filled if an audio packet is available
+     *
+     * @returns the packet length
+     */
+    uint32_t readSync(uint8_t *buf);
+
+    /**
     * Write an audio packet. During a frame, only a single writing (you can't write and read an audio packet during the same frame)can be done using this method.
     *
     * @param buf pointer on the audio packet which will be sent
@@ -116,6 +124,12 @@
     bool write(uint8_t * buf);
 
     /**
+     * Write packet in endpoint fifo. assuming tx fifo is empty
+     * @param buf pointer on the audio packet which will be sent
+     */
+    void writeSync(uint8_t *buf);
+
+    /**
     * Write and read an audio packet at the same time (on the same frame)
     *
     * @param buf_read pointer on a buffer which will be filled with an audio packet
@@ -133,6 +147,22 @@
     void attach(void(*fptr)(void)) {
         updateVol.attach(fptr);
     }
+	/** attach a handler to Tx Done
+     *
+     * @param function Function to attach
+     *
+     */
+    void attachTx(void(*fptr)(void)) {
+        txDone.attach(fptr);
+    }
+    /** attach a handler to Rx Done
+     *
+     * @param function Function to attach
+     *
+     */
+    void attachRx(void(*fptr)(void)) {
+        rxDone.attach(fptr);
+    }
 
     /** Attach a nonstatic void/void member function to update the volume
      *
@@ -144,6 +174,14 @@
     void attach(T *tptr, void(T::*mptr)(void)) {
         updateVol.attach(tptr, mptr);
     }
+	template<typename T>
+	void attachTx(T *tptr, void(T::*mptr)(void)) {
+        txDone.attach(tptr, mptr);
+    }
+    template<typename T>
+	void attachRx(T *tptr, void(T::*mptr)(void)) {
+        rxDone.attach(tptr, mptr);
+    }
 
 
 protected:
@@ -277,6 +315,11 @@
     // callback to update volume
     Callback<void()> updateVol;
 
+    // callback transmit Done
+    Callback<void()> txDone;
+    // callback transmit Done
+    Callback<void()> rxDone;
+
     // boolean showing that the SOF handler has been called. Useful for readNB.
     volatile bool SOF_handler;