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 USBHOSTMOUSE_H
va009039 0:148fca6fd246 18 #define USBHOSTMOUSE_H
va009039 0:148fca6fd246 19
va009039 0:148fca6fd246 20 #include "USBHostConf.h"
va009039 0:148fca6fd246 21
va009039 0:148fca6fd246 22 #if USBHOST_MOUSE
va009039 0:148fca6fd246 23
va009039 0:148fca6fd246 24 #include "USBHost.h"
va009039 0:148fca6fd246 25
va009039 0:148fca6fd246 26 /**
va009039 0:148fca6fd246 27 * A class to communicate a USB mouse
va009039 0:148fca6fd246 28 */
va009039 0:148fca6fd246 29 class USBHostMouse : public IUSBEnumerator {
va009039 0:148fca6fd246 30 public:
va009039 0:148fca6fd246 31
va009039 0:148fca6fd246 32 /**
va009039 0:148fca6fd246 33 * Constructor
va009039 0:148fca6fd246 34 */
va009039 0:148fca6fd246 35 USBHostMouse();
va009039 0:148fca6fd246 36
va009039 0:148fca6fd246 37 /**
va009039 0:148fca6fd246 38 * Try to connect a mouse device
va009039 0:148fca6fd246 39 *
va009039 0:148fca6fd246 40 * @return true if connection was successful
va009039 0:148fca6fd246 41 */
va009039 0:148fca6fd246 42 bool connect();
va009039 0:148fca6fd246 43
va009039 0:148fca6fd246 44 /**
va009039 0:148fca6fd246 45 * Check if a mouse is connected
va009039 0:148fca6fd246 46 *
va009039 0:148fca6fd246 47 * @returns true if a mouse is connected
va009039 0:148fca6fd246 48 */
va009039 0:148fca6fd246 49 bool connected();
va009039 0:148fca6fd246 50
va009039 0:148fca6fd246 51 /**
va009039 0:148fca6fd246 52 * Attach a callback called when a mouse event is received
va009039 0:148fca6fd246 53 *
va009039 0:148fca6fd246 54 * @param ptr function pointer
va009039 0:148fca6fd246 55 */
va009039 0:148fca6fd246 56 inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) {
va009039 0:148fca6fd246 57 if (ptr != NULL) {
va009039 0:148fca6fd246 58 onUpdate = ptr;
Grag38 1:d652de69bd1a 59 printf(" OnUpdate ok %p", ptr);
va009039 0:148fca6fd246 60 }
va009039 0:148fca6fd246 61 }
va009039 0:148fca6fd246 62
va009039 0:148fca6fd246 63 /**
va009039 0:148fca6fd246 64 * Attach a callback called when the button state changes
va009039 0:148fca6fd246 65 *
va009039 0:148fca6fd246 66 * @param ptr function pointer
va009039 0:148fca6fd246 67 */
va009039 0:148fca6fd246 68 inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) {
va009039 0:148fca6fd246 69 if (ptr != NULL) {
va009039 0:148fca6fd246 70 onButtonUpdate = ptr;
va009039 0:148fca6fd246 71 }
va009039 0:148fca6fd246 72 }
va009039 0:148fca6fd246 73
va009039 0:148fca6fd246 74 /**
va009039 0:148fca6fd246 75 * Attach a callback called when the X axis value changes
va009039 0:148fca6fd246 76 *
va009039 0:148fca6fd246 77 * @param ptr function pointer
va009039 0:148fca6fd246 78 */
va009039 0:148fca6fd246 79 inline void attachXEvent(void (*ptr)(int8_t x)) {
va009039 0:148fca6fd246 80 if (ptr != NULL) {
va009039 0:148fca6fd246 81 onXUpdate = ptr;
va009039 0:148fca6fd246 82 }
va009039 0:148fca6fd246 83 }
va009039 0:148fca6fd246 84
va009039 0:148fca6fd246 85 /**
va009039 0:148fca6fd246 86 * Attach a callback called when the Y axis value changes
va009039 0:148fca6fd246 87 *
va009039 0:148fca6fd246 88 * @param ptr function pointer
va009039 0:148fca6fd246 89 */
va009039 0:148fca6fd246 90 inline void attachYEvent(void (*ptr)(int8_t y)) {
va009039 0:148fca6fd246 91 if (ptr != NULL) {
va009039 0:148fca6fd246 92 onYUpdate = ptr;
va009039 0:148fca6fd246 93 }
va009039 0:148fca6fd246 94 }
va009039 0:148fca6fd246 95
va009039 0:148fca6fd246 96 /**
va009039 0:148fca6fd246 97 * Attach a callback called when the Z axis value changes (scrolling)
va009039 0:148fca6fd246 98 *
va009039 0:148fca6fd246 99 * @param ptr function pointer
va009039 0:148fca6fd246 100 */
va009039 0:148fca6fd246 101 inline void attachZEvent(void (*ptr)(int8_t z)) {
va009039 0:148fca6fd246 102 if (ptr != NULL) {
va009039 0:148fca6fd246 103 onZUpdate = ptr;
va009039 0:148fca6fd246 104 }
va009039 0:148fca6fd246 105 }
va009039 0:148fca6fd246 106
va009039 0:148fca6fd246 107 protected:
va009039 0:148fca6fd246 108 //From IUSBEnumerator
va009039 0:148fca6fd246 109 virtual void setVidPid(uint16_t vid, uint16_t pid);
va009039 0:148fca6fd246 110 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
va009039 0:148fca6fd246 111 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
va009039 0:148fca6fd246 112
Grag38 1:d652de69bd1a 113 public:
va009039 0:148fca6fd246 114 USBHost * host;
va009039 0:148fca6fd246 115 USBDeviceConnected * dev;
va009039 0:148fca6fd246 116 USBEndpoint * int_in;
va009039 0:148fca6fd246 117 uint8_t report[4];
va009039 0:148fca6fd246 118
va009039 0:148fca6fd246 119 bool dev_connected;
va009039 0:148fca6fd246 120 bool mouse_device_found;
va009039 0:148fca6fd246 121 int mouse_intf;
va009039 0:148fca6fd246 122
va009039 0:148fca6fd246 123 uint8_t buttons;
va009039 0:148fca6fd246 124 int8_t x;
va009039 0:148fca6fd246 125 int8_t y;
va009039 0:148fca6fd246 126 int8_t z;
va009039 0:148fca6fd246 127
va009039 0:148fca6fd246 128 void rxHandler();
va009039 0:148fca6fd246 129 void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z);
va009039 0:148fca6fd246 130 void (*onButtonUpdate)(uint8_t buttons);
va009039 0:148fca6fd246 131 void (*onXUpdate)(int8_t x);
va009039 0:148fca6fd246 132 void (*onYUpdate)(int8_t y);
va009039 0:148fca6fd246 133 void (*onZUpdate)(int8_t z);
va009039 0:148fca6fd246 134 int report_id;
va009039 0:148fca6fd246 135 void init();
va009039 0:148fca6fd246 136 };
va009039 0:148fca6fd246 137
va009039 0:148fca6fd246 138 #endif
va009039 0:148fca6fd246 139
va009039 0:148fca6fd246 140 #endif