USBMSD test for GR-PEACH

Dependencies:   USBDevice USBMSD_SD mbed

Fork of USBMSD_SD_HelloWorld_Mbed by Samuel Mokrani

Committer:
samux
Date:
Wed Nov 16 17:17:42 2011 +0000
Revision:
11:a26e7b7a1221
GOOD COMMIT: msd and hid work even on MAC...

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 USBDEVICE_TYPES_H
samux 11:a26e7b7a1221 20 #define USBDEVICE_TYPES_H
samux 11:a26e7b7a1221 21
samux 11:a26e7b7a1221 22 /* Standard requests */
samux 11:a26e7b7a1221 23 #define GET_STATUS (0)
samux 11:a26e7b7a1221 24 #define CLEAR_FEATURE (1)
samux 11:a26e7b7a1221 25 #define SET_FEATURE (3)
samux 11:a26e7b7a1221 26 #define SET_ADDRESS (5)
samux 11:a26e7b7a1221 27 #define GET_DESCRIPTOR (6)
samux 11:a26e7b7a1221 28 #define SET_DESCRIPTOR (7)
samux 11:a26e7b7a1221 29 #define GET_CONFIGURATION (8)
samux 11:a26e7b7a1221 30 #define SET_CONFIGURATION (9)
samux 11:a26e7b7a1221 31 #define GET_INTERFACE (10)
samux 11:a26e7b7a1221 32 #define SET_INTERFACE (11)
samux 11:a26e7b7a1221 33
samux 11:a26e7b7a1221 34 /* bmRequestType.dataTransferDirection */
samux 11:a26e7b7a1221 35 #define HOST_TO_DEVICE (0)
samux 11:a26e7b7a1221 36 #define DEVICE_TO_HOST (1)
samux 11:a26e7b7a1221 37
samux 11:a26e7b7a1221 38 /* bmRequestType.Type*/
samux 11:a26e7b7a1221 39 #define STANDARD_TYPE (0)
samux 11:a26e7b7a1221 40 #define CLASS_TYPE (1)
samux 11:a26e7b7a1221 41 #define VENDOR_TYPE (2)
samux 11:a26e7b7a1221 42 #define RESERVED_TYPE (3)
samux 11:a26e7b7a1221 43
samux 11:a26e7b7a1221 44 /* bmRequestType.Recipient */
samux 11:a26e7b7a1221 45 #define DEVICE_RECIPIENT (0)
samux 11:a26e7b7a1221 46 #define INTERFACE_RECIPIENT (1)
samux 11:a26e7b7a1221 47 #define ENDPOINT_RECIPIENT (2)
samux 11:a26e7b7a1221 48 #define OTHER_RECIPIENT (3)
samux 11:a26e7b7a1221 49
samux 11:a26e7b7a1221 50 /* Descriptors */
samux 11:a26e7b7a1221 51 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
samux 11:a26e7b7a1221 52 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xf)
samux 11:a26e7b7a1221 53
samux 11:a26e7b7a1221 54 typedef struct {
samux 11:a26e7b7a1221 55 struct {
samux 11:a26e7b7a1221 56 uint8_t dataTransferDirection;
samux 11:a26e7b7a1221 57 uint8_t Type;
samux 11:a26e7b7a1221 58 uint8_t Recipient;
samux 11:a26e7b7a1221 59 } bmRequestType;
samux 11:a26e7b7a1221 60 uint8_t bRequest;
samux 11:a26e7b7a1221 61 uint16_t wValue;
samux 11:a26e7b7a1221 62 uint16_t wIndex;
samux 11:a26e7b7a1221 63 uint16_t wLength;
samux 11:a26e7b7a1221 64 } SETUP_PACKET;
samux 11:a26e7b7a1221 65
samux 11:a26e7b7a1221 66 typedef struct {
samux 11:a26e7b7a1221 67 SETUP_PACKET setup;
samux 11:a26e7b7a1221 68 uint8_t *ptr;
samux 11:a26e7b7a1221 69 uint32_t remaining;
samux 11:a26e7b7a1221 70 uint8_t direction;
samux 11:a26e7b7a1221 71 bool zlp;
samux 11:a26e7b7a1221 72 bool notify;
samux 11:a26e7b7a1221 73 } CONTROL_TRANSFER;
samux 11:a26e7b7a1221 74
samux 11:a26e7b7a1221 75 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
samux 11:a26e7b7a1221 76
samux 11:a26e7b7a1221 77 typedef struct {
samux 11:a26e7b7a1221 78 volatile DEVICE_STATE state;
samux 11:a26e7b7a1221 79 uint8_t configuration;
samux 11:a26e7b7a1221 80 bool suspended;
samux 11:a26e7b7a1221 81 } USB_DEVICE;
samux 11:a26e7b7a1221 82
samux 11:a26e7b7a1221 83 #endif