usb device

Committer:
ppo
Date:
Sat May 14 17:24:10 2022 +0000
Revision:
0:c1e89c49eae5
commit

Who changed what in which revision?

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