ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Committer:
cho45
Date:
Thu Sep 15 09:31:05 2016 +0900
Revision:
86:e0fab77e669d
Parent:
54:899fc2b0a76b
support consumer keys

Who changed what in which revision?

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