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