Based on the example USB HID keyboard https://developer.mbed.org/users/jbru/code/BLE_HID_KeyboardStreamDemo/

Dependencies:   BLE_API mbed nRF51822

Fork of HID-kb by Microbug

Committer:
JonnyA
Date:
Wed Nov 14 09:46:45 2018 +0000
Revision:
3:7d7822143a2d
Parent:
0:cb1939018833
Add simple debounce wait on interrupts for buttons

Who changed what in which revision?

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