USBDevice for STM support

Dependents:   Nucleo_Usb_JoyMouse Nucleo_usbmouse ELEC350_1-referral-2018-usb-hid USBJoystick_HelloWorld2_wip ... more

This library contains all mbed usb device library (mbed-os\features\unsupported\USBDevice).

Committer:
frq08711@LMECWL0871.LME.ST.COM
Date:
Tue Mar 28 11:00:57 2017 +0200
Branch:
master
Revision:
4:50ec00aa4515
Parent:
1:2a3ae13b45ef
update for 5.4.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 2 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 4 * and associated documentation files (the "Software"), to deal in the Software without
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 7 * Software is furnished to do so, subject to the following conditions:
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 8 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 9 * The above copyright notice and this permission notice shall be included in all copies or
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 10 * substantial portions of the Software.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 11 *
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 17 */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 18
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 19 #ifndef USBCLASS_HID_TYPES
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 20 #define USBCLASS_HID_TYPES
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 21
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 22 #include <stdint.h>
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 23
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 24 /* */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 25 #define HID_VERSION_1_11 (0x0111)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 26
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 27 /* HID Class */
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 28 #define HID_CLASS (3)
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 29 #define HID_SUBCLASS_NONE (0)
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 30 #define HID_SUBCLASS_BOOT (1)
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 31 #define HID_PROTOCOL_NONE (0)
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 32 #define HID_PROTOCOL_KEYBOARD (1)
frq08711@LMECWL0871.LME.ST.COM 4:50ec00aa4515 33 #define HID_PROTOCOL_MOUSE (2)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 34
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 35 /* Descriptors */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 36 #define HID_DESCRIPTOR (33)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 37 #define HID_DESCRIPTOR_LENGTH (0x09)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 38 #define REPORT_DESCRIPTOR (34)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 39
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 40 /* Class requests */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 41 #define GET_REPORT (0x1)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 42 #define GET_IDLE (0x2)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 43 #define SET_REPORT (0x9)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 44 #define SET_IDLE (0xa)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 45
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 46 /* HID Class Report Descriptor */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 47 /* Short items: size is 0, 1, 2 or 3 specifying 0, 1, 2 or 4 (four) bytes */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 48 /* of data as per HID Class standard */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 49
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 50 /* Main items */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 51 #define INPUT(size) (0x80 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 52 #define OUTPUT(size) (0x90 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 53 #define FEATURE(size) (0xb0 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 54 #define COLLECTION(size) (0xa0 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 55 #define END_COLLECTION(size) (0xc0 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 56
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 57 /* Global items */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 58 #define USAGE_PAGE(size) (0x04 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 59 #define LOGICAL_MINIMUM(size) (0x14 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 60 #define LOGICAL_MAXIMUM(size) (0x24 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 61 #define PHYSICAL_MINIMUM(size) (0x34 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 62 #define PHYSICAL_MAXIMUM(size) (0x44 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 63 #define UNIT_EXPONENT(size) (0x54 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 64 #define UNIT(size) (0x64 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 65 #define REPORT_SIZE(size) (0x74 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 66 #define REPORT_ID(size) (0x84 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 67 #define REPORT_COUNT(size) (0x94 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 68 #define PUSH(size) (0xa4 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 69 #define POP(size) (0xb4 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 70
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 71 /* Local items */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 72 #define USAGE(size) (0x08 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 73 #define USAGE_MINIMUM(size) (0x18 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 74 #define USAGE_MAXIMUM(size) (0x28 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 75 #define DESIGNATOR_INDEX(size) (0x38 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 76 #define DESIGNATOR_MINIMUM(size) (0x48 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 77 #define DESIGNATOR_MAXIMUM(size) (0x58 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 78 #define STRING_INDEX(size) (0x78 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 79 #define STRING_MINIMUM(size) (0x88 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 80 #define STRING_MAXIMUM(size) (0x98 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 81 #define DELIMITER(size) (0xa8 | size)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 82
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 83 /* HID Report */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 84 /* Where report IDs are used the first byte of 'data' will be the */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 85 /* report ID and 'length' will include this report ID byte. */
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 86
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 87 #define MAX_HID_REPORT_SIZE (64)
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 88
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 89 typedef struct {
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 90 uint32_t length;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 91 uint8_t data[MAX_HID_REPORT_SIZE];
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 92 } HID_REPORT;
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 93
frq08711@LMECWL0871.LME.ST.COM 1:2a3ae13b45ef 94 #endif