USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Committer:
samux
Date:
Tue Dec 06 12:07:12 2011 +0000
Revision:
14:757226626acb
Parent:
11:a26e7b7a1221
protection enabled when usb cable plugged. filesystem has no access when plugged

Who changed what in which revision?

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