summaryrefslogtreecommitdiffstats
path: root/tool/mbed/mbed-sdk/libraries/USBDevice
diff options
context:
space:
mode:
authorJun Wako <wakojun@gmail.com>2015-04-24 16:26:14 +0900
committerJun Wako <wakojun@gmail.com>2015-04-24 16:26:14 +0900
commit1fe4406f374291ab2e86e95a97341fd9c475fcb8 (patch)
tree1be0e16b4b07b5a31ea97ec50a9eb13a288c3d27 /tool/mbed/mbed-sdk/libraries/USBDevice
parenta20ef7052c6e937d2f7672dd59456e55a5c08296 (diff)
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
b9e0ea0 Merge commit '7fa9d8bdea3773d1195b04d98fcf27cf48ddd81d' as 'tool/mbed/mbed-sdk' 7fa9d8b Squashed 'tool/mbed/mbed-sdk/' content from commit 7c21ce5 git-subtree-dir: tmk_core git-subtree-split: b9e0ea08cb940de20b3610ecdda18e9d8cd7c552
Diffstat (limited to 'tool/mbed/mbed-sdk/libraries/USBDevice')
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio.cpp618
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio.h287
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio_Types.h97
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/inc/devdrv_usb_function_api.h365
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/inc/usb_function.h143
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/inc/usb_function_version.h32
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/inc/usb0_function.h171
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/inc/usb0_function_api.h104
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/inc/usb0_function_dmacdrv.h142
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/common/usb0_function_dataio.c2933
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/common/usb0_function_dma.c346
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/common/usb0_function_intrn.c249
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/common/usb0_function_lib.c2026
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/function/usb0_function_api.c441
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/function/usb0_function_controlrw.c142
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/function/usb0_function_global.c144
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/function/usb0_function_sig.c330
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/function/usb0_function_sub.c453
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/userdef/usb0_function_dmacdrv.c698
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb0/src/userdef/usb0_function_userdef.c762
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/inc/usb1_function.h171
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/inc/usb1_function_api.h104
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/inc/usb1_function_dmacdrv.h142
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/common/usb1_function_dataio.c2932
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/common/usb1_function_dma.c346
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/common/usb1_function_intrn.c249
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/common/usb1_function_lib.c2044
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/function/usb1_function_api.c441
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/function/usb1_function_controlrw.c142
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/function/usb1_function_global.c144
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/function/usb1_function_sig.c330
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/function/usb1_function_sub.c453
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/userdef/usb1_function_dmacdrv.c698
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb1/src/userdef/usb1_function_userdef.c762
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/TARGET_RENESAS/TARGET_RZ_A1H/usb_function_setting.h173
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBDescriptor.h74
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBDevice.cpp1005
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBDevice.h271
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBDevice_Types.h83
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints.h56
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_KL25Z.h99
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_LPC11U.h71
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_LPC17_LPC23.h99
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_Maxim.h90
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_RZ_A1H.h85
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBEndpoints_STM32F4.h67
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL.h121
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_KL25Z.cpp551
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_LPC11U.cpp738
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_LPC17.cpp623
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_LPC40.cpp628
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_Maxim.cpp473
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.cpp1497
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBHAL_STM32F4.cpp410
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBDevice/USBRegs_STM32.h149
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBHID.cpp276
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBHID.h172
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBHID_Types.h91
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBKeyboard.cpp553
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBKeyboard.h183
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBMouse.cpp245
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBMouse.h209
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBMouseKeyboard.cpp706
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBHID/USBMouseKeyboard.h220
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBMIDI/MIDIMessage.h276
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBMIDI/USBMIDI.cpp207
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBMIDI/USBMIDI.h112
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBMSD/USBMSD.cpp655
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBMSD/USBMSD.h251
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/CircBuffer.h63
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/USBCDC.cpp286
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/USBCDC.h123
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/USBSerial.cpp67
-rw-r--r--tool/mbed/mbed-sdk/libraries/USBDevice/USBSerial/USBSerial.h161
74 files changed, 31660 insertions, 0 deletions
diff --git a/tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio.cpp b/tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio.cpp
new file mode 100644
index 0000000000..aab9e774e3
--- /dev/null
+++ b/tool/mbed/mbed-sdk/libraries/USBDevice/USBAudio/USBAudio.cpp
@@ -0,0 +1,618 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "stdint.h"
+#include "USBAudio.h"
+#include "USBAudio_Types.h"
+
+
+
+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) {
+ mute = 0;
+ volCur = 0x0080;
+ volMin = 0x0000;
+ volMax = 0x0100;
+ volRes = 0x0004;
+ available = false;
+
+ FREQ_IN = frequency_in;
+ FREQ_OUT = frequency_out;
+
+ this->channel_nb_in = channel_nb_in;
+ this->channel_nb_out = channel_nb_out;
+
+ // stereo -> *2, mono -> *1
+ PACKET_SIZE_ISO_IN = (FREQ_IN / 500) * channel_nb_in;
+ PACKET_SIZE_ISO_OUT = (FREQ_OUT / 500) * channel_nb_out;
+
+ // STEREO -> left and right
+ channel_config_in = (channel_nb_in == 1) ? CHANNEL_M : CHANNEL_L + CHANNEL_R;
+ channel_config_out = (channel_nb_out == 1) ? CHANNEL_M : CHANNEL_L + CHANNEL_R;
+
+ SOF_handler = false;
+
+ buf_stream_out = NULL;
+ buf_stream_in = NULL;
+
+ interruptOUT = false;
+ writeIN = false;
+ interruptIN = false;
+ available = false;
+
+ volume = 0;
+
+ // connect the device
+ USBDevice::connect();
+}
+
+bool USBAudio::read(uint8_t * buf) {
+ buf_stream_in = buf;
+ SOF_handler = false;
+ while (!available || !SOF_handler);
+ available = false;
+ return true;
+}
+
+bool USBAudio::readNB(uint8_t * buf) {
+ buf_stream_in = buf;
+ SOF_handler = false;
+ while (!SOF_handler);
+ if (available) {
+ available = false;
+ buf_stream_in = NULL;
+ return true;
+ }
+ return false;
+}
+
+bool USBAudio::readWrite(uint8_t * buf_read, uint8_t * buf_write) {
+ buf_stream_in = buf_read;
+ SOF_handler = false;
+ writeIN = false;
+ if (interruptIN) {
+ USBDevice::writeNB(EP3IN, buf_write, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
+ } else {
+ buf_stream_out = buf_write;
+ }
+ while (!available);
+ if (interruptIN) {
+ while (!writeIN);
+ }
+ while (!SOF_handler);
+ return true;
+}
+
+
+bool USBAudio::write(uint8_t * buf) {
+ writeIN = false;
+ SOF_handler = false;
+ if (interruptIN) {
+ USBDevice::writeNB(EP3IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
+ } else {
+ buf_stream_out = buf;
+ }
+ while (!SOF_handler);
+ if (interruptIN) {
+ while (!writeIN);
+ }
+ return true;
+}
+
+
+float USBAudio::getVolume() {
+ return (mute) ? 0.0 : volume;
+}
+
+
+bool USBAudio::EPISO_OUT_callback() {
+ uint32_t size = 0;
+ interruptOUT = true;
+ if (buf_stream_in != NULL) {
+ readEP(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN);
+ available = true;
+ buf_stream_in = NULL;
+ }
+ readStart(EP3OUT, PACKET_SIZE_ISO_IN);
+ return false;
+}
+
+
+bool USBAudio::EPISO_IN_callback() {
+ interruptIN = true;
+ writeIN = true;
+ return true;
+}
+
+
+
+// Called in ISR context on each start of frame
+void USBAudio::SOF(int frameNumber) {
+ uint32_t size = 0;
+
+ if (!interruptOUT) {
+ // read the isochronous endpoint
+ if (buf_stream_in != NULL) {
+ if (USBDevice::readEP_NB(EP3OUT, (uint8_t *)buf_stream_in, &size, PACKET_SIZE_ISO_IN)) {
+ if (size) {
+ available = true;
+ readStart(EP3OUT, PACKET_SIZE_ISO_IN);
+ buf_stream_in = NULL;
+ }
+ }
+ }
+ }
+
+ if (!interruptIN) {
+ // write if needed
+ if (buf_stream_out != NULL) {
+ USBDevice::writeNB(EP3IN, (uint8_t *)buf_stream_out, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
+ buf_stream_out = NULL;
+ }
+ }
+
+ SOF_handler = true;
+}
+
+
+// Called in ISR context
+// Set configuration. Return false if the configuration is not supported.
+bool USBAudio::USBCallback_setConfiguration(uint8_t configuration) {
+ if (configuration != DEFAULT_CONFIGURATION) {
+ return false;
+ }
+
+ // Configure isochronous endpoint
+ realiseEndpoint(EP3OUT, PACKET_SIZE_ISO_IN, ISOCHRONOUS);
+ realiseEndpoint(EP3IN, PACKET_SIZE_ISO_OUT, ISOCHRONOUS);
+
+ // activate readings on this endpoint
+ readStart(EP3OUT, PACKET_SIZE_ISO_IN);
+ return true;
+}
+
+
+// Called in ISR context
+// Set alternate setting. Return false if the alternate setting is not supported
+bool USBAudio::USBCallback_setInterface(uint16_t interface, uint8_t alternate) {
+ if (interface == 0 && alternate == 0) {
+ return true;
+ }
+ if (interface == 1 && (alternate == 0 || alternate == 1)) {
+ return true;
+ }
+ if (interface == 2 && (alternate == 0 || alternate == 1)) {
+ return true;
+ }
+ return false;
+}
+
+
+
+// Called in ISR context
+// Called by USBDevice on Endpoint0 request
+// This is used to handle extensions to standard requests and class specific requests.
+// Return true if class handles this request
+bool USBAudio::USBCallback_request() {
+ bool success = false;
+ CONTROL_TRANSFER * transfer = getTransferPtr();
+
+ // Process class-specific requests
+ if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
+
+ // Feature Unit: Interface = 0, ID = 2
+ if (transfer->setup.wIndex == 0x0200) {
+
+ // Master Channel
+ if ((transfer->setup.wValue & 0xff) == 0) {
+
+ switch (transfer->setup.wValue >> 8) {
+ case MUTE_CONTROL:
+ switch (transfer->setup.bRequest) {
+ case REQUEST_GET_CUR:
+ transfer->remaining = 1;
+ transfer->ptr = &mute;
+ transfer->direction = DEVICE_TO_HOST;
+ success = true;
+ break;
+
+ case REQUEST_SET_CUR:
+ transfer->remaining = 1;
+ transfer->notify = true;
+ transfer->direction = HOST_TO_DEVICE;
+ success = true;
+ break;
+ default:
+ break;
+ }
+ break;
+ case VOLUME_CONTROL:
+ switch (transfer->setup.bRequest) {
+ case REQUEST_GET_CUR:
+ transfer->remaining = 2;
+ transfer->ptr = (uint8_t *)&volCur;
+ transfer->direction = DEVICE_TO_HOST;
+ success = true;
+ break;
+ case REQUEST_GET_MIN:
+ transfer->remaining = 2;
+ transfer->ptr = (uint8_t *)&volMin;
+ transfer->direction = DEVICE_TO_HOST;
+ success = true;
+ break;
+ case REQUEST_GET_MAX:
+ transfer->remaining = 2;
+ transfer->ptr = (uint8_t *)&volMax;
+ transfer->direction = DEVICE_TO_HOST;
+ success = true;
+ break;
+ case REQUEST_GET_RES:
+ transfer->remaining = 2;
+ transfer->ptr = (uint8_t *)&volRes;
+ transfer->direction = DEVICE_TO_HOST;
+ success = true;
+ break;
+
+ case REQUEST_SET_CUR:
+ transfer->remaining = 2;
+ transfer->notify = true;
+ transfer->direction = HOST_TO_DEVICE;
+ success = true;
+ break;
+ case REQUEST_SET_MIN:
+ transfer->remaining = 2;
+ transfer->notify = true;
+ transfer->direction = HOST_TO_DEVICE;
+ success = true;
+ break;
+ case REQUEST_SET_MAX:
+ transfer->remaining = 2;
+ transfer->notify = true;
+ transfer->direction = HOST_TO_DEVICE;
+ success = true;
+ break;
+ case REQUEST_SET_RES:
+ transfer->remaining = 2;
+ transfer->notify = true;
+ transfer->direction = HOST_TO_DEVICE;
+ success = true;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ return success;
+}
+
+
+// Called in ISR context when a data OUT stage has been performed
+void USBAudio::USBCallback_requestCompleted(uint8_t * buf, uint32_t length) {
+ if ((length == 1) || (length == 2)) {
+ uint16_t data = (length == 1) ? *buf : *((uint16_t *)buf);
+ CONTROL_TRANSFER * transfer = getTransferPtr();
+ switch (transfer->setup.wValue >> 8) {
+ case MUTE_CONTROL:
+ switch (transfer->setup.bRequest) {
+ case REQUEST_SET_CUR:
+ mute = data & 0xff;
+ updateVol.call();
+ break;
+ default:
+ break;
+ }
+ break;
+ case VOLUME_CONTROL:
+ switch (transfer->setup.bRequest) {
+ case REQUEST_SET_CUR:
+ volCur = data;
+ volume = (float)volCur/(float)volMax;