first release for keyboard

Dependencies:   FATFileSystem2

Dependents:   N64_Output_KB

Fork of F401RE-USBHost by Norimasa Okamoto

Committer:
va009039
Date:
Sat Jan 25 12:51:44 2014 +0000
Revision:
3:a3872f7593e2
fix max packet size

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 3:a3872f7593e2 1 /* mbed USBHost Library
va009039 3:a3872f7593e2 2 * Copyright (c) 2006-2013 ARM Limited
va009039 3:a3872f7593e2 3 *
va009039 3:a3872f7593e2 4 * Licensed under the Apache License, Version 2.0 (the "License");
va009039 3:a3872f7593e2 5 * you may not use this file except in compliance with the License.
va009039 3:a3872f7593e2 6 * You may obtain a copy of the License at
va009039 3:a3872f7593e2 7 *
va009039 3:a3872f7593e2 8 * http://www.apache.org/licenses/LICENSE-2.0
va009039 3:a3872f7593e2 9 *
va009039 3:a3872f7593e2 10 * Unless required by applicable law or agreed to in writing, software
va009039 3:a3872f7593e2 11 * distributed under the License is distributed on an "AS IS" BASIS,
va009039 3:a3872f7593e2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
va009039 3:a3872f7593e2 13 * See the License for the specific language governing permissions and
va009039 3:a3872f7593e2 14 * limitations under the License.
va009039 3:a3872f7593e2 15 */
va009039 3:a3872f7593e2 16
va009039 3:a3872f7593e2 17 #ifndef USB_INC_H
va009039 3:a3872f7593e2 18 #define USB_INC_H
va009039 3:a3872f7593e2 19
va009039 3:a3872f7593e2 20 #include "mbed.h"
va009039 3:a3872f7593e2 21 #include "toolchain.h"
va009039 3:a3872f7593e2 22
va009039 3:a3872f7593e2 23 enum USB_TYPE {
va009039 3:a3872f7593e2 24 USB_TYPE_OK = 0,
va009039 3:a3872f7593e2 25
va009039 3:a3872f7593e2 26 // completion code
va009039 3:a3872f7593e2 27 USB_TYPE_CRC_ERROR = 1,
va009039 3:a3872f7593e2 28 USB_TYPE_BIT_STUFFING_ERROR = 2,
va009039 3:a3872f7593e2 29 USB_TYPE_DATA_TOGGLE_MISMATCH_ERROR = 3,
va009039 3:a3872f7593e2 30 USB_TYPE_STALL_ERROR = 4,
va009039 3:a3872f7593e2 31 USB_TYPE_DEVICE_NOT_RESPONDING_ERROR = 5,
va009039 3:a3872f7593e2 32 USB_TYPE_PID_CHECK_FAILURE_ERROR = 6,
va009039 3:a3872f7593e2 33 USB_TYPE_UNEXPECTED_PID_ERROR = 7,
va009039 3:a3872f7593e2 34 USB_TYPE_DATA_OVERRUN_ERROR = 8,
va009039 3:a3872f7593e2 35 USB_TYPE_DATA_UNDERRUN_ERROR = 9,
va009039 3:a3872f7593e2 36 USB_TYPE_RESERVED = 9,
va009039 3:a3872f7593e2 37 USB_TYPE_RESERVED_ = 10,
va009039 3:a3872f7593e2 38 USB_TYPE_BUFFER_OVERRUN_ERROR = 12,
va009039 3:a3872f7593e2 39 USB_TYPE_BUFFER_UNDERRUN_ERROR = 13,
va009039 3:a3872f7593e2 40
va009039 3:a3872f7593e2 41 // general usb state
va009039 3:a3872f7593e2 42 USB_TYPE_DISCONNECTED = 14,
va009039 3:a3872f7593e2 43 USB_TYPE_FREE = 15,
va009039 3:a3872f7593e2 44 USB_TYPE_IDLE = 16,
va009039 3:a3872f7593e2 45 USB_TYPE_PROCESSING = 17,
va009039 3:a3872f7593e2 46
va009039 3:a3872f7593e2 47 USB_TYPE_ERROR = 18,
va009039 3:a3872f7593e2 48 };
va009039 3:a3872f7593e2 49
va009039 3:a3872f7593e2 50
va009039 3:a3872f7593e2 51 enum ENDPOINT_DIRECTION {
va009039 3:a3872f7593e2 52 OUT = 1,
va009039 3:a3872f7593e2 53 IN
va009039 3:a3872f7593e2 54 };
va009039 3:a3872f7593e2 55
va009039 3:a3872f7593e2 56 enum ENDPOINT_TYPE {
va009039 3:a3872f7593e2 57 CONTROL_ENDPOINT = 0,
va009039 3:a3872f7593e2 58 ISOCHRONOUS_ENDPOINT,
va009039 3:a3872f7593e2 59 BULK_ENDPOINT,
va009039 3:a3872f7593e2 60 INTERRUPT_ENDPOINT
va009039 3:a3872f7593e2 61 };
va009039 3:a3872f7593e2 62
va009039 3:a3872f7593e2 63 #define AUDIO_CLASS 0x01
va009039 3:a3872f7593e2 64 #define CDC_CLASS 0x02
va009039 3:a3872f7593e2 65 #define HID_CLASS 0x03
va009039 3:a3872f7593e2 66 #define MSD_CLASS 0x08
va009039 3:a3872f7593e2 67 #define HUB_CLASS 0x09
va009039 3:a3872f7593e2 68 #define SERIAL_CLASS 0x0A
va009039 3:a3872f7593e2 69
va009039 3:a3872f7593e2 70 #define DEVICE_DESCRIPTOR (1)
va009039 3:a3872f7593e2 71 #define CONFIGURATION_DESCRIPTOR (2)
va009039 3:a3872f7593e2 72 #define INTERFACE_DESCRIPTOR (4)
va009039 3:a3872f7593e2 73 #define ENDPOINT_DESCRIPTOR (5)
va009039 3:a3872f7593e2 74 #define HID_DESCRIPTOR (33)
va009039 3:a3872f7593e2 75
va009039 3:a3872f7593e2 76 // ----------- Control RequestType Fields -----------
va009039 3:a3872f7593e2 77 #define USB_DEVICE_TO_HOST 0x80
va009039 3:a3872f7593e2 78 #define USB_HOST_TO_DEVICE 0x00
va009039 3:a3872f7593e2 79 #define USB_REQUEST_TYPE_CLASS 0x20
va009039 3:a3872f7593e2 80 #define USB_REQUEST_TYPE_STANDARD 0x00
va009039 3:a3872f7593e2 81 #define USB_RECIPIENT_DEVICE 0x00
va009039 3:a3872f7593e2 82 #define USB_RECIPIENT_INTERFACE 0x01
va009039 3:a3872f7593e2 83 #define USB_RECIPIENT_ENDPOINT 0x02
va009039 3:a3872f7593e2 84
va009039 3:a3872f7593e2 85 // -------------- USB Standard Requests --------------
va009039 3:a3872f7593e2 86 #define SET_ADDRESS 0x05
va009039 3:a3872f7593e2 87 #define GET_DESCRIPTOR 0x06
va009039 3:a3872f7593e2 88 #define SET_CONFIGURATION 0x09
va009039 3:a3872f7593e2 89 #define SET_INTERFACE 0x0b
va009039 3:a3872f7593e2 90 #define CLEAR_FEATURE 0x01
va009039 3:a3872f7593e2 91
va009039 3:a3872f7593e2 92 // -------------- USB Descriptor Length --------------
va009039 3:a3872f7593e2 93 #define DEVICE_DESCRIPTOR_LENGTH 0x12
va009039 3:a3872f7593e2 94 #define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
va009039 3:a3872f7593e2 95
va009039 3:a3872f7593e2 96 #pragma pack(push,1)
va009039 3:a3872f7593e2 97 typedef struct {
va009039 3:a3872f7593e2 98 uint8_t bLength;
va009039 3:a3872f7593e2 99 uint8_t bDescriptorType;
va009039 3:a3872f7593e2 100 uint16_t bcdUSB;
va009039 3:a3872f7593e2 101 uint8_t bDeviceClass;
va009039 3:a3872f7593e2 102 uint8_t bDeviceSubClass;
va009039 3:a3872f7593e2 103 uint8_t bDeviceProtocol;
va009039 3:a3872f7593e2 104 uint8_t bMaxPacketSize;
va009039 3:a3872f7593e2 105 uint16_t idVendor;
va009039 3:a3872f7593e2 106 uint16_t idProduct;
va009039 3:a3872f7593e2 107 uint16_t bcdDevice;
va009039 3:a3872f7593e2 108 uint8_t iManufacturer;
va009039 3:a3872f7593e2 109 uint8_t iProduct;
va009039 3:a3872f7593e2 110 uint8_t iSerialNumber;
va009039 3:a3872f7593e2 111 uint8_t bNumConfigurations;
va009039 3:a3872f7593e2 112 } PACKED DeviceDescriptor;
va009039 3:a3872f7593e2 113
va009039 3:a3872f7593e2 114 typedef struct {
va009039 3:a3872f7593e2 115 uint8_t bLength;
va009039 3:a3872f7593e2 116 uint8_t bDescriptorType;
va009039 3:a3872f7593e2 117 uint16_t wTotalLength;
va009039 3:a3872f7593e2 118 uint8_t bNumInterfaces;
va009039 3:a3872f7593e2 119 uint8_t bConfigurationValue;
va009039 3:a3872f7593e2 120 uint8_t iConfiguration;
va009039 3:a3872f7593e2 121 uint8_t bmAttributes;
va009039 3:a3872f7593e2 122 uint8_t bMaxPower;
va009039 3:a3872f7593e2 123 } PACKED ConfigurationDescriptor;
va009039 3:a3872f7593e2 124
va009039 3:a3872f7593e2 125 typedef struct {
va009039 3:a3872f7593e2 126 uint8_t bLength;
va009039 3:a3872f7593e2 127 uint8_t bDescriptorType;
va009039 3:a3872f7593e2 128 uint8_t bInterfaceNumber;
va009039 3:a3872f7593e2 129 uint8_t bAlternateSetting;
va009039 3:a3872f7593e2 130 uint8_t bNumEndpoints;
va009039 3:a3872f7593e2 131 uint8_t bInterfaceClass;
va009039 3:a3872f7593e2 132 uint8_t bInterfaceSubClass;
va009039 3:a3872f7593e2 133 uint8_t bInterfaceProtocol;
va009039 3:a3872f7593e2 134 uint8_t iInterface;
va009039 3:a3872f7593e2 135 } InterfaceDescriptor;
va009039 3:a3872f7593e2 136
va009039 3:a3872f7593e2 137 typedef struct {
va009039 3:a3872f7593e2 138 uint8_t bLength;
va009039 3:a3872f7593e2 139 uint8_t bDescriptorType;
va009039 3:a3872f7593e2 140 uint8_t bEndpointAddress;
va009039 3:a3872f7593e2 141 uint8_t bmAttributes;
va009039 3:a3872f7593e2 142 uint16_t wMaxPacketSize;
va009039 3:a3872f7593e2 143 uint8_t bInterval;
va009039 3:a3872f7593e2 144 } EndpointDescriptor;
va009039 3:a3872f7593e2 145
va009039 3:a3872f7593e2 146 typedef struct {
va009039 3:a3872f7593e2 147 uint8_t bDescLength;
va009039 3:a3872f7593e2 148 uint8_t bDescriptorType;
va009039 3:a3872f7593e2 149 uint8_t bNbrPorts;
va009039 3:a3872f7593e2 150 uint16_t wHubCharacteristics;
va009039 3:a3872f7593e2 151 uint8_t bPwrOn2PwrGood;
va009039 3:a3872f7593e2 152 uint8_t bHubContrCurrent;
va009039 3:a3872f7593e2 153 uint8_t DeviceRemovable;
va009039 3:a3872f7593e2 154 uint8_t PortPweCtrlMak;
va009039 3:a3872f7593e2 155 } HubDescriptor;
va009039 3:a3872f7593e2 156 #pragma pack(pop)
va009039 3:a3872f7593e2 157
va009039 3:a3872f7593e2 158 #endif