From cc0c99845d899cdac89fcb8df295cf8470a8d5fe Mon Sep 17 00:00:00 2001 From: mlundinse Date: Mon, 15 Apr 2013 23:47:06 +0200 Subject: moved usb_midi_descr.c Non processor specific code --- libmaple/usb/stm32f1/usb_midi_descr.c | 308 ---------------------------------- libmaple/usb/usb_lib/usb_midi_descr.c | 308 ++++++++++++++++++++++++++++++++++ 2 files changed, 308 insertions(+), 308 deletions(-) delete mode 100644 libmaple/usb/stm32f1/usb_midi_descr.c create mode 100644 libmaple/usb/usb_lib/usb_midi_descr.c diff --git a/libmaple/usb/stm32f1/usb_midi_descr.c b/libmaple/usb/stm32f1/usb_midi_descr.c deleted file mode 100644 index d476fd2..0000000 --- a/libmaple/usb/stm32f1/usb_midi_descr.c +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************** - * The MIT License - * - * Copyright (c) 2011 LeafLabs LLC. - * Copyright (c) 2013 Magnus Lundin. - * - * 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. - *****************************************************************************/ - -/** - * @file libmaple/usb/stm32f1/usb_midi_descr.c - * @brief USB MIDI Class descriptor. - * - * This file uses no device specific code - * - */ - -#include -#include - -/* Private headers */ -#include "usb_lib_globals.h" - -/* usb_lib headers */ -#include "usb_type.h" -#include "usb_core.h" -#include "usb_def.h" - -/* - * Descriptors - */ - -static const usb_descriptor_device usbMIDIDescriptor_Device = - USB_MIDI_DECLARE_DEV_DESC(LEAFLABS_ID_VENDOR, MAPLE_ID_PRODUCT); - -typedef struct { - usb_descriptor_config_header Config_Header; - /* Control Interface */ - usb_descriptor_interface AC_Interface; - AC_CS_INTERFACE_DESCRIPTOR(1) AC_CS_Interface; - /* Control Interface */ - usb_descriptor_interface MS_Interface; - MS_CS_INTERFACE_DESCRIPTOR MS_CS_Interface; - MIDI_IN_JACK_DESCRIPTOR MIDI_IN_JACK_1; - MIDI_IN_JACK_DESCRIPTOR MIDI_IN_JACK_2; - MIDI_OUT_JACK_DESCRIPTOR(1) MIDI_OUT_JACK_3; - MIDI_OUT_JACK_DESCRIPTOR(1) MIDI_OUT_JACK_4; - usb_descriptor_endpoint DataOutEndpoint; - MS_CS_BULK_ENDPOINT_DESCRIPTOR(1) MS_CS_DataOutEndpoint; - usb_descriptor_endpoint DataInEndpoint; - MS_CS_BULK_ENDPOINT_DESCRIPTOR(1) MS_CS_DataInEndpoint; -} __packed usb_descriptor_config; - -static const usb_descriptor_config usbMIDIDescriptor_Config = { - .Config_Header = { - .bLength = sizeof(usb_descriptor_config_header), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CONFIGURATION, - .wTotalLength = sizeof(usb_descriptor_config), - .bNumInterfaces = 0x02, - .bConfigurationValue = 0x01, - .iConfiguration = 0x00, - .bmAttributes = (USB_CONFIG_ATTR_BUSPOWERED | - USB_CONFIG_ATTR_SELF_POWERED), - .bMaxPower = MAX_POWER, - }, - - .AC_Interface = { - .bLength = sizeof(usb_descriptor_interface), - .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, - .bInterfaceNumber = 0x00, - .bAlternateSetting = 0x00, - .bNumEndpoints = 0x00, - .bInterfaceClass = USB_INTERFACE_CLASS_AUDIO, - .bInterfaceSubClass = USB_INTERFACE_AUDIOCONTROL, - .bInterfaceProtocol = 0x00, - .iInterface = 0x00, - }, - - .AC_CS_Interface = { - .bLength = AC_CS_INTERFACE_DESCRIPTOR_SIZE(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = 0x01, - .bcdADC = 0x0100, - .wTotalLength = AC_CS_INTERFACE_DESCRIPTOR_SIZE(1), - .bInCollection = 0x01, - .baInterfaceNr = {0x01}, - }, - - .MS_Interface = { - .bLength = sizeof(usb_descriptor_interface), - .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, - .bInterfaceNumber = 0x01, - .bAlternateSetting = 0x00, - .bNumEndpoints = 0x02, - .bInterfaceClass = USB_INTERFACE_CLASS_AUDIO, - .bInterfaceSubClass = USB_INTERFACE_MIDISTREAMING, - .bInterfaceProtocol = 0x00, - .iInterface = 0x04, - }, - - .MS_CS_Interface = { - .bLength = sizeof(MS_CS_INTERFACE_DESCRIPTOR), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = 0x01, - .bcdADC = 0x0100, - .wTotalLength = sizeof(MS_CS_INTERFACE_DESCRIPTOR) - +sizeof(MIDI_IN_JACK_DESCRIPTOR) - +sizeof(MIDI_IN_JACK_DESCRIPTOR) - +MIDI_OUT_JACK_DESCRIPTOR_SIZE(1) - +MIDI_OUT_JACK_DESCRIPTOR_SIZE(1) - +sizeof(usb_descriptor_endpoint) - +MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1) - +sizeof(usb_descriptor_endpoint) - +MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1) - /* 0x41-4 */, - }, - - .MIDI_IN_JACK_1 = { - .bLength = sizeof(MIDI_IN_JACK_DESCRIPTOR), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = MIDI_IN_JACK, - .bJackType = MIDI_JACK_EMBEDDED, - .bJackId = 0x01, - .iJack = 0x05, - }, - - .MIDI_IN_JACK_2 = { - .bLength = sizeof(MIDI_IN_JACK_DESCRIPTOR), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = MIDI_IN_JACK, - .bJackType = MIDI_JACK_EXTERNAL, - .bJackId = 0x02, - .iJack = 0x00, - }, - - .MIDI_OUT_JACK_3 = { - .bLength = MIDI_OUT_JACK_DESCRIPTOR_SIZE(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = MIDI_OUT_JACK, - .bJackType = MIDI_JACK_EMBEDDED, - .bJackId = 0x03, - .bNrInputPins = 0x01, - .baSourceId = {0x02}, - .baSourcePin = {0x01}, - .iJack = 0x00, - }, - - .MIDI_OUT_JACK_4 = { - .bLength = MIDI_OUT_JACK_DESCRIPTOR_SIZE(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, - .SubType = MIDI_OUT_JACK, - .bJackType = MIDI_JACK_EXTERNAL, - .bJackId = 0x04, - .bJackId = 0x03, - .bNrInputPins = 0x01, - .baSourceId = {0x01}, - .baSourcePin = {0x01}, - .iJack = 0x00, - }, - - .DataOutEndpoint = { - .bLength = sizeof(usb_descriptor_endpoint), - .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, - .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_OUT | - USB_MIDI_RX_ENDP), - .bmAttributes = USB_EP_TYPE_BULK, - .wMaxPacketSize = USB_MIDI_RX_EPSIZE, - .bInterval = 0x00, - }, - - .MS_CS_DataOutEndpoint = { - .bLength = MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_ENDPOINT, - .SubType = 0x01, - .bNumEmbMIDIJack = 0x01, - .baAssocJackID = {0x01}, - }, - - .DataInEndpoint = { - .bLength = sizeof(usb_descriptor_endpoint), - .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, - .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_IN | USB_MIDI_TX_ENDP), - .bmAttributes = USB_EP_TYPE_BULK, - .wMaxPacketSize = USB_MIDI_TX_EPSIZE, - .bInterval = 0x00, - }, - - .MS_CS_DataInEndpoint = { - .bLength = MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_ENDPOINT, - .SubType = 0x01, - .bNumEmbMIDIJack = 0x01, - .baAssocJackID = {0x03}, - }, - -}; - -/* - String Descriptors: - - we may choose to specify any or none of the following string - identifiers: - - iManufacturer: LeafLabs - iProduct: Maple - iSerialNumber: NONE - iConfiguration: NONE - iInterface(CCI): NONE - iInterface(DCI): NONE - -*/ - -/* Unicode language identifier: 0x0409 is US English */ -/* FIXME move to Wirish */ -static const usb_descriptor_string usbMIDIDescriptor_LangID = { - .bLength = USB_DESCRIPTOR_STRING_LEN(1), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {0x09, 0x04}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbMIDIDescriptor_iManufacturer = { - .bLength = USB_DESCRIPTOR_STRING_LEN(8), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'L', 0, 'e', 0, 'a', 0, 'f', 0, - 'L', 0, 'a', 0, 'b', 0, 's', 0}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbMIDIDescriptor_iProduct = { - .bLength = USB_DESCRIPTOR_STRING_LEN(10), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'M', 0, 'a', 0, 'p', 0, 'l', 0, 'e', 0, ' ', 0, 'M', 0, 'I', 0, 'D', 0, 'I', 0}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbMIDIDescriptor_iInterface = { - .bLength = USB_DESCRIPTOR_STRING_LEN(4), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'M', 0, 'I', 0, 'D', 0, 'I', 0}, -}; - -/* FIXME move to Wirish */ -static const usb_descriptor_string usbMIDIDescriptor_iJack1 = { - .bLength = USB_DESCRIPTOR_STRING_LEN(5), - .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, - .bString = {'J', 0, 'a', 0, 'c', 0, 'k', 0, '1', 0}, -}; - - -static ONE_DESCRIPTOR Device_Descriptor = { - (uint8*)&usbMIDIDescriptor_Device, - sizeof(usb_descriptor_device) -}; - -static ONE_DESCRIPTOR Config_Descriptor = { - (uint8*)&usbMIDIDescriptor_Config, - sizeof(usb_descriptor_config) -}; - -#define N_STRING_DESCRIPTORS 5 -static ONE_DESCRIPTOR String_Descriptor[N_STRING_DESCRIPTORS] = { - {(uint8*)&usbMIDIDescriptor_LangID, USB_DESCRIPTOR_STRING_LEN(1)}, - {(uint8*)&usbMIDIDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(8)}, - {(uint8*)&usbMIDIDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(10)}, - {(uint8*)&usbMIDIDescriptor_iInterface, USB_DESCRIPTOR_STRING_LEN(4)}, - {(uint8*)&usbMIDIDescriptor_iJack1, USB_DESCRIPTOR_STRING_LEN(5)} -}; - -/* - * Funtions to access the descriptor structures - */ - -uint8* usbGetMidiDeviceDescriptor(uint16 length) { - return Standard_GetDescriptorData(length, &Device_Descriptor); -} - -uint8* usbGetMidiConfigDescriptor(uint16 length) { - return Standard_GetDescriptorData(length, &Config_Descriptor); -} - -uint8* usbGetMidiStringDescriptor(uint16 length) { - uint8 wValue0 = pInformation->USBwValue0; - - if (wValue0 > N_STRING_DESCRIPTORS) { - return NULL; - } - return Standard_GetDescriptorData(length, &String_Descriptor[wValue0]); -} - diff --git a/libmaple/usb/usb_lib/usb_midi_descr.c b/libmaple/usb/usb_lib/usb_midi_descr.c new file mode 100644 index 0000000..d476fd2 --- /dev/null +++ b/libmaple/usb/usb_lib/usb_midi_descr.c @@ -0,0 +1,308 @@ +/****************************************************************************** + * The MIT License + * + * Copyright (c) 2011 LeafLabs LLC. + * Copyright (c) 2013 Magnus Lundin. + * + * 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. + *****************************************************************************/ + +/** + * @file libmaple/usb/stm32f1/usb_midi_descr.c + * @brief USB MIDI Class descriptor. + * + * This file uses no device specific code + * + */ + +#include +#include + +/* Private headers */ +#include "usb_lib_globals.h" + +/* usb_lib headers */ +#include "usb_type.h" +#include "usb_core.h" +#include "usb_def.h" + +/* + * Descriptors + */ + +static const usb_descriptor_device usbMIDIDescriptor_Device = + USB_MIDI_DECLARE_DEV_DESC(LEAFLABS_ID_VENDOR, MAPLE_ID_PRODUCT); + +typedef struct { + usb_descriptor_config_header Config_Header; + /* Control Interface */ + usb_descriptor_interface AC_Interface; + AC_CS_INTERFACE_DESCRIPTOR(1) AC_CS_Interface; + /* Control Interface */ + usb_descriptor_interface MS_Interface; + MS_CS_INTERFACE_DESCRIPTOR MS_CS_Interface; + MIDI_IN_JACK_DESCRIPTOR MIDI_IN_JACK_1; + MIDI_IN_JACK_DESCRIPTOR MIDI_IN_JACK_2; + MIDI_OUT_JACK_DESCRIPTOR(1) MIDI_OUT_JACK_3; + MIDI_OUT_JACK_DESCRIPTOR(1) MIDI_OUT_JACK_4; + usb_descriptor_endpoint DataOutEndpoint; + MS_CS_BULK_ENDPOINT_DESCRIPTOR(1) MS_CS_DataOutEndpoint; + usb_descriptor_endpoint DataInEndpoint; + MS_CS_BULK_ENDPOINT_DESCRIPTOR(1) MS_CS_DataInEndpoint; +} __packed usb_descriptor_config; + +static const usb_descriptor_config usbMIDIDescriptor_Config = { + .Config_Header = { + .bLength = sizeof(usb_descriptor_config_header), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CONFIGURATION, + .wTotalLength = sizeof(usb_descriptor_config), + .bNumInterfaces = 0x02, + .bConfigurationValue = 0x01, + .iConfiguration = 0x00, + .bmAttributes = (USB_CONFIG_ATTR_BUSPOWERED | + USB_CONFIG_ATTR_SELF_POWERED), + .bMaxPower = MAX_POWER, + }, + + .AC_Interface = { + .bLength = sizeof(usb_descriptor_interface), + .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, + .bInterfaceNumber = 0x00, + .bAlternateSetting = 0x00, + .bNumEndpoints = 0x00, + .bInterfaceClass = USB_INTERFACE_CLASS_AUDIO, + .bInterfaceSubClass = USB_INTERFACE_AUDIOCONTROL, + .bInterfaceProtocol = 0x00, + .iInterface = 0x00, + }, + + .AC_CS_Interface = { + .bLength = AC_CS_INTERFACE_DESCRIPTOR_SIZE(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = 0x01, + .bcdADC = 0x0100, + .wTotalLength = AC_CS_INTERFACE_DESCRIPTOR_SIZE(1), + .bInCollection = 0x01, + .baInterfaceNr = {0x01}, + }, + + .MS_Interface = { + .bLength = sizeof(usb_descriptor_interface), + .bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE, + .bInterfaceNumber = 0x01, + .bAlternateSetting = 0x00, + .bNumEndpoints = 0x02, + .bInterfaceClass = USB_INTERFACE_CLASS_AUDIO, + .bInterfaceSubClass = USB_INTERFACE_MIDISTREAMING, + .bInterfaceProtocol = 0x00, + .iInterface = 0x04, + }, + + .MS_CS_Interface = { + .bLength = sizeof(MS_CS_INTERFACE_DESCRIPTOR), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = 0x01, + .bcdADC = 0x0100, + .wTotalLength = sizeof(MS_CS_INTERFACE_DESCRIPTOR) + +sizeof(MIDI_IN_JACK_DESCRIPTOR) + +sizeof(MIDI_IN_JACK_DESCRIPTOR) + +MIDI_OUT_JACK_DESCRIPTOR_SIZE(1) + +MIDI_OUT_JACK_DESCRIPTOR_SIZE(1) + +sizeof(usb_descriptor_endpoint) + +MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1) + +sizeof(usb_descriptor_endpoint) + +MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1) + /* 0x41-4 */, + }, + + .MIDI_IN_JACK_1 = { + .bLength = sizeof(MIDI_IN_JACK_DESCRIPTOR), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = MIDI_IN_JACK, + .bJackType = MIDI_JACK_EMBEDDED, + .bJackId = 0x01, + .iJack = 0x05, + }, + + .MIDI_IN_JACK_2 = { + .bLength = sizeof(MIDI_IN_JACK_DESCRIPTOR), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = MIDI_IN_JACK, + .bJackType = MIDI_JACK_EXTERNAL, + .bJackId = 0x02, + .iJack = 0x00, + }, + + .MIDI_OUT_JACK_3 = { + .bLength = MIDI_OUT_JACK_DESCRIPTOR_SIZE(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = MIDI_OUT_JACK, + .bJackType = MIDI_JACK_EMBEDDED, + .bJackId = 0x03, + .bNrInputPins = 0x01, + .baSourceId = {0x02}, + .baSourcePin = {0x01}, + .iJack = 0x00, + }, + + .MIDI_OUT_JACK_4 = { + .bLength = MIDI_OUT_JACK_DESCRIPTOR_SIZE(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_INTERFACE, + .SubType = MIDI_OUT_JACK, + .bJackType = MIDI_JACK_EXTERNAL, + .bJackId = 0x04, + .bJackId = 0x03, + .bNrInputPins = 0x01, + .baSourceId = {0x01}, + .baSourcePin = {0x01}, + .iJack = 0x00, + }, + + .DataOutEndpoint = { + .bLength = sizeof(usb_descriptor_endpoint), + .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, + .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_OUT | + USB_MIDI_RX_ENDP), + .bmAttributes = USB_EP_TYPE_BULK, + .wMaxPacketSize = USB_MIDI_RX_EPSIZE, + .bInterval = 0x00, + }, + + .MS_CS_DataOutEndpoint = { + .bLength = MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_ENDPOINT, + .SubType = 0x01, + .bNumEmbMIDIJack = 0x01, + .baAssocJackID = {0x01}, + }, + + .DataInEndpoint = { + .bLength = sizeof(usb_descriptor_endpoint), + .bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT, + .bEndpointAddress = (USB_DESCRIPTOR_ENDPOINT_IN | USB_MIDI_TX_ENDP), + .bmAttributes = USB_EP_TYPE_BULK, + .wMaxPacketSize = USB_MIDI_TX_EPSIZE, + .bInterval = 0x00, + }, + + .MS_CS_DataInEndpoint = { + .bLength = MS_CS_BULK_ENDPOINT_DESCRIPTOR_SIZE(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_CS_ENDPOINT, + .SubType = 0x01, + .bNumEmbMIDIJack = 0x01, + .baAssocJackID = {0x03}, + }, + +}; + +/* + String Descriptors: + + we may choose to specify any or none of the following string + identifiers: + + iManufacturer: LeafLabs + iProduct: Maple + iSerialNumber: NONE + iConfiguration: NONE + iInterface(CCI): NONE + iInterface(DCI): NONE + +*/ + +/* Unicode language identifier: 0x0409 is US English */ +/* FIXME move to Wirish */ +static const usb_descriptor_string usbMIDIDescriptor_LangID = { + .bLength = USB_DESCRIPTOR_STRING_LEN(1), + .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, + .bString = {0x09, 0x04}, +}; + +/* FIXME move to Wirish */ +static const usb_descriptor_string usbMIDIDescriptor_iManufacturer = { + .bLength = USB_DESCRIPTOR_STRING_LEN(8), + .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, + .bString = {'L', 0, 'e', 0, 'a', 0, 'f', 0, + 'L', 0, 'a', 0, 'b', 0, 's', 0}, +}; + +/* FIXME move to Wirish */ +static const usb_descriptor_string usbMIDIDescriptor_iProduct = { + .bLength = USB_DESCRIPTOR_STRING_LEN(10), + .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, + .bString = {'M', 0, 'a', 0, 'p', 0, 'l', 0, 'e', 0, ' ', 0, 'M', 0, 'I', 0, 'D', 0, 'I', 0}, +}; + +/* FIXME move to Wirish */ +static const usb_descriptor_string usbMIDIDescriptor_iInterface = { + .bLength = USB_DESCRIPTOR_STRING_LEN(4), + .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, + .bString = {'M', 0, 'I', 0, 'D', 0, 'I', 0}, +}; + +/* FIXME move to Wirish */ +static const usb_descriptor_string usbMIDIDescriptor_iJack1 = { + .bLength = USB_DESCRIPTOR_STRING_LEN(5), + .bDescriptorType = USB_DESCRIPTOR_TYPE_STRING, + .bString = {'J', 0, 'a', 0, 'c', 0, 'k', 0, '1', 0}, +}; + + +static ONE_DESCRIPTOR Device_Descriptor = { + (uint8*)&usbMIDIDescriptor_Device, + sizeof(usb_descriptor_device) +}; + +static ONE_DESCRIPTOR Config_Descriptor = { + (uint8*)&usbMIDIDescriptor_Config, + sizeof(usb_descriptor_config) +}; + +#define N_STRING_DESCRIPTORS 5 +static ONE_DESCRIPTOR String_Descriptor[N_STRING_DESCRIPTORS] = { + {(uint8*)&usbMIDIDescriptor_LangID, USB_DESCRIPTOR_STRING_LEN(1)}, + {(uint8*)&usbMIDIDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(8)}, + {(uint8*)&usbMIDIDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(10)}, + {(uint8*)&usbMIDIDescriptor_iInterface, USB_DESCRIPTOR_STRING_LEN(4)}, + {(uint8*)&usbMIDIDescriptor_iJack1, USB_DESCRIPTOR_STRING_LEN(5)} +}; + +/* + * Funtions to access the descriptor structures + */ + +uint8* usbGetMidiDeviceDescriptor(uint16 length) { + return Standard_GetDescriptorData(length, &Device_Descriptor); +} + +uint8* usbGetMidiConfigDescriptor(uint16 length) { + return Standard_GetDescriptorData(length, &Config_Descriptor); +} + +uint8* usbGetMidiStringDescriptor(uint16 length) { + uint8 wValue0 = pInformation->USBwValue0; + + if (wValue0 > N_STRING_DESCRIPTORS) { + return NULL; + } + return Standard_GetDescriptorData(length, &String_Descriptor[wValue0]); +} + -- cgit v1.2.3