Base station firmware

Committer:
Perijah
Date:
Tue May 24 13:16:55 2016 +0000
Revision:
0:ecc3925d3f8c
Base station firmware

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Perijah 0:ecc3925d3f8c 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
Perijah 0:ecc3925d3f8c 2 *
Perijah 0:ecc3925d3f8c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Perijah 0:ecc3925d3f8c 4 * and associated documentation files (the "Software"), to deal in the Software without
Perijah 0:ecc3925d3f8c 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
Perijah 0:ecc3925d3f8c 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Perijah 0:ecc3925d3f8c 7 * Software is furnished to do so, subject to the following conditions:
Perijah 0:ecc3925d3f8c 8 *
Perijah 0:ecc3925d3f8c 9 * The above copyright notice and this permission notice shall be included in all copies or
Perijah 0:ecc3925d3f8c 10 * substantial portions of the Software.
Perijah 0:ecc3925d3f8c 11 *
Perijah 0:ecc3925d3f8c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Perijah 0:ecc3925d3f8c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Perijah 0:ecc3925d3f8c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Perijah 0:ecc3925d3f8c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Perijah 0:ecc3925d3f8c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Perijah 0:ecc3925d3f8c 17 */
Perijah 0:ecc3925d3f8c 18
Perijah 0:ecc3925d3f8c 19 #include "stdint.h"
Perijah 0:ecc3925d3f8c 20 #include "USBAudio.h"
Perijah 0:ecc3925d3f8c 21 #include "USBAudio_Types.h"
Perijah 0:ecc3925d3f8c 22
Perijah 0:ecc3925d3f8c 23
Perijah 0:ecc3925d3f8c 24
Perijah 0:ecc3925d3f8c 25 USBAudio::USBAudio(uint32_t frequency_in, uint8_t channel_nb_in, uint32_t frequency_out, uint8_t channel_nb_out, uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) {
Perijah 0:ecc3925d3f8c 26 mute = 0;
Perijah 0:ecc3925d3f8c 27 volCur = 0x0080;
Perijah 0:ecc3925d3f8c 28 volMin = 0x0000;
Perijah 0:ecc3925d3f8c 29 volMax = 0x0100;
Perijah 0:ecc3925d3f8c 30 volRes = 0x0004;
Perijah 0:ecc3925d3f8c 31 available = false;
Perijah 0:ecc3925d3f8c 32
Perijah 0:ecc3925d3f8c 33 FREQ_IN = frequency_in;
Perijah 0:ecc3925d3f8c 34 FREQ_OUT = frequency_out;
Perijah 0:ecc3925d3f8c 35
Perijah 0:ecc3925d3f8c 36 this->channel_nb_in = channel_nb_in;
Perijah 0:ecc3925d3f8c 37 this->channel_nb_out = channel_nb_out;
Perijah 0:ecc3925d3f8c 38
Perijah 0:ecc3925d3f8c 39 // stereo -> *2, mono -> *1
Perijah 0:ecc3925d3f8c 40 PACKET_SIZE_ISO_IN = (FREQ_IN / 500) * channel_nb_in;
Perijah 0:ecc3925d3f8c 41 PACKET_SIZE_ISO_OUT = (FREQ_OUT / 500) * channel_nb_out;
Perijah 0:ecc3925d3f8c 42
Perijah 0:ecc3925d3f8c 43 // STEREO -> left and right
Perijah 0:ecc3925d3f8c 44 channel_config_in = (channel_nb_in == 1) ? CHANNEL_M : CHANNEL_L + CHANNEL_R;
Perijah 0:ecc3925d3f8c 45 channel_config_out = (channel_nb_out == 1) ? CHANNEL_M : CHANNEL_L + CHANNEL_R;
Perijah 0:ecc3925d3f8c 46
Perijah 0:ecc3925d3f8c 47 SOF_handler = false;
Perijah 0:ecc3925d3f8c 48
Perijah 0:ecc3925d3f8c 49 buf_stream_out = NULL;
Perijah 0:ecc3925d3f8c 50 buf_stream_in = NULL;
Perijah 0:ecc3925d3f8c 51
Perijah 0:ecc3925d3f8c 52 interruptOUT = false;
Perijah 0:ecc3925d3f8c 53 writeIN = false;
Perijah 0:ecc3925d3f8c 54 interruptIN = false;
Perijah 0:ecc3925d3f8c 55 available = false;
Perijah 0:ecc3925d3f8c 56
Perijah 0:ecc3925d3f8c 57 volume = 0;
Perijah 0:ecc3925d3f8c 58
Perijah 0:ecc3925d3f8c 59 // connect the device
Perijah 0:ecc3925d3f8c 60 USBDevice::connect();
Perijah 0:ecc3925d3f8c 61 }
Perijah 0:ecc3925d3f8c 62
Perijah 0:ecc3925d3f8c 63 bool USBAudio::read(uint8_t * buf) {
Perijah 0:ecc3925d3f8c 64 buf_stream_in = buf;
Perijah 0:ecc3925d3f8c 65 SOF_handler = false;
Perijah 0:ecc3925d3f8c 66 while (!available || !SOF_handler);
Perijah 0:ecc3925d3f8c 67 available = false;
Perijah 0:ecc3925d3f8c 68 return true;
Perijah 0:ecc3925d3f8c 69 }
Perijah 0:ecc3925d3f8c 70
Perijah 0:ecc3925d3f8c 71 bool USBAudio::readNB(uint8_t * buf) {
Perijah 0:ecc3925d3f8c 72 buf_stream_in = buf;
Perijah 0:ecc3925d3f8c 73 SOF_handler = false;
Perijah 0:ecc3925d3f8c 74 while (!SOF_handler);
Perijah 0:ecc3925d3f8c 75 if (available) {
Perijah 0:ecc3925d3f8c 76 available = false;
Perijah 0:ecc3925d3f8c 77 buf_stream_in = NULL;
Perijah 0:ecc3925d3f8c 78 return true;
Perijah 0:ecc3925d3f8c 79 }
Perijah 0:ecc3925d3f8c 80 return false;
Perijah 0:ecc3925d3f8c 81 }
Perijah 0:ecc3925d3f8c 82
Perijah 0:ecc3925d3f8c 83 bool USBAudio::readWrite(uint8_t * buf_read, uint8_t * buf_write) {
Perijah 0:ecc3925d3f8c 84 buf_stream_in = buf_read;
Perijah 0:ecc3925d3f8c 85 SOF_handler = false;
Perijah 0:ecc3925d3f8c 86 writeIN = false;
Perijah 0:ecc3925d3f8c 87 if (interruptIN) {
Perijah 0:ecc3925d3f8c 88 USBDevice::writeNB(EP3IN, buf_write, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
Perijah 0:ecc3925d3f8c 89 } else {
Perijah 0:ecc3925d3f8c 90 buf_stream_out = buf_write;
Perijah 0:ecc3925d3f8c 91 }
Perijah 0:ecc3925d3f8c 92 while (!available);
Perijah 0:ecc3925d3f8c 93 if (interruptIN) {
Perijah 0:ecc3925d3f8c 94 while (!writeIN);
Perijah 0:ecc3925d3f8c 95 }
Perijah 0:ecc3925d3f8c 96 while (!SOF_handler);
Perijah 0:ecc3925d3f8c 97 return true;
Perijah 0:ecc3925d3f8c 98 }
Perijah 0:ecc3925d3f8c 99
Perijah 0:ecc3925d3f8c 100
Perijah 0:ecc3925d3f8c 101 bool USBAudio::write(uint8_t * buf) {
Perijah 0:ecc3925d3f8c 102 writeIN = false;
Perijah 0:ecc3925d3f8c 103 SOF_handler = false;
Perijah 0:ecc3925d3f8c 104 if (interruptIN) {
Perijah 0:ecc3925d3f8c 105 USBDevice::writeNB(EP3IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
Perijah 0:ecc3925d3f8c 106 } else {
Perijah 0:ecc3925d3f8c 107 buf_stream_out = buf;
Perijah 0:ecc3925d3f8c 108 }
Perijah 0:ecc3925d3f8c 109 while (!SOF_handler);
Perijah 0:ecc3925d3f8c 110 if (interruptIN) {
Perijah 0:ecc3925d3f8c 111 while (!writeIN);
Perijah 0:ecc3925d3f8c 112 }
Perijah 0:ecc3925d3f8c 113 return true;
Perijah 0:ecc3925d3f8c 114 }
Perijah 0:ecc3925d3f8c 115
Perijah 0:ecc3925d3f8c 116
Perijah 0:ecc3925d3f8c 117 float USBAudio::getVolume() {
Perijah 0:ecc3925d3f8c 118 return (mute) ? 0.0 : volume;
Perijah 0:ecc3925d3f8c 119 }
Perijah 0:ecc3925d3f8c 120
Perijah 0:ecc3925d3f8c 121
Perijah 0:ecc3925d3f8c 122 bool USBAudio::EP3_OUT_callback() {
Perijah 0:ecc3925d3f8c 123 uint32_t size = 0;
Perijah 0:ecc3925d3f8c 124 interruptOUT = true;
Perijah 0:ecc3925d3f8c 125 if (buf_stream_in != NULL) {
Perijah 0:ecc3925d3f8c 126 readEP(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN);
Perijah 0:ecc3925d3f8c 127 available = true;
Perijah 0:ecc3925d3f8c 128 buf_stream_in = NULL;
Perijah 0:ecc3925d3f8c 129 }
Perijah 0:ecc3925d3f8c 130 readStart(EP3OUT, PACKET_SIZE_ISO_IN);
Perijah 0:ecc3925d3f8c 131 return false;
Perijah 0:ecc3925d3f8c 132 }
Perijah 0:ecc3925d3f8c 133
Perijah 0:ecc3925d3f8c 134
Perijah 0:ecc3925d3f8c 135 bool USBAudio::EP3_IN_callback() {
Perijah 0:ecc3925d3f8c 136 interruptIN = true;
Perijah 0:ecc3925d3f8c 137 writeIN = true;
Perijah 0:ecc3925d3f8c 138 return true;
Perijah 0:ecc3925d3f8c 139 }
Perijah 0:ecc3925d3f8c 140
Perijah 0:ecc3925d3f8c 141
Perijah 0:ecc3925d3f8c 142
Perijah 0:ecc3925d3f8c 143 // Called in ISR context on each start of frame
Perijah 0:ecc3925d3f8c 144 void USBAudio::SOF(int frameNumber) {
Perijah 0:ecc3925d3f8c 145 uint32_t size = 0;
Perijah 0:ecc3925d3f8c 146
Perijah 0:ecc3925d3f8c 147 if (!interruptOUT) {
Perijah 0:ecc3925d3f8c 148 // read the isochronous endpoint
Perijah 0:ecc3925d3f8c 149 if (buf_stream_in != NULL) {
Perijah 0:ecc3925d3f8c 150 if (USBDevice::readEP_NB(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN)) {
Perijah 0:ecc3925d3f8c 151 if (size) {
Perijah 0:ecc3925d3f8c 152 available = true;
Perijah 0:ecc3925d3f8c 153 readStart(EP3OUT, PACKET_SIZE_ISO_IN);
Perijah 0:ecc3925d3f8c 154 buf_stream_in = NULL;
Perijah 0:ecc3925d3f8c 155 }
Perijah 0:ecc3925d3f8c 156 }
Perijah 0:ecc3925d3f8c 157 }
Perijah 0:ecc3925d3f8c 158 }
Perijah 0:ecc3925d3f8c 159
Perijah 0:ecc3925d3f8c 160 if (!interruptIN) {
Perijah 0:ecc3925d3f8c 161 // write if needed
Perijah 0:ecc3925d3f8c 162 if (buf_stream_out != NULL) {
Perijah 0:ecc3925d3f8c 163 USBDevice::writeNB(EP3IN, (uint8_t *)buf_stream_out, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
Perijah 0:ecc3925d3f8c 164 buf_stream_out = NULL;
Perijah 0:ecc3925d3f8c 165 }
Perijah 0:ecc3925d3f8c 166 }
Perijah 0:ecc3925d3f8c 167
Perijah 0:ecc3925d3f8c 168 SOF_handler = true;
Perijah 0:ecc3925d3f8c 169 }
Perijah 0:ecc3925d3f8c 170
Perijah 0:ecc3925d3f8c 171
Perijah 0:ecc3925d3f8c 172 // Called in ISR context
Perijah 0:ecc3925d3f8c 173 // Set configuration. Return false if the configuration is not supported.
Perijah 0:ecc3925d3f8c 174 bool USBAudio::USBCallback_setConfiguration(uint8_t configuration) {
Perijah 0:ecc3925d3f8c 175 if (configuration != DEFAULT_CONFIGURATION) {
Perijah 0:ecc3925d3f8c 176 return false;
Perijah 0:ecc3925d3f8c 177 }
Perijah 0:ecc3925d3f8c 178
Perijah 0:ecc3925d3f8c 179 // Configure isochronous endpoint
Perijah 0:ecc3925d3f8c 180 realiseEndpoint(EP3OUT, PACKET_SIZE_ISO_IN, ISOCHRONOUS);
Perijah 0:ecc3925d3f8c 181 realiseEndpoint(EP3IN, PACKET_SIZE_ISO_OUT, ISOCHRONOUS);
Perijah 0:ecc3925d3f8c 182
Perijah 0:ecc3925d3f8c 183 // activate readings on this endpoint
Perijah 0:ecc3925d3f8c 184 readStart(EP3OUT, PACKET_SIZE_ISO_IN);
Perijah 0:ecc3925d3f8c 185 return true;
Perijah 0:ecc3925d3f8c 186 }
Perijah 0:ecc3925d3f8c 187
Perijah 0:ecc3925d3f8c 188
Perijah 0:ecc3925d3f8c 189 // Called in ISR context
Perijah 0:ecc3925d3f8c 190 // Set alternate setting. Return false if the alternate setting is not supported
Perijah 0:ecc3925d3f8c 191 bool USBAudio::USBCallback_setInterface(uint16_t interface, uint8_t alternate) {
Perijah 0:ecc3925d3f8c 192 if (interface == 0 && alternate == 0) {
Perijah 0:ecc3925d3f8c 193 return true;
Perijah 0:ecc3925d3f8c 194 }
Perijah 0:ecc3925d3f8c 195 if (interface == 1 && (alternate == 0 || alternate == 1)) {
Perijah 0:ecc3925d3f8c 196 return true;
Perijah 0:ecc3925d3f8c 197 }
Perijah 0:ecc3925d3f8c 198 if (interface == 2 && (alternate == 0 || alternate == 1)) {
Perijah 0:ecc3925d3f8c 199 return true;
Perijah 0:ecc3925d3f8c 200 }
Perijah 0:ecc3925d3f8c 201 return false;
Perijah 0:ecc3925d3f8c 202 }
Perijah 0:ecc3925d3f8c 203
Perijah 0:ecc3925d3f8c 204
Perijah 0:ecc3925d3f8c 205
Perijah 0:ecc3925d3f8c 206 // Called in ISR context
Perijah 0:ecc3925d3f8c 207 // Called by USBDevice on Endpoint0 request
Perijah 0:ecc3925d3f8c 208 // This is used to handle extensions to standard requests and class specific requests.
Perijah 0:ecc3925d3f8c 209 // Return true if class handles this request
Perijah 0:ecc3925d3f8c 210 bool USBAudio::USBCallback_request() {
Perijah 0:ecc3925d3f8c 211 bool success = false;
Perijah 0:ecc3925d3f8c 212 CONTROL_TRANSFER * transfer = getTransferPtr();
Perijah 0:ecc3925d3f8c 213
Perijah 0:ecc3925d3f8c 214 // Process class-specific requests
Perijah 0:ecc3925d3f8c 215 if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
Perijah 0:ecc3925d3f8c 216
Perijah 0:ecc3925d3f8c 217 // Feature Unit: Interface = 0, ID = 2
Perijah 0:ecc3925d3f8c 218 if (transfer->setup.wIndex == 0x0200) {
Perijah 0:ecc3925d3f8c 219
Perijah 0:ecc3925d3f8c 220 // Master Channel
Perijah 0:ecc3925d3f8c 221 if ((transfer->setup.wValue & 0xff) == 0) {
Perijah 0:ecc3925d3f8c 222
Perijah 0:ecc3925d3f8c 223 switch (transfer->setup.wValue >> 8) {
Perijah 0:ecc3925d3f8c 224 case MUTE_CONTROL:
Perijah 0:ecc3925d3f8c 225 switch (transfer->setup.bRequest) {
Perijah 0:ecc3925d3f8c 226 case REQUEST_GET_CUR:
Perijah 0:ecc3925d3f8c 227 transfer->remaining = 1;
Perijah 0:ecc3925d3f8c 228 transfer->ptr = &mute;
Perijah 0:ecc3925d3f8c 229 transfer->direction = DEVICE_TO_HOST;
Perijah 0:ecc3925d3f8c 230 success = true;
Perijah 0:ecc3925d3f8c 231 break;
Perijah 0:ecc3925d3f8c 232
Perijah 0:ecc3925d3f8c 233 case REQUEST_SET_CUR:
Perijah 0:ecc3925d3f8c 234 transfer->remaining = 1;
Perijah 0:ecc3925d3f8c 235 transfer->notify = true;
Perijah 0:ecc3925d3f8c 236 transfer->direction = HOST_TO_DEVICE;
Perijah 0:ecc3925d3f8c 237 success = true;
Perijah 0:ecc3925d3f8c 238 break;
Perijah 0:ecc3925d3f8c 239 default:
Perijah 0:ecc3925d3f8c 240 break;
Perijah 0:ecc3925d3f8c 241 }
Perijah 0:ecc3925d3f8c 242 break;
Perijah 0:ecc3925d3f8c 243 case VOLUME_CONTROL:
Perijah 0:ecc3925d3f8c 244 switch (transfer->setup.bRequest) {
Perijah 0:ecc3925d3f8c 245 case REQUEST_GET_CUR:
Perijah 0:ecc3925d3f8c 246 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 247 transfer->ptr = (uint8_t *)&volCur;
Perijah 0:ecc3925d3f8c 248 transfer->direction = DEVICE_TO_HOST;
Perijah 0:ecc3925d3f8c 249 success = true;
Perijah 0:ecc3925d3f8c 250 break;
Perijah 0:ecc3925d3f8c 251 case REQUEST_GET_MIN:
Perijah 0:ecc3925d3f8c 252 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 253 transfer->ptr = (uint8_t *)&volMin;
Perijah 0:ecc3925d3f8c 254 transfer->direction = DEVICE_TO_HOST;
Perijah 0:ecc3925d3f8c 255 success = true;
Perijah 0:ecc3925d3f8c 256 break;
Perijah 0:ecc3925d3f8c 257 case REQUEST_GET_MAX:
Perijah 0:ecc3925d3f8c 258 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 259 transfer->ptr = (uint8_t *)&volMax;
Perijah 0:ecc3925d3f8c 260 transfer->direction = DEVICE_TO_HOST;
Perijah 0:ecc3925d3f8c 261 success = true;
Perijah 0:ecc3925d3f8c 262 break;
Perijah 0:ecc3925d3f8c 263 case REQUEST_GET_RES:
Perijah 0:ecc3925d3f8c 264 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 265 transfer->ptr = (uint8_t *)&volRes;
Perijah 0:ecc3925d3f8c 266 transfer->direction = DEVICE_TO_HOST;
Perijah 0:ecc3925d3f8c 267 success = true;
Perijah 0:ecc3925d3f8c 268 break;
Perijah 0:ecc3925d3f8c 269
Perijah 0:ecc3925d3f8c 270 case REQUEST_SET_CUR:
Perijah 0:ecc3925d3f8c 271 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 272 transfer->notify = true;
Perijah 0:ecc3925d3f8c 273 transfer->direction = HOST_TO_DEVICE;
Perijah 0:ecc3925d3f8c 274 success = true;
Perijah 0:ecc3925d3f8c 275 break;
Perijah 0:ecc3925d3f8c 276 case REQUEST_SET_MIN:
Perijah 0:ecc3925d3f8c 277 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 278 transfer->notify = true;
Perijah 0:ecc3925d3f8c 279 transfer->direction = HOST_TO_DEVICE;
Perijah 0:ecc3925d3f8c 280 success = true;
Perijah 0:ecc3925d3f8c 281 break;
Perijah 0:ecc3925d3f8c 282 case REQUEST_SET_MAX:
Perijah 0:ecc3925d3f8c 283 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 284 transfer->notify = true;
Perijah 0:ecc3925d3f8c 285 transfer->direction = HOST_TO_DEVICE;
Perijah 0:ecc3925d3f8c 286 success = true;
Perijah 0:ecc3925d3f8c 287 break;
Perijah 0:ecc3925d3f8c 288 case REQUEST_SET_RES:
Perijah 0:ecc3925d3f8c 289 transfer->remaining = 2;
Perijah 0:ecc3925d3f8c 290 transfer->notify = true;
Perijah 0:ecc3925d3f8c 291 transfer->direction = HOST_TO_DEVICE;
Perijah 0:ecc3925d3f8c 292 success = true;
Perijah 0:ecc3925d3f8c 293 break;
Perijah 0:ecc3925d3f8c 294 }
Perijah 0:ecc3925d3f8c 295 break;
Perijah 0:ecc3925d3f8c 296 default:
Perijah 0:ecc3925d3f8c 297 break;
Perijah 0:ecc3925d3f8c 298 }
Perijah 0:ecc3925d3f8c 299 }
Perijah 0:ecc3925d3f8c 300 }
Perijah 0:ecc3925d3f8c 301 }
Perijah 0:ecc3925d3f8c 302 return success;
Perijah 0:ecc3925d3f8c 303 }
Perijah 0:ecc3925d3f8c 304
Perijah 0:ecc3925d3f8c 305
Perijah 0:ecc3925d3f8c 306 // Called in ISR context when a data OUT stage has been performed
Perijah 0:ecc3925d3f8c 307 void USBAudio::USBCallback_requestCompleted(uint8_t * buf, uint32_t length) {
Perijah 0:ecc3925d3f8c 308 if ((length == 1) || (length == 2)) {
Perijah 0:ecc3925d3f8c 309 uint16_t data = (length == 1) ? *buf : *((uint16_t *)buf);
Perijah 0:ecc3925d3f8c 310 CONTROL_TRANSFER * transfer = getTransferPtr();
Perijah 0:ecc3925d3f8c 311 switch (transfer->setup.wValue >> 8) {
Perijah 0:ecc3925d3f8c 312 case MUTE_CONTROL:
Perijah 0:ecc3925d3f8c 313 switch (transfer->setup.bRequest) {
Perijah 0:ecc3925d3f8c 314 case REQUEST_SET_CUR:
Perijah 0:ecc3925d3f8c 315 mute = data & 0xff;
Perijah 0:ecc3925d3f8c 316 updateVol.call();
Perijah 0:ecc3925d3f8c 317 break;
Perijah 0:ecc3925d3f8c 318 default:
Perijah 0:ecc3925d3f8c 319 break;
Perijah 0:ecc3925d3f8c 320 }
Perijah 0:ecc3925d3f8c 321 break;
Perijah 0:ecc3925d3f8c 322 case VOLUME_CONTROL:
Perijah 0:ecc3925d3f8c 323 switch (transfer->setup.bRequest) {
Perijah 0:ecc3925d3f8c 324 case REQUEST_SET_CUR:
Perijah 0:ecc3925d3f8c 325 volCur = data;
Perijah 0:ecc3925d3f8c 326 volume = (float)volCur/(float)volMax;
Perijah 0:ecc3925d3f8c 327 updateVol.call();
Perijah 0:ecc3925d3f8c 328 break;
Perijah 0:ecc3925d3f8c 329 default:
Perijah 0:ecc3925d3f8c 330 break;
Perijah 0:ecc3925d3f8c 331 }
Perijah 0:ecc3925d3f8c 332 break;
Perijah 0:ecc3925d3f8c 333 default:
Perijah 0:ecc3925d3f8c 334 break;
Perijah 0:ecc3925d3f8c 335 }
Perijah 0:ecc3925d3f8c 336 }
Perijah 0:ecc3925d3f8c 337 }
Perijah 0:ecc3925d3f8c 338
Perijah 0:ecc3925d3f8c 339
Perijah 0:ecc3925d3f8c 340
Perijah 0:ecc3925d3f8c 341 #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 342 + (5 * INTERFACE_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 343 + (1 * CONTROL_INTERFACE_DESCRIPTOR_LENGTH + 1) \
Perijah 0:ecc3925d3f8c 344 + (2 * INPUT_TERMINAL_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 345 + (1 * FEATURE_UNIT_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 346 + (2 * OUTPUT_TERMINAL_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 347 + (2 * STREAMING_INTERFACE_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 348 + (2 * FORMAT_TYPE_I_DESCRIPTOR_LENGTH) \
Perijah 0:ecc3925d3f8c 349 + (2 * (ENDPOINT_DESCRIPTOR_LENGTH + 2)) \
Perijah 0:ecc3925d3f8c 350 + (2 * STREAMING_ENDPOINT_DESCRIPTOR_LENGTH) )
Perijah 0:ecc3925d3f8c 351
Perijah 0:ecc3925d3f8c 352 #define TOTAL_CONTROL_INTF_LENGTH (CONTROL_INTERFACE_DESCRIPTOR_LENGTH + 1 + \
Perijah 0:ecc3925d3f8c 353 2*INPUT_TERMINAL_DESCRIPTOR_LENGTH + \
Perijah 0:ecc3925d3f8c 354 FEATURE_UNIT_DESCRIPTOR_LENGTH + \
Perijah 0:ecc3925d3f8c 355 2*OUTPUT_TERMINAL_DESCRIPTOR_LENGTH)
Perijah 0:ecc3925d3f8c 356
Perijah 0:ecc3925d3f8c 357 uint8_t * USBAudio::configurationDesc() {
Perijah 0:ecc3925d3f8c 358 static uint8_t configDescriptor[] = {
Perijah 0:ecc3925d3f8c 359 // Configuration 1
Perijah 0:ecc3925d3f8c 360 CONFIGURATION_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 361 CONFIGURATION_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 362 LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB)
Perijah 0:ecc3925d3f8c 363 MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB)
Perijah 0:ecc3925d3f8c 364 0x03, // bNumInterfaces
Perijah 0:ecc3925d3f8c 365 DEFAULT_CONFIGURATION, // bConfigurationValue
Perijah 0:ecc3925d3f8c 366 0x00, // iConfiguration
Perijah 0:ecc3925d3f8c 367 0x80, // bmAttributes
Perijah 0:ecc3925d3f8c 368 50, // bMaxPower
Perijah 0:ecc3925d3f8c 369
Perijah 0:ecc3925d3f8c 370 // Interface 0, Alternate Setting 0, Audio Control
Perijah 0:ecc3925d3f8c 371 INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 372 INTERFACE_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 373 0x00, // bInterfaceNumber
Perijah 0:ecc3925d3f8c 374 0x00, // bAlternateSetting
Perijah 0:ecc3925d3f8c 375 0x00, // bNumEndpoints
Perijah 0:ecc3925d3f8c 376 AUDIO_CLASS, // bInterfaceClass
Perijah 0:ecc3925d3f8c 377 SUBCLASS_AUDIOCONTROL, // bInterfaceSubClass
Perijah 0:ecc3925d3f8c 378 0x00, // bInterfaceProtocol
Perijah 0:ecc3925d3f8c 379 0x00, // iInterface
Perijah 0:ecc3925d3f8c 380
Perijah 0:ecc3925d3f8c 381
Perijah 0:ecc3925d3f8c 382 // Audio Control Interface
Perijah 0:ecc3925d3f8c 383 CONTROL_INTERFACE_DESCRIPTOR_LENGTH + 1,// bLength
Perijah 0:ecc3925d3f8c 384 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 385 CONTROL_HEADER, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 386 LSB(0x0100), // bcdADC (LSB)
Perijah 0:ecc3925d3f8c 387 MSB(0x0100), // bcdADC (MSB)
Perijah 0:ecc3925d3f8c 388 LSB(TOTAL_CONTROL_INTF_LENGTH), // wTotalLength
Perijah 0:ecc3925d3f8c 389 MSB(TOTAL_CONTROL_INTF_LENGTH), // wTotalLength
Perijah 0:ecc3925d3f8c 390 0x02, // bInCollection
Perijah 0:ecc3925d3f8c 391 0x01, // baInterfaceNr
Perijah 0:ecc3925d3f8c 392 0x02, // baInterfaceNr
Perijah 0:ecc3925d3f8c 393
Perijah 0:ecc3925d3f8c 394 // Audio Input Terminal (Speaker)
Perijah 0:ecc3925d3f8c 395 INPUT_TERMINAL_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 396 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 397 CONTROL_INPUT_TERMINAL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 398 0x01, // bTerminalID
Perijah 0:ecc3925d3f8c 399 LSB(TERMINAL_USB_STREAMING), // wTerminalType
Perijah 0:ecc3925d3f8c 400 MSB(TERMINAL_USB_STREAMING), // wTerminalType
Perijah 0:ecc3925d3f8c 401 0x00, // bAssocTerminal
Perijah 0:ecc3925d3f8c 402 channel_nb_in, // bNrChannels
Perijah 0:ecc3925d3f8c 403 LSB(channel_config_in), // wChannelConfig
Perijah 0:ecc3925d3f8c 404 MSB(channel_config_in), // wChannelConfig
Perijah 0:ecc3925d3f8c 405 0x00, // iChannelNames
Perijah 0:ecc3925d3f8c 406 0x00, // iTerminal
Perijah 0:ecc3925d3f8c 407
Perijah 0:ecc3925d3f8c 408 // Audio Feature Unit (Speaker)
Perijah 0:ecc3925d3f8c 409 FEATURE_UNIT_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 410 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 411 CONTROL_FEATURE_UNIT, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 412 0x02, // bUnitID
Perijah 0:ecc3925d3f8c 413 0x01, // bSourceID
Perijah 0:ecc3925d3f8c 414 0x01, // bControlSize
Perijah 0:ecc3925d3f8c 415 CONTROL_MUTE |
Perijah 0:ecc3925d3f8c 416 CONTROL_VOLUME, // bmaControls(0)
Perijah 0:ecc3925d3f8c 417 0x00, // bmaControls(1)
Perijah 0:ecc3925d3f8c 418 0x00, // iTerminal
Perijah 0:ecc3925d3f8c 419
Perijah 0:ecc3925d3f8c 420 // Audio Output Terminal (Speaker)
Perijah 0:ecc3925d3f8c 421 OUTPUT_TERMINAL_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 422 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 423 CONTROL_OUTPUT_TERMINAL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 424 0x03, // bTerminalID
Perijah 0:ecc3925d3f8c 425 LSB(TERMINAL_SPEAKER), // wTerminalType
Perijah 0:ecc3925d3f8c 426 MSB(TERMINAL_SPEAKER), // wTerminalType
Perijah 0:ecc3925d3f8c 427 0x00, // bAssocTerminal
Perijah 0:ecc3925d3f8c 428 0x02, // bSourceID
Perijah 0:ecc3925d3f8c 429 0x00, // iTerminal
Perijah 0:ecc3925d3f8c 430
Perijah 0:ecc3925d3f8c 431
Perijah 0:ecc3925d3f8c 432 // Audio Input Terminal (Microphone)
Perijah 0:ecc3925d3f8c 433 INPUT_TERMINAL_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 434 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 435 CONTROL_INPUT_TERMINAL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 436 0x04, // bTerminalID
Perijah 0:ecc3925d3f8c 437 LSB(TERMINAL_MICROPHONE), // wTerminalType
Perijah 0:ecc3925d3f8c 438 MSB(TERMINAL_MICROPHONE), // wTerminalType
Perijah 0:ecc3925d3f8c 439 0x00, // bAssocTerminal
Perijah 0:ecc3925d3f8c 440 channel_nb_out, // bNrChannels
Perijah 0:ecc3925d3f8c 441 LSB(channel_config_out), // wChannelConfig
Perijah 0:ecc3925d3f8c 442 MSB(channel_config_out), // wChannelConfig
Perijah 0:ecc3925d3f8c 443 0x00, // iChannelNames
Perijah 0:ecc3925d3f8c 444 0x00, // iTerminal
Perijah 0:ecc3925d3f8c 445
Perijah 0:ecc3925d3f8c 446 // Audio Output Terminal (Microphone)
Perijah 0:ecc3925d3f8c 447 OUTPUT_TERMINAL_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 448 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 449 CONTROL_OUTPUT_TERMINAL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 450 0x05, // bTerminalID
Perijah 0:ecc3925d3f8c 451 LSB(TERMINAL_USB_STREAMING), // wTerminalType
Perijah 0:ecc3925d3f8c 452 MSB(TERMINAL_USB_STREAMING), // wTerminalType
Perijah 0:ecc3925d3f8c 453 0x00, // bAssocTerminal
Perijah 0:ecc3925d3f8c 454 0x04, // bSourceID
Perijah 0:ecc3925d3f8c 455 0x00, // iTerminal
Perijah 0:ecc3925d3f8c 456
Perijah 0:ecc3925d3f8c 457
Perijah 0:ecc3925d3f8c 458
Perijah 0:ecc3925d3f8c 459
Perijah 0:ecc3925d3f8c 460
Perijah 0:ecc3925d3f8c 461
Perijah 0:ecc3925d3f8c 462 // Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith
Perijah 0:ecc3925d3f8c 463 INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 464 INTERFACE_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 465 0x01, // bInterfaceNumber
Perijah 0:ecc3925d3f8c 466 0x00, // bAlternateSetting
Perijah 0:ecc3925d3f8c 467 0x00, // bNumEndpoints
Perijah 0:ecc3925d3f8c 468 AUDIO_CLASS, // bInterfaceClass
Perijah 0:ecc3925d3f8c 469 SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
Perijah 0:ecc3925d3f8c 470 0x00, // bInterfaceProtocol
Perijah 0:ecc3925d3f8c 471 0x00, // iInterface
Perijah 0:ecc3925d3f8c 472
Perijah 0:ecc3925d3f8c 473 // Interface 1, Alternate Setting 1, Audio Streaming - Operational
Perijah 0:ecc3925d3f8c 474 INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 475 INTERFACE_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 476 0x01, // bInterfaceNumber
Perijah 0:ecc3925d3f8c 477 0x01, // bAlternateSetting
Perijah 0:ecc3925d3f8c 478 0x01, // bNumEndpoints
Perijah 0:ecc3925d3f8c 479 AUDIO_CLASS, // bInterfaceClass
Perijah 0:ecc3925d3f8c 480 SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
Perijah 0:ecc3925d3f8c 481 0x00, // bInterfaceProtocol
Perijah 0:ecc3925d3f8c 482 0x00, // iInterface
Perijah 0:ecc3925d3f8c 483
Perijah 0:ecc3925d3f8c 484 // Audio Streaming Interface
Perijah 0:ecc3925d3f8c 485 STREAMING_INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 486 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 487 STREAMING_GENERAL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 488 0x01, // bTerminalLink
Perijah 0:ecc3925d3f8c 489 0x00, // bDelay
Perijah 0:ecc3925d3f8c 490 LSB(FORMAT_PCM), // wFormatTag
Perijah 0:ecc3925d3f8c 491 MSB(FORMAT_PCM), // wFormatTag
Perijah 0:ecc3925d3f8c 492
Perijah 0:ecc3925d3f8c 493 // Audio Type I Format
Perijah 0:ecc3925d3f8c 494 FORMAT_TYPE_I_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 495 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 496 STREAMING_FORMAT_TYPE, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 497 FORMAT_TYPE_I, // bFormatType
Perijah 0:ecc3925d3f8c 498 channel_nb_in, // bNrChannels
Perijah 0:ecc3925d3f8c 499 0x02, // bSubFrameSize
Perijah 0:ecc3925d3f8c 500 16, // bBitResolution
Perijah 0:ecc3925d3f8c 501 0x01, // bSamFreqType
Perijah 0:ecc3925d3f8c 502 LSB(FREQ_IN), // tSamFreq
Perijah 0:ecc3925d3f8c 503 (FREQ_IN >> 8) & 0xff, // tSamFreq
Perijah 0:ecc3925d3f8c 504 (FREQ_IN >> 16) & 0xff, // tSamFreq
Perijah 0:ecc3925d3f8c 505
Perijah 0:ecc3925d3f8c 506 // Endpoint - Standard Descriptor
Perijah 0:ecc3925d3f8c 507 ENDPOINT_DESCRIPTOR_LENGTH + 2, // bLength
Perijah 0:ecc3925d3f8c 508 ENDPOINT_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 509 PHY_TO_DESC(EPISO_OUT), // bEndpointAddress
Perijah 0:ecc3925d3f8c 510 E_ISOCHRONOUS, // bmAttributes
Perijah 0:ecc3925d3f8c 511 LSB(PACKET_SIZE_ISO_IN), // wMaxPacketSize
Perijah 0:ecc3925d3f8c 512 MSB(PACKET_SIZE_ISO_IN), // wMaxPacketSize
Perijah 0:ecc3925d3f8c 513 0x01, // bInterval
Perijah 0:ecc3925d3f8c 514 0x00, // bRefresh
Perijah 0:ecc3925d3f8c 515 0x00, // bSynchAddress
Perijah 0:ecc3925d3f8c 516
Perijah 0:ecc3925d3f8c 517 // Endpoint - Audio Streaming
Perijah 0:ecc3925d3f8c 518 STREAMING_ENDPOINT_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 519 ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 520 ENDPOINT_GENERAL, // bDescriptor
Perijah 0:ecc3925d3f8c 521 0x00, // bmAttributes
Perijah 0:ecc3925d3f8c 522 0x00, // bLockDelayUnits
Perijah 0:ecc3925d3f8c 523 LSB(0x0000), // wLockDelay
Perijah 0:ecc3925d3f8c 524 MSB(0x0000), // wLockDelay
Perijah 0:ecc3925d3f8c 525
Perijah 0:ecc3925d3f8c 526
Perijah 0:ecc3925d3f8c 527
Perijah 0:ecc3925d3f8c 528
Perijah 0:ecc3925d3f8c 529
Perijah 0:ecc3925d3f8c 530
Perijah 0:ecc3925d3f8c 531
Perijah 0:ecc3925d3f8c 532 // Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith
Perijah 0:ecc3925d3f8c 533 INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 534 INTERFACE_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 535 0x02, // bInterfaceNumber
Perijah 0:ecc3925d3f8c 536 0x00, // bAlternateSetting
Perijah 0:ecc3925d3f8c 537 0x00, // bNumEndpoints
Perijah 0:ecc3925d3f8c 538 AUDIO_CLASS, // bInterfaceClass
Perijah 0:ecc3925d3f8c 539 SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
Perijah 0:ecc3925d3f8c 540 0x00, // bInterfaceProtocol
Perijah 0:ecc3925d3f8c 541 0x00, // iInterface
Perijah 0:ecc3925d3f8c 542
Perijah 0:ecc3925d3f8c 543 // Interface 1, Alternate Setting 1, Audio Streaming - Operational
Perijah 0:ecc3925d3f8c 544 INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 545 INTERFACE_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 546 0x02, // bInterfaceNumber
Perijah 0:ecc3925d3f8c 547 0x01, // bAlternateSetting
Perijah 0:ecc3925d3f8c 548 0x01, // bNumEndpoints
Perijah 0:ecc3925d3f8c 549 AUDIO_CLASS, // bInterfaceClass
Perijah 0:ecc3925d3f8c 550 SUBCLASS_AUDIOSTREAMING, // bInterfaceSubClass
Perijah 0:ecc3925d3f8c 551 0x00, // bInterfaceProtocol
Perijah 0:ecc3925d3f8c 552 0x00, // iInterface
Perijah 0:ecc3925d3f8c 553
Perijah 0:ecc3925d3f8c 554 // Audio Streaming Interface
Perijah 0:ecc3925d3f8c 555 STREAMING_INTERFACE_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 556 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 557 SUBCLASS_AUDIOCONTROL, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 558 0x05, // bTerminalLink (output terminal microphone)
Perijah 0:ecc3925d3f8c 559 0x01, // bDelay
Perijah 0:ecc3925d3f8c 560 0x01, // wFormatTag
Perijah 0:ecc3925d3f8c 561 0x00, // wFormatTag
Perijah 0:ecc3925d3f8c 562
Perijah 0:ecc3925d3f8c 563 // Audio Type I Format
Perijah 0:ecc3925d3f8c 564 FORMAT_TYPE_I_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 565 INTERFACE_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 566 SUBCLASS_AUDIOSTREAMING, // bDescriptorSubtype
Perijah 0:ecc3925d3f8c 567 FORMAT_TYPE_I, // bFormatType
Perijah 0:ecc3925d3f8c 568 channel_nb_out, // bNrChannels
Perijah 0:ecc3925d3f8c 569 0x02, // bSubFrameSize
Perijah 0:ecc3925d3f8c 570 0x10, // bBitResolution
Perijah 0:ecc3925d3f8c 571 0x01, // bSamFreqType
Perijah 0:ecc3925d3f8c 572 LSB(FREQ_OUT), // tSamFreq
Perijah 0:ecc3925d3f8c 573 (FREQ_OUT >> 8) & 0xff, // tSamFreq
Perijah 0:ecc3925d3f8c 574 (FREQ_OUT >> 16) & 0xff, // tSamFreq
Perijah 0:ecc3925d3f8c 575
Perijah 0:ecc3925d3f8c 576 // Endpoint - Standard Descriptor
Perijah 0:ecc3925d3f8c 577 ENDPOINT_DESCRIPTOR_LENGTH + 2, // bLength
Perijah 0:ecc3925d3f8c 578 ENDPOINT_DESCRIPTOR, // bDescriptorType
Perijah 0:ecc3925d3f8c 579 PHY_TO_DESC(EPISO_IN), // bEndpointAddress
Perijah 0:ecc3925d3f8c 580 E_ISOCHRONOUS, // bmAttributes
Perijah 0:ecc3925d3f8c 581 LSB(PACKET_SIZE_ISO_OUT), // wMaxPacketSize
Perijah 0:ecc3925d3f8c 582 MSB(PACKET_SIZE_ISO_OUT), // wMaxPacketSize
Perijah 0:ecc3925d3f8c 583 0x01, // bInterval
Perijah 0:ecc3925d3f8c 584 0x00, // bRefresh
Perijah 0:ecc3925d3f8c 585 0x00, // bSynchAddress
Perijah 0:ecc3925d3f8c 586
Perijah 0:ecc3925d3f8c 587 // Endpoint - Audio Streaming
Perijah 0:ecc3925d3f8c 588 STREAMING_ENDPOINT_DESCRIPTOR_LENGTH, // bLength
Perijah 0:ecc3925d3f8c 589 ENDPOINT_DESCRIPTOR_TYPE, // bDescriptorType
Perijah 0:ecc3925d3f8c 590 ENDPOINT_GENERAL, // bDescriptor
Perijah 0:ecc3925d3f8c 591 0x00, // bmAttributes
Perijah 0:ecc3925d3f8c 592 0x00, // bLockDelayUnits
Perijah 0:ecc3925d3f8c 593 LSB(0x0000), // wLockDelay
Perijah 0:ecc3925d3f8c 594 MSB(0x0000), // wLockDelay
Perijah 0:ecc3925d3f8c 595
Perijah 0:ecc3925d3f8c 596 // Terminator
Perijah 0:ecc3925d3f8c 597 0 // bLength
Perijah 0:ecc3925d3f8c 598 };
Perijah 0:ecc3925d3f8c 599 return configDescriptor;
Perijah 0:ecc3925d3f8c 600 }
Perijah 0:ecc3925d3f8c 601
Perijah 0:ecc3925d3f8c 602 uint8_t * USBAudio::stringIinterfaceDesc() {
Perijah 0:ecc3925d3f8c 603 static uint8_t stringIinterfaceDescriptor[] = {
Perijah 0:ecc3925d3f8c 604 0x0c, //bLength
Perijah 0:ecc3925d3f8c 605 STRING_DESCRIPTOR, //bDescriptorType 0x03
Perijah 0:ecc3925d3f8c 606 'A',0,'u',0,'d',0,'i',0,'o',0 //bString iInterface - Audio
Perijah 0:ecc3925d3f8c 607 };
Perijah 0:ecc3925d3f8c 608 return stringIinterfaceDescriptor;
Perijah 0:ecc3925d3f8c 609 }
Perijah 0:ecc3925d3f8c 610
Perijah 0:ecc3925d3f8c 611 uint8_t * USBAudio::stringIproductDesc() {
Perijah 0:ecc3925d3f8c 612 static uint8_t stringIproductDescriptor[] = {
Perijah 0:ecc3925d3f8c 613 0x16, //bLength
Perijah 0:ecc3925d3f8c 614 STRING_DESCRIPTOR, //bDescriptorType 0x03
Perijah 0:ecc3925d3f8c 615 'M',0,'b',0,'e',0,'d',0,' ',0,'A',0,'u',0,'d',0,'i',0,'o',0 //bString iProduct - Mbed Audio
Perijah 0:ecc3925d3f8c 616 };
Perijah 0:ecc3925d3f8c 617 return stringIproductDescriptor;
Perijah 0:ecc3925d3f8c 618 }