CDC/ECM driver for mbed, based on USBDevice by mbed-official. Uses PicoTCP to access Ethernet USB device. License: GPLv2

Dependents:   USBEthernet_TEST

Fork of USB_Ethernet by Daniele Lacamera

Committer:
daniele
Date:
Sat Aug 03 13:16:14 2013 +0000
Revision:
2:540f6e142d59
Moved to single package

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daniele 2:540f6e142d59 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
daniele 2:540f6e142d59 2 *
daniele 2:540f6e142d59 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
daniele 2:540f6e142d59 4 * and associated documentation files (the "Software"), to deal in the Software without
daniele 2:540f6e142d59 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
daniele 2:540f6e142d59 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
daniele 2:540f6e142d59 7 * Software is furnished to do so, subject to the following conditions:
daniele 2:540f6e142d59 8 *
daniele 2:540f6e142d59 9 * The above copyright notice and this permission notice shall be included in all copies or
daniele 2:540f6e142d59 10 * substantial portions of the Software.
daniele 2:540f6e142d59 11 *
daniele 2:540f6e142d59 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
daniele 2:540f6e142d59 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
daniele 2:540f6e142d59 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
daniele 2:540f6e142d59 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
daniele 2:540f6e142d59 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
daniele 2:540f6e142d59 17 */
daniele 2:540f6e142d59 18
daniele 2:540f6e142d59 19 #ifndef USBDEVICE_TYPES_H
daniele 2:540f6e142d59 20 #define USBDEVICE_TYPES_H
daniele 2:540f6e142d59 21
daniele 2:540f6e142d59 22 /* Standard requests */
daniele 2:540f6e142d59 23 #define GET_STATUS (0)
daniele 2:540f6e142d59 24 #define CLEAR_FEATURE (1)
daniele 2:540f6e142d59 25 #define SET_FEATURE (3)
daniele 2:540f6e142d59 26 #define SET_ADDRESS (5)
daniele 2:540f6e142d59 27 #define GET_DESCRIPTOR (6)
daniele 2:540f6e142d59 28 #define SET_DESCRIPTOR (7)
daniele 2:540f6e142d59 29 #define GET_CONFIGURATION (8)
daniele 2:540f6e142d59 30 #define SET_CONFIGURATION (9)
daniele 2:540f6e142d59 31 #define GET_INTERFACE (10)
daniele 2:540f6e142d59 32 #define SET_INTERFACE (11)
daniele 2:540f6e142d59 33
daniele 2:540f6e142d59 34 /* bmRequestType.dataTransferDirection */
daniele 2:540f6e142d59 35 #define HOST_TO_DEVICE (0)
daniele 2:540f6e142d59 36 #define DEVICE_TO_HOST (1)
daniele 2:540f6e142d59 37
daniele 2:540f6e142d59 38 /* bmRequestType.Type*/
daniele 2:540f6e142d59 39 #define STANDARD_TYPE (0)
daniele 2:540f6e142d59 40 #define CLASS_TYPE (1)
daniele 2:540f6e142d59 41 #define VENDOR_TYPE (2)
daniele 2:540f6e142d59 42 #define RESERVED_TYPE (3)
daniele 2:540f6e142d59 43
daniele 2:540f6e142d59 44 /* bmRequestType.Recipient */
daniele 2:540f6e142d59 45 #define DEVICE_RECIPIENT (0)
daniele 2:540f6e142d59 46 #define INTERFACE_RECIPIENT (1)
daniele 2:540f6e142d59 47 #define ENDPOINT_RECIPIENT (2)
daniele 2:540f6e142d59 48 #define OTHER_RECIPIENT (3)
daniele 2:540f6e142d59 49
daniele 2:540f6e142d59 50 /* Descriptors */
daniele 2:540f6e142d59 51 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
daniele 2:540f6e142d59 52 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xf)
daniele 2:540f6e142d59 53
daniele 2:540f6e142d59 54 typedef struct {
daniele 2:540f6e142d59 55 struct {
daniele 2:540f6e142d59 56 uint8_t dataTransferDirection;
daniele 2:540f6e142d59 57 uint8_t Type;
daniele 2:540f6e142d59 58 uint8_t Recipient;
daniele 2:540f6e142d59 59 } bmRequestType;
daniele 2:540f6e142d59 60 uint8_t bRequest;
daniele 2:540f6e142d59 61 uint16_t wValue;
daniele 2:540f6e142d59 62 uint16_t wIndex;
daniele 2:540f6e142d59 63 uint16_t wLength;
daniele 2:540f6e142d59 64 } SETUP_PACKET;
daniele 2:540f6e142d59 65
daniele 2:540f6e142d59 66 typedef struct {
daniele 2:540f6e142d59 67 SETUP_PACKET setup;
daniele 2:540f6e142d59 68 uint8_t *ptr;
daniele 2:540f6e142d59 69 uint32_t remaining;
daniele 2:540f6e142d59 70 uint8_t direction;
daniele 2:540f6e142d59 71 bool zlp;
daniele 2:540f6e142d59 72 bool notify;
daniele 2:540f6e142d59 73 } CONTROL_TRANSFER;
daniele 2:540f6e142d59 74
daniele 2:540f6e142d59 75 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
daniele 2:540f6e142d59 76
daniele 2:540f6e142d59 77 typedef struct {
daniele 2:540f6e142d59 78 volatile DEVICE_STATE state;
daniele 2:540f6e142d59 79 uint8_t configuration;
daniele 2:540f6e142d59 80 bool suspended;
daniele 2:540f6e142d59 81 } USB_DEVICE;
daniele 2:540f6e142d59 82
daniele 2:540f6e142d59 83 #endif