Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:3a9487d57a5c 1 /* mbed USBHost Library
thedo 166:3a9487d57a5c 2 * Copyright (c) 2006-2013 ARM Limited
thedo 166:3a9487d57a5c 3 *
thedo 166:3a9487d57a5c 4 * Licensed under the Apache License, Version 2.0 (the "License");
thedo 166:3a9487d57a5c 5 * you may not use this file except in compliance with the License.
thedo 166:3a9487d57a5c 6 * You may obtain a copy of the License at
thedo 166:3a9487d57a5c 7 *
thedo 166:3a9487d57a5c 8 * http://www.apache.org/licenses/LICENSE-2.0
thedo 166:3a9487d57a5c 9 *
thedo 166:3a9487d57a5c 10 * Unless required by applicable law or agreed to in writing, software
thedo 166:3a9487d57a5c 11 * distributed under the License is distributed on an "AS IS" BASIS,
thedo 166:3a9487d57a5c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
thedo 166:3a9487d57a5c 13 * See the License for the specific language governing permissions and
thedo 166:3a9487d57a5c 14 * limitations under the License.
thedo 166:3a9487d57a5c 15 */
thedo 166:3a9487d57a5c 16
thedo 166:3a9487d57a5c 17 #ifndef USBHOSTKEYBOARD_H
thedo 166:3a9487d57a5c 18 #define USBHOSTKEYBOARD_H
thedo 166:3a9487d57a5c 19
thedo 166:3a9487d57a5c 20 #include "USBHostConf.h"
thedo 166:3a9487d57a5c 21
thedo 166:3a9487d57a5c 22 #if USBHOST_KEYBOARD
thedo 166:3a9487d57a5c 23
thedo 166:3a9487d57a5c 24 #include "USBHost.h"
thedo 166:3a9487d57a5c 25
thedo 166:3a9487d57a5c 26 /**
thedo 166:3a9487d57a5c 27 * A class to communicate a USB keyboard
thedo 166:3a9487d57a5c 28 */
thedo 166:3a9487d57a5c 29 class USBHostKeyboard : public IUSBEnumerator {
thedo 166:3a9487d57a5c 30 public:
thedo 166:3a9487d57a5c 31
thedo 166:3a9487d57a5c 32 /**
thedo 166:3a9487d57a5c 33 * Constructor
thedo 166:3a9487d57a5c 34 */
thedo 166:3a9487d57a5c 35 USBHostKeyboard();
thedo 166:3a9487d57a5c 36
thedo 166:3a9487d57a5c 37 /**
thedo 166:3a9487d57a5c 38 * Try to connect a keyboard device
thedo 166:3a9487d57a5c 39 *
thedo 166:3a9487d57a5c 40 * @return true if connection was successful
thedo 166:3a9487d57a5c 41 */
thedo 166:3a9487d57a5c 42 bool connect();
thedo 166:3a9487d57a5c 43
thedo 166:3a9487d57a5c 44 /**
thedo 166:3a9487d57a5c 45 * Check if a keyboard is connected
thedo 166:3a9487d57a5c 46 *
thedo 166:3a9487d57a5c 47 * @returns true if a keyboard is connected
thedo 166:3a9487d57a5c 48 */
thedo 166:3a9487d57a5c 49 bool connected();
thedo 166:3a9487d57a5c 50
thedo 166:3a9487d57a5c 51 /**
thedo 166:3a9487d57a5c 52 * Attach a callback called when a keyboard event is received
thedo 166:3a9487d57a5c 53 *
thedo 166:3a9487d57a5c 54 * @param ptr function pointer
thedo 166:3a9487d57a5c 55 */
thedo 166:3a9487d57a5c 56 inline void attach(void (*ptr)(uint8_t key)) {
thedo 166:3a9487d57a5c 57 if (ptr != NULL) {
thedo 166:3a9487d57a5c 58 onKey = ptr;
thedo 166:3a9487d57a5c 59 }
thedo 166:3a9487d57a5c 60 }
thedo 166:3a9487d57a5c 61
thedo 166:3a9487d57a5c 62 /**
thedo 166:3a9487d57a5c 63 * Attach a callback called when a keyboard event is received
thedo 166:3a9487d57a5c 64 *
thedo 166:3a9487d57a5c 65 * @param ptr function pointer
thedo 166:3a9487d57a5c 66 */
thedo 166:3a9487d57a5c 67 inline void attach(void (*ptr)(uint8_t keyCode, uint8_t modifier)) {
thedo 166:3a9487d57a5c 68 if (ptr != NULL) {
thedo 166:3a9487d57a5c 69 onKeyCode = ptr;
thedo 166:3a9487d57a5c 70 }
thedo 166:3a9487d57a5c 71 }
thedo 166:3a9487d57a5c 72
thedo 166:3a9487d57a5c 73 protected:
thedo 166:3a9487d57a5c 74 //From IUSBEnumerator
thedo 166:3a9487d57a5c 75 virtual void setVidPid(uint16_t vid, uint16_t pid);
thedo 166:3a9487d57a5c 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
thedo 166:3a9487d57a5c 77 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
thedo 166:3a9487d57a5c 78
thedo 166:3a9487d57a5c 79 private:
thedo 166:3a9487d57a5c 80 USBHost * host;
thedo 166:3a9487d57a5c 81 USBDeviceConnected * dev;
thedo 166:3a9487d57a5c 82 USBEndpoint * int_in;
thedo 166:3a9487d57a5c 83 uint8_t report[9];
thedo 166:3a9487d57a5c 84 int keyboard_intf;
thedo 166:3a9487d57a5c 85 bool keyboard_device_found;
thedo 166:3a9487d57a5c 86
thedo 166:3a9487d57a5c 87 bool dev_connected;
thedo 166:3a9487d57a5c 88
thedo 166:3a9487d57a5c 89 void rxHandler();
thedo 166:3a9487d57a5c 90
thedo 166:3a9487d57a5c 91 void (*onKey)(uint8_t key);
thedo 166:3a9487d57a5c 92 void (*onKeyCode)(uint8_t key, uint8_t modifier);
thedo 166:3a9487d57a5c 93
thedo 166:3a9487d57a5c 94 int report_id;
thedo 166:3a9487d57a5c 95
thedo 166:3a9487d57a5c 96 void init();
thedo 166:3a9487d57a5c 97
thedo 166:3a9487d57a5c 98 };
thedo 166:3a9487d57a5c 99
thedo 166:3a9487d57a5c 100 #endif
thedo 166:3a9487d57a5c 101
thedo 166:3a9487d57a5c 102 #endif