Added to LPC4088-USBHost the USBHostMidi class. Plugin an usb midi interface to the usb host of lpc4088 allows to send midi event to the midi interface. For the moment I can not be able to get event from the interface by using the attacheNoteOn or other triggers...

Dependencies:   FATFileSystem mbed-rtos

Fork of LPC4088-USBHost by Norimasa Okamoto

Committer:
Grag38
Date:
Mon Apr 06 12:46:58 2015 +0000
Revision:
1:d652de69bd1a
Parent:
0:148fca6fd246
Added USBHostMidi to drive midi interface.; ; Tested to send Midi messages from LPC4088. This works.; ; Need to test with incomming events.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:148fca6fd246 1 /* mbed USBHost Library
va009039 0:148fca6fd246 2 * Copyright (c) 2006-2013 ARM Limited
va009039 0:148fca6fd246 3 *
va009039 0:148fca6fd246 4 * Licensed under the Apache License, Version 2.0 (the "License");
va009039 0:148fca6fd246 5 * you may not use this file except in compliance with the License.
va009039 0:148fca6fd246 6 * You may obtain a copy of the License at
va009039 0:148fca6fd246 7 *
va009039 0:148fca6fd246 8 * http://www.apache.org/licenses/LICENSE-2.0
va009039 0:148fca6fd246 9 *
va009039 0:148fca6fd246 10 * Unless required by applicable law or agreed to in writing, software
va009039 0:148fca6fd246 11 * distributed under the License is distributed on an "AS IS" BASIS,
va009039 0:148fca6fd246 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
va009039 0:148fca6fd246 13 * See the License for the specific language governing permissions and
va009039 0:148fca6fd246 14 * limitations under the License.
va009039 0:148fca6fd246 15 */
va009039 0:148fca6fd246 16
va009039 0:148fca6fd246 17 #ifndef USB_INC_H
va009039 0:148fca6fd246 18 #define USB_INC_H
va009039 0:148fca6fd246 19
va009039 0:148fca6fd246 20 #include "mbed.h"
va009039 0:148fca6fd246 21 #include "toolchain.h"
va009039 0:148fca6fd246 22
va009039 0:148fca6fd246 23 enum USB_TYPE {
va009039 0:148fca6fd246 24 USB_TYPE_OK = 0,
va009039 0:148fca6fd246 25
va009039 0:148fca6fd246 26 // completion code
va009039 0:148fca6fd246 27 USB_TYPE_CRC_ERROR = 1,
va009039 0:148fca6fd246 28 USB_TYPE_BIT_STUFFING_ERROR = 2,
va009039 0:148fca6fd246 29 USB_TYPE_DATA_TOGGLE_MISMATCH_ERROR = 3,
va009039 0:148fca6fd246 30 USB_TYPE_STALL_ERROR = 4,
va009039 0:148fca6fd246 31 USB_TYPE_DEVICE_NOT_RESPONDING_ERROR = 5,
va009039 0:148fca6fd246 32 USB_TYPE_PID_CHECK_FAILURE_ERROR = 6,
va009039 0:148fca6fd246 33 USB_TYPE_UNEXPECTED_PID_ERROR = 7,
va009039 0:148fca6fd246 34 USB_TYPE_DATA_OVERRUN_ERROR = 8,
va009039 0:148fca6fd246 35 USB_TYPE_DATA_UNDERRUN_ERROR = 9,
va009039 0:148fca6fd246 36 USB_TYPE_RESERVED = 9,
va009039 0:148fca6fd246 37 USB_TYPE_RESERVED_ = 10,
va009039 0:148fca6fd246 38 USB_TYPE_BUFFER_OVERRUN_ERROR = 12,
va009039 0:148fca6fd246 39 USB_TYPE_BUFFER_UNDERRUN_ERROR = 13,
va009039 0:148fca6fd246 40
va009039 0:148fca6fd246 41 // general usb state
va009039 0:148fca6fd246 42 USB_TYPE_DISCONNECTED = 14,
va009039 0:148fca6fd246 43 USB_TYPE_FREE = 15,
va009039 0:148fca6fd246 44 USB_TYPE_IDLE = 16,
va009039 0:148fca6fd246 45 USB_TYPE_PROCESSING = 17,
va009039 0:148fca6fd246 46
va009039 0:148fca6fd246 47 USB_TYPE_ERROR = 18,
va009039 0:148fca6fd246 48 };
va009039 0:148fca6fd246 49
va009039 0:148fca6fd246 50
va009039 0:148fca6fd246 51 enum ENDPOINT_DIRECTION {
va009039 0:148fca6fd246 52 OUT = 1,
va009039 0:148fca6fd246 53 IN
va009039 0:148fca6fd246 54 };
va009039 0:148fca6fd246 55
va009039 0:148fca6fd246 56 enum ENDPOINT_TYPE {
va009039 0:148fca6fd246 57 CONTROL_ENDPOINT = 0,
va009039 0:148fca6fd246 58 ISOCHRONOUS_ENDPOINT,
va009039 0:148fca6fd246 59 BULK_ENDPOINT,
va009039 0:148fca6fd246 60 INTERRUPT_ENDPOINT
va009039 0:148fca6fd246 61 };
va009039 0:148fca6fd246 62
va009039 0:148fca6fd246 63 #define AUDIO_CLASS 0x01
va009039 0:148fca6fd246 64 #define CDC_CLASS 0x02
va009039 0:148fca6fd246 65 #define HID_CLASS 0x03
va009039 0:148fca6fd246 66 #define MSD_CLASS 0x08
va009039 0:148fca6fd246 67 #define HUB_CLASS 0x09
va009039 0:148fca6fd246 68 #define SERIAL_CLASS 0x0A
va009039 0:148fca6fd246 69
va009039 0:148fca6fd246 70 #define DEVICE_DESCRIPTOR (1)
va009039 0:148fca6fd246 71 #define CONFIGURATION_DESCRIPTOR (2)
va009039 0:148fca6fd246 72 #define INTERFACE_DESCRIPTOR (4)
va009039 0:148fca6fd246 73 #define ENDPOINT_DESCRIPTOR (5)
va009039 0:148fca6fd246 74 #define HID_DESCRIPTOR (33)
va009039 0:148fca6fd246 75
va009039 0:148fca6fd246 76 // ----------- Control RequestType Fields -----------
va009039 0:148fca6fd246 77 #define USB_DEVICE_TO_HOST 0x80
va009039 0:148fca6fd246 78 #define USB_HOST_TO_DEVICE 0x00
va009039 0:148fca6fd246 79 #define USB_REQUEST_TYPE_CLASS 0x20
va009039 0:148fca6fd246 80 #define USB_REQUEST_TYPE_STANDARD 0x00
va009039 0:148fca6fd246 81 #define USB_RECIPIENT_DEVICE 0x00
va009039 0:148fca6fd246 82 #define USB_RECIPIENT_INTERFACE 0x01
va009039 0:148fca6fd246 83 #define USB_RECIPIENT_ENDPOINT 0x02
va009039 0:148fca6fd246 84
va009039 0:148fca6fd246 85 // -------------- USB Standard Requests --------------
va009039 0:148fca6fd246 86 #define GET_STATUS 0x00
va009039 0:148fca6fd246 87 #define SET_FEATURE 0x03
va009039 0:148fca6fd246 88 #define SET_ADDRESS 0x05
va009039 0:148fca6fd246 89 #define GET_DESCRIPTOR 0x06
va009039 0:148fca6fd246 90 #define SET_CONFIGURATION 0x09
va009039 0:148fca6fd246 91 #define SET_INTERFACE 0x0b
va009039 0:148fca6fd246 92 #define CLEAR_FEATURE 0x01
va009039 0:148fca6fd246 93
va009039 0:148fca6fd246 94 // -------------- USB Descriptor Length --------------
va009039 0:148fca6fd246 95 #define DEVICE_DESCRIPTOR_LENGTH 0x12
va009039 0:148fca6fd246 96 #define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
va009039 0:148fca6fd246 97
va009039 0:148fca6fd246 98 // PID
va009039 0:148fca6fd246 99 #define DATA0 0x03
va009039 0:148fca6fd246 100 #define DATA1 0x0b
va009039 0:148fca6fd246 101 #define ACK 0x02
va009039 0:148fca6fd246 102 #define STALL 0x0e
va009039 0:148fca6fd246 103 #define NAK 0x0a
va009039 0:148fca6fd246 104
va009039 0:148fca6fd246 105 #pragma pack(push,1)
va009039 0:148fca6fd246 106 typedef struct {
va009039 0:148fca6fd246 107 uint8_t bLength;
va009039 0:148fca6fd246 108 uint8_t bDescriptorType;
va009039 0:148fca6fd246 109 uint16_t bcdUSB;
va009039 0:148fca6fd246 110 uint8_t bDeviceClass;
va009039 0:148fca6fd246 111 uint8_t bDeviceSubClass;
va009039 0:148fca6fd246 112 uint8_t bDeviceProtocol;
va009039 0:148fca6fd246 113 uint8_t bMaxPacketSize;
va009039 0:148fca6fd246 114 uint16_t idVendor;
va009039 0:148fca6fd246 115 uint16_t idProduct;
va009039 0:148fca6fd246 116 uint16_t bcdDevice;
va009039 0:148fca6fd246 117 uint8_t iManufacturer;
va009039 0:148fca6fd246 118 uint8_t iProduct;
va009039 0:148fca6fd246 119 uint8_t iSerialNumber;
va009039 0:148fca6fd246 120 uint8_t bNumConfigurations;
va009039 0:148fca6fd246 121 } PACKED DeviceDescriptor;
va009039 0:148fca6fd246 122
va009039 0:148fca6fd246 123 typedef struct {
va009039 0:148fca6fd246 124 uint8_t bLength;
va009039 0:148fca6fd246 125 uint8_t bDescriptorType;
va009039 0:148fca6fd246 126 uint16_t wTotalLength;
va009039 0:148fca6fd246 127 uint8_t bNumInterfaces;
va009039 0:148fca6fd246 128 uint8_t bConfigurationValue;
va009039 0:148fca6fd246 129 uint8_t iConfiguration;
va009039 0:148fca6fd246 130 uint8_t bmAttributes;
va009039 0:148fca6fd246 131 uint8_t bMaxPower;
va009039 0:148fca6fd246 132 } PACKED ConfigurationDescriptor;
va009039 0:148fca6fd246 133
va009039 0:148fca6fd246 134 typedef struct {
va009039 0:148fca6fd246 135 uint8_t bLength;
va009039 0:148fca6fd246 136 uint8_t bDescriptorType;
va009039 0:148fca6fd246 137 uint8_t bInterfaceNumber;
va009039 0:148fca6fd246 138 uint8_t bAlternateSetting;
va009039 0:148fca6fd246 139 uint8_t bNumEndpoints;
va009039 0:148fca6fd246 140 uint8_t bInterfaceClass;
va009039 0:148fca6fd246 141 uint8_t bInterfaceSubClass;
va009039 0:148fca6fd246 142 uint8_t bInterfaceProtocol;
va009039 0:148fca6fd246 143 uint8_t iInterface;
va009039 0:148fca6fd246 144 } InterfaceDescriptor;
va009039 0:148fca6fd246 145
va009039 0:148fca6fd246 146 typedef struct {
va009039 0:148fca6fd246 147 uint8_t bLength;
va009039 0:148fca6fd246 148 uint8_t bDescriptorType;
va009039 0:148fca6fd246 149 uint8_t bEndpointAddress;
va009039 0:148fca6fd246 150 uint8_t bmAttributes;
va009039 0:148fca6fd246 151 uint16_t wMaxPacketSize;
va009039 0:148fca6fd246 152 uint8_t bInterval;
va009039 0:148fca6fd246 153 } EndpointDescriptor;
va009039 0:148fca6fd246 154
va009039 0:148fca6fd246 155 typedef struct {
va009039 0:148fca6fd246 156 uint8_t bDescLength;
va009039 0:148fca6fd246 157 uint8_t bDescriptorType;
va009039 0:148fca6fd246 158 uint8_t bNbrPorts;
va009039 0:148fca6fd246 159 uint16_t wHubCharacteristics;
va009039 0:148fca6fd246 160 uint8_t bPwrOn2PwrGood;
va009039 0:148fca6fd246 161 uint8_t bHubContrCurrent;
va009039 0:148fca6fd246 162 uint8_t DeviceRemovable;
va009039 0:148fca6fd246 163 uint8_t PortPweCtrlMak;
va009039 0:148fca6fd246 164 } HubDescriptor;
va009039 0:148fca6fd246 165 #pragma pack(pop)
va009039 0:148fca6fd246 166
va009039 0:148fca6fd246 167 #endif