Slingshot Controller

Dependencies:   ADXL345 DebounceIn USBDevice mbed

Committer:
Brandon
Date:
Wed Oct 17 16:33:04 2012 +0000
Revision:
1:2721dc2acc2c
Parent:
0:cf17ea89fd09
Updated comments, added names, cleaned old code.

Who changed what in which revision?

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