HID-over-GATT implementation with the BLE API. This library allows to create devices such as mouse, keyboard or joystick, over Bluetooth Low Energy.
Dependents: BLENano_HID BLE_HID_MouseScrollDemo BLE_HID_KeyboardStreamDemo Shervs_TestKeyboard_TinyBLE ... more
The development repository is currently hosted on github. It contains examples and documentation. This is a snapshot of the library. The documentation can be read on github, or on docs.mbed.com.
HID_types.h@0:cfd70fa91663, 2015-09-15 (annotated)
- Committer:
- Jean-Philippe Brucker
- Date:
- Tue Sep 15 20:16:58 2015 +0100
- Revision:
- 0:cfd70fa91663
- Child:
- 1:7a6c2e2c9371
Initial version
Provides all the components for an HID-over-GATT Profile implementation using
BLE API.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jean-Philippe Brucker |
0:cfd70fa91663 | 1 | /* mbed Microcontroller Library |
Jean-Philippe Brucker |
0:cfd70fa91663 | 2 | * Copyright (c) 2006-2013 ARM Limited |
Jean-Philippe Brucker |
0:cfd70fa91663 | 3 | * |
Jean-Philippe Brucker |
0:cfd70fa91663 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Jean-Philippe Brucker |
0:cfd70fa91663 | 5 | * you may not use this file except in compliance with the License. |
Jean-Philippe Brucker |
0:cfd70fa91663 | 6 | * You may obtain a copy of the License at |
Jean-Philippe Brucker |
0:cfd70fa91663 | 7 | * |
Jean-Philippe Brucker |
0:cfd70fa91663 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jean-Philippe Brucker |
0:cfd70fa91663 | 9 | * |
Jean-Philippe Brucker |
0:cfd70fa91663 | 10 | * Unless required by applicable law or agreed to in writing, software |
Jean-Philippe Brucker |
0:cfd70fa91663 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Jean-Philippe Brucker |
0:cfd70fa91663 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Jean-Philippe Brucker |
0:cfd70fa91663 | 13 | * See the License for the specific language governing permissions and |
Jean-Philippe Brucker |
0:cfd70fa91663 | 14 | * limitations under the License. |
Jean-Philippe Brucker |
0:cfd70fa91663 | 15 | */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 16 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 17 | #ifndef USBCLASS_HID_TYPES |
Jean-Philippe Brucker |
0:cfd70fa91663 | 18 | #define USBCLASS_HID_TYPES |
Jean-Philippe Brucker |
0:cfd70fa91663 | 19 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 20 | #include <stdint.h> |
Jean-Philippe Brucker |
0:cfd70fa91663 | 21 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 22 | #pragma pack(push, 1) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 23 | typedef struct { |
Jean-Philippe Brucker |
0:cfd70fa91663 | 24 | uint8_t vendorID_source; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 25 | uint16_t vendorID; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 26 | uint16_t productID; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 27 | uint16_t productVersion; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 28 | } PnPID_t; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 29 | #pragma pack(pop) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 30 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 31 | /* */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 32 | #define HID_VERSION_1_11 (0x0111) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 33 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 34 | /* HID Class */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 35 | #define HID_CLASS (3) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 36 | #define HID_SUBCLASS_NONE (0) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 37 | #define HID_PROTOCOL_NONE (0) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 38 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 39 | /* Descriptors */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 40 | #define HID_DESCRIPTOR (33) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 41 | #define HID_DESCRIPTOR_LENGTH (0x09) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 42 | #define REPORT_DESCRIPTOR (34) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 43 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 44 | /* Class requests */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 45 | #define GET_REPORT (0x1) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 46 | #define GET_IDLE (0x2) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 47 | #define SET_REPORT (0x9) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 48 | #define SET_IDLE (0xa) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 49 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 50 | /* HID Class Report Descriptor */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 51 | /* Short items: size is 0, 1, 2 or 3 specifying 0, 1, 2 or 4 (four) bytes */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 52 | /* of data as per HID Class standard */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 53 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 54 | /* Main items */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 55 | #define INPUT(size) (0x80 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 56 | #define OUTPUT(size) (0x90 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 57 | #define FEATURE(size) (0xb0 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 58 | #define COLLECTION(size) (0xa0 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 59 | #define END_COLLECTION(size) (0xc0 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 60 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 61 | /* Global items */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 62 | #define USAGE_PAGE(size) (0x04 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 63 | #define LOGICAL_MINIMUM(size) (0x14 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 64 | #define LOGICAL_MAXIMUM(size) (0x24 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 65 | #define PHYSICAL_MINIMUM(size) (0x34 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 66 | #define PHYSICAL_MAXIMUM(size) (0x44 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 67 | #define UNIT_EXPONENT(size) (0x54 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 68 | #define UNIT(size) (0x64 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 69 | #define REPORT_SIZE(size) (0x74 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 70 | #define REPORT_ID(size) (0x84 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 71 | #define REPORT_COUNT(size) (0x94 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 72 | #define PUSH(size) (0xa4 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 73 | #define POP(size) (0xb4 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 74 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 75 | /* Local items */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 76 | #define USAGE(size) (0x08 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 77 | #define USAGE_MINIMUM(size) (0x18 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 78 | #define USAGE_MAXIMUM(size) (0x28 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 79 | #define DESIGNATOR_INDEX(size) (0x38 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 80 | #define DESIGNATOR_MINIMUM(size) (0x48 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 81 | #define DESIGNATOR_MAXIMUM(size) (0x58 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 82 | #define STRING_INDEX(size) (0x78 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 83 | #define STRING_MINIMUM(size) (0x88 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 84 | #define STRING_MAXIMUM(size) (0x98 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 85 | #define DELIMITER(size) (0xa8 | size) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 86 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 87 | /* HID Report */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 88 | /* Where report IDs are used the first byte of 'data' will be the */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 89 | /* report ID and 'length' will include this report ID byte. */ |
Jean-Philippe Brucker |
0:cfd70fa91663 | 90 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 91 | #define MAX_HID_REPORT_SIZE (64) |
Jean-Philippe Brucker |
0:cfd70fa91663 | 92 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 93 | typedef struct { |
Jean-Philippe Brucker |
0:cfd70fa91663 | 94 | uint32_t length; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 95 | uint8_t data[MAX_HID_REPORT_SIZE]; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 96 | } HID_REPORT; |
Jean-Philippe Brucker |
0:cfd70fa91663 | 97 | |
Jean-Philippe Brucker |
0:cfd70fa91663 | 98 | #endif |
Jean-Philippe Brucker |
0:cfd70fa91663 | 99 |