Simple USBHost library for LPC4088. Backward compatibility of official-USBHost.

Dependencies:   FATFileSystem mbed-rtos

EA LPC4088 QSB専用の簡易USBホストライブラリです。
official-USBHostの下位互換で対応プログラムを僅かな修正で動かすことが出来ます。
examples:

Import programLPC4088-USBHostMSD_HelloWorld

Simple USBHost MSD(USB flash drive) for EA LPC4088 QSB test program

Import programLPC4088-BTstack_example

BTstack for EA LPC4088 QSB example program

Import programLPC4088-USBHostC270_example

Simple USBHost WebCam for EA LPC4088 QSB/LPC1768 test program

Committer:
va009039
Date:
Fri Apr 25 05:18:55 2014 +0000
Revision:
0:148fca6fd246
first commit

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 USBHOSTKEYBOARD_H
va009039 0:148fca6fd246 18 #define USBHOSTKEYBOARD_H
va009039 0:148fca6fd246 19
va009039 0:148fca6fd246 20 #include "USBHostConf.h"
va009039 0:148fca6fd246 21
va009039 0:148fca6fd246 22 #if USBHOST_KEYBOARD
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 keyboard
va009039 0:148fca6fd246 28 */
va009039 0:148fca6fd246 29 class USBHostKeyboard : 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 USBHostKeyboard();
va009039 0:148fca6fd246 36
va009039 0:148fca6fd246 37 /**
va009039 0:148fca6fd246 38 * Try to connect a keyboard 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 keyboard is connected
va009039 0:148fca6fd246 46 *
va009039 0:148fca6fd246 47 * @returns true if a keyboard 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 keyboard 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 attach(void (*ptr)(uint8_t key)) {
va009039 0:148fca6fd246 57 if (ptr != NULL) {
va009039 0:148fca6fd246 58 onKey = ptr;
va009039 0:148fca6fd246 59 }
va009039 0:148fca6fd246 60 }
va009039 0:148fca6fd246 61
va009039 0:148fca6fd246 62 /**
va009039 0:148fca6fd246 63 * Attach a callback called when a keyboard event is received
va009039 0:148fca6fd246 64 *
va009039 0:148fca6fd246 65 * @param ptr function pointer
va009039 0:148fca6fd246 66 */
va009039 0:148fca6fd246 67 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier)) {
va009039 0:148fca6fd246 68 if (ptr != NULL) {
va009039 0:148fca6fd246 69 onKeyCode = ptr;
va009039 0:148fca6fd246 70 }
va009039 0:148fca6fd246 71 }
va009039 0:148fca6fd246 72
va009039 0:148fca6fd246 73 protected:
va009039 0:148fca6fd246 74 //From IUSBEnumerator
va009039 0:148fca6fd246 75 virtual void setVidPid(uint16_t vid, uint16_t pid);
va009039 0:148fca6fd246 76 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 77 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 78
va009039 0:148fca6fd246 79 private:
va009039 0:148fca6fd246 80 USBHost * host;
va009039 0:148fca6fd246 81 USBDeviceConnected * dev;
va009039 0:148fca6fd246 82 USBEndpoint * int_in;
va009039 0:148fca6fd246 83 uint8_t report[9];
va009039 0:148fca6fd246 84 int keyboard_intf;
va009039 0:148fca6fd246 85 bool keyboard_device_found;
va009039 0:148fca6fd246 86
va009039 0:148fca6fd246 87 bool dev_connected;
va009039 0:148fca6fd246 88
va009039 0:148fca6fd246 89 void rxHandler();
va009039 0:148fca6fd246 90
va009039 0:148fca6fd246 91 void (*onKey)(uint8_t key);
va009039 0:148fca6fd246 92 void (*onKeyCode)(uint8_t key, uint8_t modifier);
va009039 0:148fca6fd246 93
va009039 0:148fca6fd246 94 int report_id;
va009039 0:148fca6fd246 95
va009039 0:148fca6fd246 96 void init();
va009039 0:148fca6fd246 97
va009039 0:148fca6fd246 98 };
va009039 0:148fca6fd246 99
va009039 0:148fca6fd246 100 #endif
va009039 0:148fca6fd246 101
va009039 0:148fca6fd246 102 #endif