USBDevice stack

Dependents:   erg USBSerial_HelloWorld Slingshot SuperScanner ... more

Committer:
samux
Date:
Wed May 30 18:28:11 2012 +0000
Revision:
0:140cdf8e2d60

        

Who changed what in which revision?

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