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