Fork of the official USBDevice library
Fork of USBDevice by
USBAudio/USBAudio.h@76:f0fd8d911b24, 2017-04-28 (annotated)
- Committer:
- screamer
- Date:
- Fri Apr 28 17:01:10 2017 +0000
- Branch:
- device-files
- Revision:
- 76:f0fd8d911b24
- Parent:
- 73:8d28a0cb7b43
Changed the layout of USBDevice implementation for various targets to match mbed-os/targets. This also reduces the amount of files being compiled as USBDevice code for other targets is not compiled.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 73:8d28a0cb7b43 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
screamer | 73:8d28a0cb7b43 | 2 | * |
screamer | 73:8d28a0cb7b43 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
screamer | 73:8d28a0cb7b43 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
screamer | 73:8d28a0cb7b43 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
screamer | 73:8d28a0cb7b43 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
screamer | 73:8d28a0cb7b43 | 7 | * Software is furnished to do so, subject to the following conditions: |
screamer | 73:8d28a0cb7b43 | 8 | * |
screamer | 73:8d28a0cb7b43 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
screamer | 73:8d28a0cb7b43 | 10 | * substantial portions of the Software. |
screamer | 73:8d28a0cb7b43 | 11 | * |
screamer | 73:8d28a0cb7b43 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
screamer | 73:8d28a0cb7b43 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
screamer | 73:8d28a0cb7b43 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
screamer | 73:8d28a0cb7b43 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
screamer | 73:8d28a0cb7b43 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
screamer | 73:8d28a0cb7b43 | 17 | */ |
screamer | 73:8d28a0cb7b43 | 18 | |
screamer | 73:8d28a0cb7b43 | 19 | #ifndef USBAudio_H |
screamer | 73:8d28a0cb7b43 | 20 | #define USBAudio_H |
screamer | 73:8d28a0cb7b43 | 21 | |
screamer | 73:8d28a0cb7b43 | 22 | /* These headers are included for child class. */ |
screamer | 73:8d28a0cb7b43 | 23 | #include "USBEndpoints.h" |
screamer | 73:8d28a0cb7b43 | 24 | #include "USBDescriptor.h" |
screamer | 73:8d28a0cb7b43 | 25 | #include "USBDevice_Types.h" |
screamer | 73:8d28a0cb7b43 | 26 | |
screamer | 73:8d28a0cb7b43 | 27 | #include "USBDevice.h" |
screamer | 73:8d28a0cb7b43 | 28 | #include "Callback.h" |
screamer | 73:8d28a0cb7b43 | 29 | |
screamer | 73:8d28a0cb7b43 | 30 | /** |
screamer | 73:8d28a0cb7b43 | 31 | * USBAudio example |
screamer | 73:8d28a0cb7b43 | 32 | * |
screamer | 73:8d28a0cb7b43 | 33 | * @code |
screamer | 73:8d28a0cb7b43 | 34 | * #include "mbed.h" |
screamer | 73:8d28a0cb7b43 | 35 | * #include "USBAudio.h" |
screamer | 73:8d28a0cb7b43 | 36 | * |
screamer | 73:8d28a0cb7b43 | 37 | * Serial pc(USBTX, USBRX); |
screamer | 73:8d28a0cb7b43 | 38 | * |
screamer | 73:8d28a0cb7b43 | 39 | * // frequency: 48 kHz |
screamer | 73:8d28a0cb7b43 | 40 | * #define FREQ 48000 |
screamer | 73:8d28a0cb7b43 | 41 | * |
screamer | 73:8d28a0cb7b43 | 42 | * // 1 channel: mono |
screamer | 73:8d28a0cb7b43 | 43 | * #define NB_CHA 1 |
screamer | 73:8d28a0cb7b43 | 44 | * |
screamer | 73:8d28a0cb7b43 | 45 | * // length of an audio packet: each ms, we receive 48 * 16bits ->48 * 2 bytes. as there is one channel, the length will be 48 * 2 * 1 |
screamer | 73:8d28a0cb7b43 | 46 | * #define AUDIO_LENGTH_PACKET 48 * 2 * 1 |
screamer | 73:8d28a0cb7b43 | 47 | * |
screamer | 73:8d28a0cb7b43 | 48 | * // USBAudio |
screamer | 73:8d28a0cb7b43 | 49 | * USBAudio audio(FREQ, NB_CHA); |
screamer | 73:8d28a0cb7b43 | 50 | * |
screamer | 73:8d28a0cb7b43 | 51 | * int main() { |
screamer | 73:8d28a0cb7b43 | 52 | * int16_t buf[AUDIO_LENGTH_PACKET/2]; |
screamer | 73:8d28a0cb7b43 | 53 | * |
screamer | 73:8d28a0cb7b43 | 54 | * while (1) { |
screamer | 73:8d28a0cb7b43 | 55 | * // read an audio packet |
screamer | 73:8d28a0cb7b43 | 56 | * audio.read((uint8_t *)buf); |
screamer | 73:8d28a0cb7b43 | 57 | * |
screamer | 73:8d28a0cb7b43 | 58 | * |
screamer | 73:8d28a0cb7b43 | 59 | * // print packet received |
screamer | 73:8d28a0cb7b43 | 60 | * pc.printf("recv: "); |
screamer | 73:8d28a0cb7b43 | 61 | * for(int i = 0; i < AUDIO_LENGTH_PACKET/2; i++) { |
screamer | 73:8d28a0cb7b43 | 62 | * pc.printf("%d ", buf[i]); |
screamer | 73:8d28a0cb7b43 | 63 | * } |
screamer | 73:8d28a0cb7b43 | 64 | * pc.printf("\r\n"); |
screamer | 73:8d28a0cb7b43 | 65 | * } |
screamer | 73:8d28a0cb7b43 | 66 | * } |
screamer | 73:8d28a0cb7b43 | 67 | * @endcode |
screamer | 73:8d28a0cb7b43 | 68 | */ |
screamer | 73:8d28a0cb7b43 | 69 | class USBAudio: public USBDevice { |
screamer | 73:8d28a0cb7b43 | 70 | public: |
screamer | 73:8d28a0cb7b43 | 71 | |
screamer | 73:8d28a0cb7b43 | 72 | /** |
screamer | 73:8d28a0cb7b43 | 73 | * Constructor |
screamer | 73:8d28a0cb7b43 | 74 | * |
screamer | 73:8d28a0cb7b43 | 75 | * @param frequency_in frequency in Hz (default: 48000) |
screamer | 73:8d28a0cb7b43 | 76 | * @param channel_nb_in channel number (1 or 2) (default: 1) |
screamer | 73:8d28a0cb7b43 | 77 | * @param frequency_out frequency in Hz (default: 8000) |
screamer | 73:8d28a0cb7b43 | 78 | * @param channel_nb_out_in channel number (1 or 2) (default: 1) |
screamer | 73:8d28a0cb7b43 | 79 | * @param vendor_id Your vendor_id |
screamer | 73:8d28a0cb7b43 | 80 | * @param product_id Your product_id |
screamer | 73:8d28a0cb7b43 | 81 | * @param product_release Your preoduct_release |
screamer | 73:8d28a0cb7b43 | 82 | */ |
screamer | 73:8d28a0cb7b43 | 83 | USBAudio(uint32_t frequency_in = 48000, uint8_t channel_nb_in = 1, uint32_t frequency_out = 8000, uint8_t channel_nb_out = 1, uint16_t vendor_id = 0x7bb8, uint16_t product_id = 0x1111, uint16_t product_release = 0x0100); |
screamer | 73:8d28a0cb7b43 | 84 | |
screamer | 73:8d28a0cb7b43 | 85 | /** |
screamer | 73:8d28a0cb7b43 | 86 | * Get current volume between 0.0 and 1.0 |
screamer | 73:8d28a0cb7b43 | 87 | * |
screamer | 73:8d28a0cb7b43 | 88 | * @returns volume |
screamer | 73:8d28a0cb7b43 | 89 | */ |
screamer | 73:8d28a0cb7b43 | 90 | float getVolume(); |
screamer | 73:8d28a0cb7b43 | 91 | |
screamer | 73:8d28a0cb7b43 | 92 | /** |
screamer | 73:8d28a0cb7b43 | 93 | * Read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Blocking |
screamer | 73:8d28a0cb7b43 | 94 | * |
screamer | 73:8d28a0cb7b43 | 95 | * @param buf pointer on a buffer which will be filled with an audio packet |
screamer | 73:8d28a0cb7b43 | 96 | * |
screamer | 73:8d28a0cb7b43 | 97 | * @returns true if successfull |
screamer | 73:8d28a0cb7b43 | 98 | */ |
screamer | 73:8d28a0cb7b43 | 99 | bool read(uint8_t * buf); |
screamer | 73:8d28a0cb7b43 | 100 | |
screamer | 73:8d28a0cb7b43 | 101 | /** |
screamer | 73:8d28a0cb7b43 | 102 | * Try to read an audio packet. During a frame, only a single reading (you can't write and read an audio packet during the same frame)can be done using this method. Warning: Non Blocking |
screamer | 73:8d28a0cb7b43 | 103 | * |
screamer | 73:8d28a0cb7b43 | 104 | * @param buf pointer on a buffer which will be filled if an audio packet is available |
screamer | 73:8d28a0cb7b43 | 105 | * |
screamer | 73:8d28a0cb7b43 | 106 | * @returns true if successfull |
screamer | 73:8d28a0cb7b43 | 107 | */ |
screamer | 73:8d28a0cb7b43 | 108 | bool readNB(uint8_t * buf); |
screamer | 73:8d28a0cb7b43 | 109 | |
screamer | 73:8d28a0cb7b43 | 110 | /** |
screamer | 73:8d28a0cb7b43 | 111 | * read last received packet if some. |
screamer | 73:8d28a0cb7b43 | 112 | * @param buf pointer on a buffer which will be filled if an audio packet is available |
screamer | 73:8d28a0cb7b43 | 113 | * |
screamer | 73:8d28a0cb7b43 | 114 | * @returns the packet length |
screamer | 73:8d28a0cb7b43 | 115 | */ |
screamer | 73:8d28a0cb7b43 | 116 | uint32_t readSync(uint8_t *buf); |
screamer | 73:8d28a0cb7b43 | 117 | |
screamer | 73:8d28a0cb7b43 | 118 | /** |
screamer | 73:8d28a0cb7b43 | 119 | * 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. |
screamer | 73:8d28a0cb7b43 | 120 | * |
screamer | 73:8d28a0cb7b43 | 121 | * @param buf pointer on the audio packet which will be sent |
screamer | 73:8d28a0cb7b43 | 122 | * @returns true if successful |
screamer | 73:8d28a0cb7b43 | 123 | */ |
screamer | 73:8d28a0cb7b43 | 124 | bool write(uint8_t * buf); |
screamer | 73:8d28a0cb7b43 | 125 | |
screamer | 73:8d28a0cb7b43 | 126 | /** |
screamer | 73:8d28a0cb7b43 | 127 | * Write packet in endpoint fifo. assuming tx fifo is empty |
screamer | 73:8d28a0cb7b43 | 128 | * @param buf pointer on the audio packet which will be sent |
screamer | 73:8d28a0cb7b43 | 129 | */ |
screamer | 73:8d28a0cb7b43 | 130 | void writeSync(uint8_t *buf); |
screamer | 73:8d28a0cb7b43 | 131 | |
screamer | 73:8d28a0cb7b43 | 132 | /** |
screamer | 73:8d28a0cb7b43 | 133 | * Write and read an audio packet at the same time (on the same frame) |
screamer | 73:8d28a0cb7b43 | 134 | * |
screamer | 73:8d28a0cb7b43 | 135 | * @param buf_read pointer on a buffer which will be filled with an audio packet |
screamer | 73:8d28a0cb7b43 | 136 | * @param buf_write pointer on the audio packet which will be sent |
screamer | 73:8d28a0cb7b43 | 137 | * @returns true if successful |
screamer | 73:8d28a0cb7b43 | 138 | */ |
screamer | 73:8d28a0cb7b43 | 139 | bool readWrite(uint8_t * buf_read, uint8_t * buf_write); |
screamer | 73:8d28a0cb7b43 | 140 | |
screamer | 73:8d28a0cb7b43 | 141 | |
screamer | 73:8d28a0cb7b43 | 142 | /** attach a handler to update the volume |
screamer | 73:8d28a0cb7b43 | 143 | * |
screamer | 73:8d28a0cb7b43 | 144 | * @param function Function to attach |
screamer | 73:8d28a0cb7b43 | 145 | * |
screamer | 73:8d28a0cb7b43 | 146 | */ |
screamer | 73:8d28a0cb7b43 | 147 | void attach(void(*fptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 148 | updateVol.attach(fptr); |
screamer | 73:8d28a0cb7b43 | 149 | } |
screamer | 73:8d28a0cb7b43 | 150 | /** attach a handler to Tx Done |
screamer | 73:8d28a0cb7b43 | 151 | * |
screamer | 73:8d28a0cb7b43 | 152 | * @param function Function to attach |
screamer | 73:8d28a0cb7b43 | 153 | * |
screamer | 73:8d28a0cb7b43 | 154 | */ |
screamer | 73:8d28a0cb7b43 | 155 | void attachTx(void(*fptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 156 | txDone.attach(fptr); |
screamer | 73:8d28a0cb7b43 | 157 | } |
screamer | 73:8d28a0cb7b43 | 158 | /** attach a handler to Rx Done |
screamer | 73:8d28a0cb7b43 | 159 | * |
screamer | 73:8d28a0cb7b43 | 160 | * @param function Function to attach |
screamer | 73:8d28a0cb7b43 | 161 | * |
screamer | 73:8d28a0cb7b43 | 162 | */ |
screamer | 73:8d28a0cb7b43 | 163 | void attachRx(void(*fptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 164 | rxDone.attach(fptr); |
screamer | 73:8d28a0cb7b43 | 165 | } |
screamer | 73:8d28a0cb7b43 | 166 | |
screamer | 73:8d28a0cb7b43 | 167 | /** Attach a nonstatic void/void member function to update the volume |
screamer | 73:8d28a0cb7b43 | 168 | * |
screamer | 73:8d28a0cb7b43 | 169 | * @param tptr Object pointer |
screamer | 73:8d28a0cb7b43 | 170 | * @param mptr Member function pointer |
screamer | 73:8d28a0cb7b43 | 171 | * |
screamer | 73:8d28a0cb7b43 | 172 | */ |
screamer | 73:8d28a0cb7b43 | 173 | template<typename T> |
screamer | 73:8d28a0cb7b43 | 174 | void attach(T *tptr, void(T::*mptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 175 | updateVol.attach(tptr, mptr); |
screamer | 73:8d28a0cb7b43 | 176 | } |
screamer | 73:8d28a0cb7b43 | 177 | template<typename T> |
screamer | 73:8d28a0cb7b43 | 178 | void attachTx(T *tptr, void(T::*mptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 179 | txDone.attach(tptr, mptr); |
screamer | 73:8d28a0cb7b43 | 180 | } |
screamer | 73:8d28a0cb7b43 | 181 | template<typename T> |
screamer | 73:8d28a0cb7b43 | 182 | void attachRx(T *tptr, void(T::*mptr)(void)) { |
screamer | 73:8d28a0cb7b43 | 183 | rxDone.attach(tptr, mptr); |
screamer | 73:8d28a0cb7b43 | 184 | } |
screamer | 73:8d28a0cb7b43 | 185 | |
screamer | 73:8d28a0cb7b43 | 186 | |
screamer | 73:8d28a0cb7b43 | 187 | protected: |
screamer | 73:8d28a0cb7b43 | 188 | |
screamer | 73:8d28a0cb7b43 | 189 | /* |
screamer | 73:8d28a0cb7b43 | 190 | * Called by USBDevice layer. Set configuration of the device. |
screamer | 73:8d28a0cb7b43 | 191 | * For instance, you can add all endpoints that you need on this function. |
screamer | 73:8d28a0cb7b43 | 192 | * |
screamer | 73:8d28a0cb7b43 | 193 | * @param configuration Number of the configuration |
screamer | 73:8d28a0cb7b43 | 194 | * @returns true if class handles this request |
screamer | 73:8d28a0cb7b43 | 195 | */ |
screamer | 73:8d28a0cb7b43 | 196 | virtual bool USBCallback_setConfiguration(uint8_t configuration); |
screamer | 73:8d28a0cb7b43 | 197 | |
screamer | 73:8d28a0cb7b43 | 198 | /* |
screamer | 73:8d28a0cb7b43 | 199 | * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context |
screamer | 73:8d28a0cb7b43 | 200 | * This is used to handle extensions to standard requests |
screamer | 73:8d28a0cb7b43 | 201 | * and class specific requests |
screamer | 73:8d28a0cb7b43 | 202 | * |
screamer | 73:8d28a0cb7b43 | 203 | * @returns true if class handles this request |
screamer | 73:8d28a0cb7b43 | 204 | */ |
screamer | 73:8d28a0cb7b43 | 205 | virtual bool USBCallback_request(); |
screamer | 73:8d28a0cb7b43 | 206 | |
screamer | 73:8d28a0cb7b43 | 207 | /* |
screamer | 73:8d28a0cb7b43 | 208 | * Get string product descriptor |
screamer | 73:8d28a0cb7b43 | 209 | * |
screamer | 73:8d28a0cb7b43 | 210 | * @returns pointer to the string product descriptor |
screamer | 73:8d28a0cb7b43 | 211 | */ |
screamer | 73:8d28a0cb7b43 | 212 | virtual uint8_t * stringIproductDesc(); |
screamer | 73:8d28a0cb7b43 | 213 | |
screamer | 73:8d28a0cb7b43 | 214 | /* |
screamer | 73:8d28a0cb7b43 | 215 | * Get string interface descriptor |
screamer | 73:8d28a0cb7b43 | 216 | * |
screamer | 73:8d28a0cb7b43 | 217 | * @returns pointer to the string interface descriptor |
screamer | 73:8d28a0cb7b43 | 218 | */ |
screamer | 73:8d28a0cb7b43 | 219 | virtual uint8_t * stringIinterfaceDesc(); |
screamer | 73:8d28a0cb7b43 | 220 | |
screamer | 73:8d28a0cb7b43 | 221 | /* |
screamer | 73:8d28a0cb7b43 | 222 | * Get configuration descriptor |
screamer | 73:8d28a0cb7b43 | 223 | * |
screamer | 73:8d28a0cb7b43 | 224 | * @returns pointer to the configuration descriptor |
screamer | 73:8d28a0cb7b43 | 225 | */ |
screamer | 73:8d28a0cb7b43 | 226 | virtual uint8_t * configurationDesc(); |
screamer | 73:8d28a0cb7b43 | 227 | |
screamer | 73:8d28a0cb7b43 | 228 | /* |
screamer | 73:8d28a0cb7b43 | 229 | * Called by USBDevice layer. Set interface/alternate of the device. |
screamer | 73:8d28a0cb7b43 | 230 | * |
screamer | 73:8d28a0cb7b43 | 231 | * @param interface Number of the interface to be configured |
screamer | 73:8d28a0cb7b43 | 232 | * @param alternate Number of the alternate to be configured |
screamer | 73:8d28a0cb7b43 | 233 | * @returns true if class handles this request |
screamer | 73:8d28a0cb7b43 | 234 | */ |
screamer | 73:8d28a0cb7b43 | 235 | virtual bool USBCallback_setInterface(uint16_t interface, uint8_t alternate); |
screamer | 73:8d28a0cb7b43 | 236 | |
screamer | 73:8d28a0cb7b43 | 237 | /* |
screamer | 73:8d28a0cb7b43 | 238 | * Called by USBDevice on Endpoint0 request completion |
screamer | 73:8d28a0cb7b43 | 239 | * if the 'notify' flag has been set to true. Warning: Called in ISR context |
screamer | 73:8d28a0cb7b43 | 240 | * |
screamer | 73:8d28a0cb7b43 | 241 | * In this case it is used to indicate that a HID report has |
screamer | 73:8d28a0cb7b43 | 242 | * been received from the host on endpoint 0 |
screamer | 73:8d28a0cb7b43 | 243 | * |
screamer | 73:8d28a0cb7b43 | 244 | * @param buf buffer received on endpoint 0 |
screamer | 73:8d28a0cb7b43 | 245 | * @param length length of this buffer |
screamer | 73:8d28a0cb7b43 | 246 | */ |
screamer | 73:8d28a0cb7b43 | 247 | virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length); |
screamer | 73:8d28a0cb7b43 | 248 | |
screamer | 73:8d28a0cb7b43 | 249 | /* |
screamer | 73:8d28a0cb7b43 | 250 | * Callback called on each Start of Frame event |
screamer | 73:8d28a0cb7b43 | 251 | */ |
screamer | 73:8d28a0cb7b43 | 252 | virtual void SOF(int frameNumber); |
screamer | 73:8d28a0cb7b43 | 253 | |
screamer | 73:8d28a0cb7b43 | 254 | /* |
screamer | 73:8d28a0cb7b43 | 255 | * Callback called when a packet is received |
screamer | 73:8d28a0cb7b43 | 256 | */ |
screamer | 73:8d28a0cb7b43 | 257 | virtual bool EPISO_OUT_callback(); |
screamer | 73:8d28a0cb7b43 | 258 | |
screamer | 73:8d28a0cb7b43 | 259 | /* |
screamer | 73:8d28a0cb7b43 | 260 | * Callback called when a packet has been sent |
screamer | 73:8d28a0cb7b43 | 261 | */ |
screamer | 73:8d28a0cb7b43 | 262 | virtual bool EPISO_IN_callback(); |
screamer | 73:8d28a0cb7b43 | 263 | |
screamer | 73:8d28a0cb7b43 | 264 | private: |
screamer | 73:8d28a0cb7b43 | 265 | |
screamer | 73:8d28a0cb7b43 | 266 | // stream available ? |
screamer | 73:8d28a0cb7b43 | 267 | volatile bool available; |
screamer | 73:8d28a0cb7b43 | 268 | |
screamer | 73:8d28a0cb7b43 | 269 | // interrupt OUT has been received |
screamer | 73:8d28a0cb7b43 | 270 | volatile bool interruptOUT; |
screamer | 73:8d28a0cb7b43 | 271 | |
screamer | 73:8d28a0cb7b43 | 272 | // interrupt IN has been received |
screamer | 73:8d28a0cb7b43 | 273 | volatile bool interruptIN; |
screamer | 73:8d28a0cb7b43 | 274 | |
screamer | 73:8d28a0cb7b43 | 275 | // audio packet has been written |
screamer | 73:8d28a0cb7b43 | 276 | volatile bool writeIN; |
screamer | 73:8d28a0cb7b43 | 277 | |
screamer | 73:8d28a0cb7b43 | 278 | // FREQ |
screamer | 73:8d28a0cb7b43 | 279 | uint32_t FREQ_OUT; |
screamer | 73:8d28a0cb7b43 | 280 | uint32_t FREQ_IN; |
screamer | 73:8d28a0cb7b43 | 281 | |
screamer | 73:8d28a0cb7b43 | 282 | // size of the maximum packet for the isochronous endpoint |
screamer | 73:8d28a0cb7b43 | 283 | uint32_t PACKET_SIZE_ISO_IN; |
screamer | 73:8d28a0cb7b43 | 284 | uint32_t PACKET_SIZE_ISO_OUT; |
screamer | 73:8d28a0cb7b43 | 285 | |
screamer | 73:8d28a0cb7b43 | 286 | // mono, stereo,... |
screamer | 73:8d28a0cb7b43 | 287 | uint8_t channel_nb_in; |
screamer | 73:8d28a0cb7b43 | 288 | uint8_t channel_nb_out; |
screamer | 73:8d28a0cb7b43 | 289 | |
screamer | 73:8d28a0cb7b43 | 290 | // channel config: master, left, right |
screamer | 73:8d28a0cb7b43 | 291 | uint8_t channel_config_in; |
screamer | 73:8d28a0cb7b43 | 292 | uint8_t channel_config_out; |
screamer | 73:8d28a0cb7b43 | 293 | |
screamer | 73:8d28a0cb7b43 | 294 | // mute state |
screamer | 73:8d28a0cb7b43 | 295 | uint8_t mute; |
screamer | 73:8d28a0cb7b43 | 296 | |
screamer | 73:8d28a0cb7b43 | 297 | // Volume Current Value |
screamer | 73:8d28a0cb7b43 | 298 | uint16_t volCur; |
screamer | 73:8d28a0cb7b43 | 299 | |
screamer | 73:8d28a0cb7b43 | 300 | // Volume Minimum Value |
screamer | 73:8d28a0cb7b43 | 301 | uint16_t volMin; |
screamer | 73:8d28a0cb7b43 | 302 | |
screamer | 73:8d28a0cb7b43 | 303 | // Volume Maximum Value |
screamer | 73:8d28a0cb7b43 | 304 | uint16_t volMax; |
screamer | 73:8d28a0cb7b43 | 305 | |
screamer | 73:8d28a0cb7b43 | 306 | // Volume Resolution |
screamer | 73:8d28a0cb7b43 | 307 | uint16_t volRes; |
screamer | 73:8d28a0cb7b43 | 308 | |
screamer | 73:8d28a0cb7b43 | 309 | // Buffer containing one audio packet (to be read) |
screamer | 73:8d28a0cb7b43 | 310 | volatile uint8_t * buf_stream_in; |
screamer | 73:8d28a0cb7b43 | 311 | |
screamer | 73:8d28a0cb7b43 | 312 | // Buffer containing one audio packet (to be written) |
screamer | 73:8d28a0cb7b43 | 313 | volatile uint8_t * buf_stream_out; |
screamer | 73:8d28a0cb7b43 | 314 | |
screamer | 73:8d28a0cb7b43 | 315 | // callback to update volume |
screamer | 73:8d28a0cb7b43 | 316 | Callback<void()> updateVol; |
screamer | 73:8d28a0cb7b43 | 317 | |
screamer | 73:8d28a0cb7b43 | 318 | // callback transmit Done |
screamer | 73:8d28a0cb7b43 | 319 | Callback<void()> txDone; |
screamer | 73:8d28a0cb7b43 | 320 | // callback transmit Done |
screamer | 73:8d28a0cb7b43 | 321 | Callback<void()> rxDone; |
screamer | 73:8d28a0cb7b43 | 322 | |
screamer | 73:8d28a0cb7b43 | 323 | // boolean showing that the SOF handler has been called. Useful for readNB. |
screamer | 73:8d28a0cb7b43 | 324 | volatile bool SOF_handler; |
screamer | 73:8d28a0cb7b43 | 325 | |
screamer | 73:8d28a0cb7b43 | 326 | volatile float volume; |
screamer | 73:8d28a0cb7b43 | 327 | |
screamer | 73:8d28a0cb7b43 | 328 | }; |
screamer | 73:8d28a0cb7b43 | 329 | |
screamer | 73:8d28a0cb7b43 | 330 | #endif |