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 #include "USBDeviceConnected.h"
va009039 0:148fca6fd246 18 #include "dbg.h"
va009039 0:148fca6fd246 19
va009039 0:148fca6fd246 20 USBDeviceConnected::USBDeviceConnected() {
va009039 0:148fca6fd246 21 init();
va009039 0:148fca6fd246 22 }
va009039 0:148fca6fd246 23
va009039 0:148fca6fd246 24 void USBDeviceConnected::init() {
va009039 0:148fca6fd246 25 port = 0;
va009039 0:148fca6fd246 26 vid = 0;
va009039 0:148fca6fd246 27 pid = 0;
va009039 0:148fca6fd246 28 nb_interf = 0;
va009039 0:148fca6fd246 29 enumerated = false;
va009039 0:148fca6fd246 30 device_class = 0;
va009039 0:148fca6fd246 31 device_subclass = 0;
va009039 0:148fca6fd246 32 proto = 0;
va009039 0:148fca6fd246 33 lowSpeed = false;
va009039 0:148fca6fd246 34 hub_parent = NULL;
va009039 0:148fca6fd246 35 }
va009039 0:148fca6fd246 36
va009039 0:148fca6fd246 37 bool USBDeviceConnected::addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) {
va009039 0:148fca6fd246 38 USB_DBG("intf_nb=%d", intf_nb);
va009039 0:148fca6fd246 39 if (intf.count(intf_nb) > 0) {
va009039 0:148fca6fd246 40 return false;
va009039 0:148fca6fd246 41 }
va009039 0:148fca6fd246 42 intf[intf_nb] = new INTERFACE(intf_class, intf_subclass, intf_protocol);
va009039 0:148fca6fd246 43 return true;
va009039 0:148fca6fd246 44 }
va009039 0:148fca6fd246 45
va009039 0:148fca6fd246 46 bool USBDeviceConnected::addEndpoint(uint8_t intf_nb, USBEndpoint * ept) {
va009039 0:148fca6fd246 47 if (intf.count(intf_nb) > 0) {
va009039 0:148fca6fd246 48 intf[intf_nb]->ep.push_back(ept);
va009039 0:148fca6fd246 49 return true;
va009039 0:148fca6fd246 50 }
va009039 0:148fca6fd246 51 return false;
va009039 0:148fca6fd246 52 }
va009039 0:148fca6fd246 53
va009039 0:148fca6fd246 54 void USBDeviceConnected::init(USBDeviceConnected* parent, uint8_t port_, bool lowSpeed_) {
va009039 0:148fca6fd246 55 USB_DBG("init dev: %p", this);
va009039 0:148fca6fd246 56 init();
va009039 0:148fca6fd246 57 hub_parent = parent;
va009039 0:148fca6fd246 58 port = port_;
va009039 0:148fca6fd246 59 lowSpeed = lowSpeed_;
va009039 0:148fca6fd246 60 }
va009039 0:148fca6fd246 61
va009039 0:148fca6fd246 62 void USBDeviceConnected::disconnect() {
va009039 0:148fca6fd246 63 //for(int i = 0; i < MAX_INTF; i++) {
va009039 0:148fca6fd246 64 // intf[i].detach.call();
va009039 0:148fca6fd246 65 //}
va009039 0:148fca6fd246 66 //init();
va009039 0:148fca6fd246 67 }
va009039 0:148fca6fd246 68
va009039 0:148fca6fd246 69
va009039 0:148fca6fd246 70 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index) {
va009039 0:148fca6fd246 71 USB_DBG("intf_nb=%d", intf_nb);
va009039 0:148fca6fd246 72 USB_TEST_ASSERT(intf.count(intf_nb) > 0);
va009039 0:148fca6fd246 73 INTERFACE* inter = intf[intf_nb];
va009039 0:148fca6fd246 74 for (int i = 0; i < inter->ep.size(); i++) {
va009039 0:148fca6fd246 75 if ((inter->ep[i]->getType() == type) && (inter->ep[i]->getDir() == dir)) {
va009039 0:148fca6fd246 76 if(index) {
va009039 0:148fca6fd246 77 index--;
va009039 0:148fca6fd246 78 } else {
va009039 0:148fca6fd246 79 return inter->ep[i];
va009039 0:148fca6fd246 80 }
va009039 0:148fca6fd246 81 }
va009039 0:148fca6fd246 82 }
va009039 0:148fca6fd246 83 return NULL;
va009039 0:148fca6fd246 84 }
va009039 0:148fca6fd246 85
va009039 0:148fca6fd246 86 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, uint8_t index) {
va009039 0:148fca6fd246 87 USB_TEST_ASSERT(intf.count(intf_nb) > 0);
va009039 0:148fca6fd246 88 return intf[intf_nb]->ep[index];
va009039 0:148fca6fd246 89 }