back up of work during May 2019

Dependencies:   microbit

Committer:
tht216
Date:
Wed Jun 05 15:21:14 2019 +0000
Branch:
class_implmentation
Revision:
6:f372773ad32f
Parent:
1:c840c2b6f490
TODO:; 1. multi keypresses; 2. integration

Who changed what in which revision?

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