Added TARGET_DISCO_F469NI in USBHOST\USBHost\TARGET_STM\USBHALHost_STM_TARGET.h
Dependents: DISCO-F469NI_USB_Disk STM32F4xx_USB_Memory
Fork of USBHOST by
USBHostHID/USBHostMouse.h@8:3e7a33f81048, 2020-01-04 (annotated)
- Committer:
- kenjiArai
- Date:
- Sat Jan 04 23:30:59 2020 +0000
- Revision:
- 8:3e7a33f81048
- Parent:
- 5:fc157e6bd5a5
updated for STM32F4xx
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1 | /* mbed USBHost Library |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2 | * Copyright (c) 2006-2013 ARM Limited |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 3 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 5 | * you may not use this file except in compliance with the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 6 | * You may obtain a copy of the License at |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 7 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 9 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 10 | * Unless required by applicable law or agreed to in writing, software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 13 | * See the License for the specific language governing permissions and |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 14 | * limitations under the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 15 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 16 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 17 | #ifndef USBHOSTMOUSE_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 18 | #define USBHOSTMOUSE_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 19 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 20 | #include "USBHostConf.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 21 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 22 | #if USBHOST_MOUSE |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 23 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 24 | #include "USBHost.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 25 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 26 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 27 | * A class to communicate a USB mouse |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 28 | */ |
kenjiArai | 8:3e7a33f81048 | 29 | class USBHostMouse : public IUSBEnumerator |
kenjiArai | 8:3e7a33f81048 | 30 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 31 | public: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 32 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 33 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 34 | * Constructor |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 35 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 36 | USBHostMouse(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 37 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 38 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 39 | * Try to connect a mouse device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 40 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | * @return true if connection was successful |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | bool connect(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 46 | * Check if a mouse is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 47 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 48 | * @returns true if a mouse is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 49 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | bool connected(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 51 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 52 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 53 | * Attach a callback called when a mouse event is received |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 54 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 56 | */ |
kenjiArai | 8:3e7a33f81048 | 57 | inline void attachEvent(void (*ptr)(uint8_t buttons, int8_t x, int8_t y, int8_t z)) |
kenjiArai | 8:3e7a33f81048 | 58 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 59 | if (ptr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | onUpdate = ptr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 61 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 62 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | * Attach a callback called when the button state changes |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | */ |
kenjiArai | 8:3e7a33f81048 | 69 | inline void attachButtonEvent(void (*ptr)(uint8_t buttons)) |
kenjiArai | 8:3e7a33f81048 | 70 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | if (ptr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | onButtonUpdate = ptr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | * Attach a callback called when the X axis value changes |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | */ |
kenjiArai | 8:3e7a33f81048 | 81 | inline void attachXEvent(void (*ptr)(int8_t x)) |
kenjiArai | 8:3e7a33f81048 | 82 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | if (ptr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | onXUpdate = ptr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | * Attach a callback called when the Y axis value changes |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | */ |
kenjiArai | 8:3e7a33f81048 | 93 | inline void attachYEvent(void (*ptr)(int8_t y)) |
kenjiArai | 8:3e7a33f81048 | 94 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | if (ptr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | onYUpdate = ptr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | * Attach a callback called when the Z axis value changes (scrolling) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | */ |
kenjiArai | 8:3e7a33f81048 | 105 | inline void attachZEvent(void (*ptr)(int8_t z)) |
kenjiArai | 8:3e7a33f81048 | 106 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | if (ptr != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | onZUpdate = ptr; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | protected: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | //From IUSBEnumerator |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | 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 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | private: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | USBHost * host; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | USBDeviceConnected * dev; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | USBEndpoint * int_in; |
frq08711@LMECWL0871.LME.ST.COM | 5:fc157e6bd5a5 | 122 | uint8_t report[64]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | bool dev_connected; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | bool mouse_device_found; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | int mouse_intf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | uint8_t buttons; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | int8_t x; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | int8_t y; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | int8_t z; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | void rxHandler(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | void (*onUpdate)(uint8_t buttons, int8_t x, int8_t y, int8_t z); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | void (*onButtonUpdate)(uint8_t buttons); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | void (*onXUpdate)(int8_t x); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | void (*onYUpdate)(int8_t y); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | void (*onZUpdate)(int8_t z); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | int report_id; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | void init(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | #endif |