EthernetNetIf Compatibility.

Dependents:   XBeeWiFi_SPI_example

Fork of NetServicesSource by Donatien Garnier

Committer:
donatien
Date:
Thu Aug 05 15:01:33 2010 +0000
Revision:
11:da4498f591ee
Parent:
4:fd826cad83c0

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 4:fd826cad83c0 1
donatien 4:fd826cad83c0 2 /*
donatien 4:fd826cad83c0 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
donatien 4:fd826cad83c0 4
donatien 4:fd826cad83c0 5 Permission is hereby granted, free of charge, to any person obtaining a copy
donatien 4:fd826cad83c0 6 of this software and associated documentation files (the "Software"), to deal
donatien 4:fd826cad83c0 7 in the Software without restriction, including without limitation the rights
donatien 4:fd826cad83c0 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
donatien 4:fd826cad83c0 9 copies of the Software, and to permit persons to whom the Software is
donatien 4:fd826cad83c0 10 furnished to do so, subject to the following conditions:
donatien 4:fd826cad83c0 11
donatien 4:fd826cad83c0 12 The above copyright notice and this permission notice shall be included in
donatien 4:fd826cad83c0 13 all copies or substantial portions of the Software.
donatien 4:fd826cad83c0 14
donatien 4:fd826cad83c0 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 4:fd826cad83c0 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 4:fd826cad83c0 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 4:fd826cad83c0 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 4:fd826cad83c0 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 4:fd826cad83c0 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
donatien 4:fd826cad83c0 21 THE SOFTWARE.
donatien 4:fd826cad83c0 22 */
donatien 4:fd826cad83c0 23
donatien 4:fd826cad83c0 24 #ifndef USB_INC_H
donatien 4:fd826cad83c0 25 #define USB_INC_H
donatien 4:fd826cad83c0 26
donatien 4:fd826cad83c0 27 #include "mbed.h"
donatien 4:fd826cad83c0 28
donatien 4:fd826cad83c0 29 #define MIN(a,b) ((a)<(b)?(a):(b))
donatien 4:fd826cad83c0 30 #define MAX(a,b) ((a)>(b)?(a):(b))
donatien 4:fd826cad83c0 31
donatien 4:fd826cad83c0 32 //typedef int32_t RC;
donatien 4:fd826cad83c0 33
donatien 4:fd826cad83c0 34 typedef uint8_t byte;
donatien 4:fd826cad83c0 35 typedef uint16_t word;
donatien 4:fd826cad83c0 36
donatien 4:fd826cad83c0 37 enum UsbErr
donatien 4:fd826cad83c0 38 {
donatien 4:fd826cad83c0 39 __USBERR_MIN = -0xFFFF,
donatien 4:fd826cad83c0 40 USBERR_DISCONNECTED,
donatien 4:fd826cad83c0 41 USBERR_NOTFOUND,
donatien 4:fd826cad83c0 42 USBERR_BADCONFIG,
donatien 4:fd826cad83c0 43 USBERR_PROCESSING,
donatien 4:fd826cad83c0 44 USBERR_HALTED, //Transfer on an ep is stalled
donatien 4:fd826cad83c0 45 USBERR_BUSY,
donatien 4:fd826cad83c0 46 USBERR_TDFAIL,
donatien 4:fd826cad83c0 47 USBERR_ERROR,
donatien 4:fd826cad83c0 48 USBERR_OK = 0
donatien 4:fd826cad83c0 49 };
donatien 4:fd826cad83c0 50
donatien 4:fd826cad83c0 51
donatien 4:fd826cad83c0 52 /* From NXP's USBHostLite stack's usbhost_lpc17xx.h */
donatien 4:fd826cad83c0 53 /* Only the types names have been changed to avoid unecessary typedefs */
donatien 4:fd826cad83c0 54
donatien 4:fd826cad83c0 55
donatien 4:fd826cad83c0 56 /*
donatien 4:fd826cad83c0 57 **************************************************************************************************************
donatien 4:fd826cad83c0 58 * NXP USB Host Stack
donatien 4:fd826cad83c0 59 *
donatien 4:fd826cad83c0 60 * (c) Copyright 2008, NXP SemiConductors
donatien 4:fd826cad83c0 61 * (c) Copyright 2008, OnChip Technologies LLC
donatien 4:fd826cad83c0 62 * All Rights Reserved
donatien 4:fd826cad83c0 63 *
donatien 4:fd826cad83c0 64 * www.nxp.com
donatien 4:fd826cad83c0 65 * www.onchiptech.com
donatien 4:fd826cad83c0 66 *
donatien 4:fd826cad83c0 67 * File : usbhost_lpc17xx.h
donatien 4:fd826cad83c0 68 * Programmer(s) : Ravikanth.P
donatien 4:fd826cad83c0 69 * Version :
donatien 4:fd826cad83c0 70 *
donatien 4:fd826cad83c0 71 **************************************************************************************************************
donatien 4:fd826cad83c0 72 */
donatien 4:fd826cad83c0 73
donatien 4:fd826cad83c0 74
donatien 4:fd826cad83c0 75
donatien 4:fd826cad83c0 76 /*
donatien 4:fd826cad83c0 77 **************************************************************************************************************
donatien 4:fd826cad83c0 78 * OHCI OPERATIONAL REGISTER FIELD DEFINITIONS
donatien 4:fd826cad83c0 79 **************************************************************************************************************
donatien 4:fd826cad83c0 80 */
donatien 4:fd826cad83c0 81
donatien 4:fd826cad83c0 82 /* ------------------ HcControl Register --------------------- */
donatien 4:fd826cad83c0 83 #define OR_CONTROL_CLE 0x00000010
donatien 4:fd826cad83c0 84 #define OR_CONTROL_BLE 0x00000020
donatien 4:fd826cad83c0 85 #define OR_CONTROL_HCFS 0x000000C0
donatien 4:fd826cad83c0 86 #define OR_CONTROL_HC_OPER 0x00000080
donatien 4:fd826cad83c0 87 /* ----------------- HcCommandStatus Register ----------------- */
donatien 4:fd826cad83c0 88 #define OR_CMD_STATUS_HCR 0x00000001
donatien 4:fd826cad83c0 89 #define OR_CMD_STATUS_CLF 0x00000002
donatien 4:fd826cad83c0 90 #define OR_CMD_STATUS_BLF 0x00000004
donatien 4:fd826cad83c0 91 /* --------------- HcInterruptStatus Register ----------------- */
donatien 4:fd826cad83c0 92 #define OR_INTR_STATUS_WDH 0x00000002
donatien 4:fd826cad83c0 93 #define OR_INTR_STATUS_RHSC 0x00000040
donatien 4:fd826cad83c0 94 #define OR_INTR_STATUS_UE 0x00000010
donatien 4:fd826cad83c0 95 /* --------------- HcInterruptEnable Register ----------------- */
donatien 4:fd826cad83c0 96 #define OR_INTR_ENABLE_WDH 0x00000002
donatien 4:fd826cad83c0 97 #define OR_INTR_ENABLE_RHSC 0x00000040
donatien 4:fd826cad83c0 98 #define OR_INTR_ENABLE_MIE 0x80000000
donatien 4:fd826cad83c0 99 /* ---------------- HcRhDescriptorA Register ------------------ */
donatien 4:fd826cad83c0 100 #define OR_RH_STATUS_LPSC 0x00010000
donatien 4:fd826cad83c0 101 #define OR_RH_STATUS_DRWE 0x00008000
donatien 4:fd826cad83c0 102 /* -------------- HcRhPortStatus[1:NDP] Register -------------- */
donatien 4:fd826cad83c0 103 #define OR_RH_PORT_CCS 0x00000001
donatien 4:fd826cad83c0 104 #define OR_RH_PORT_PRS 0x00000010
donatien 4:fd826cad83c0 105 #define OR_RH_PORT_CSC 0x00010000
donatien 4:fd826cad83c0 106 #define OR_RH_PORT_PRSC 0x00100000
donatien 4:fd826cad83c0 107
donatien 4:fd826cad83c0 108
donatien 4:fd826cad83c0 109 /*
donatien 4:fd826cad83c0 110 **************************************************************************************************************
donatien 4:fd826cad83c0 111 * FRAME INTERVAL
donatien 4:fd826cad83c0 112 **************************************************************************************************************
donatien 4:fd826cad83c0 113 */
donatien 4:fd826cad83c0 114
donatien 4:fd826cad83c0 115 #define FI 0x2EDF /* 12000 bits per frame (-1) */
donatien 4:fd826cad83c0 116 #define DEFAULT_FMINTERVAL ((((6 * (FI - 210)) / 7) << 16) | FI)
donatien 4:fd826cad83c0 117
donatien 4:fd826cad83c0 118 /*
donatien 4:fd826cad83c0 119 **************************************************************************************************************
donatien 4:fd826cad83c0 120 * ENDPOINT DESCRIPTOR CONTROL FIELDS
donatien 4:fd826cad83c0 121 **************************************************************************************************************
donatien 4:fd826cad83c0 122 */
donatien 4:fd826cad83c0 123
donatien 4:fd826cad83c0 124 #define ED_SKIP (uint32_t) (0x00001000) /* Skip this ep in queue */
donatien 4:fd826cad83c0 125
donatien 4:fd826cad83c0 126 /*
donatien 4:fd826cad83c0 127 **************************************************************************************************************
donatien 4:fd826cad83c0 128 * TRANSFER DESCRIPTOR CONTROL FIELDS
donatien 4:fd826cad83c0 129 **************************************************************************************************************
donatien 4:fd826cad83c0 130 */
donatien 4:fd826cad83c0 131
donatien 4:fd826cad83c0 132 #define TD_ROUNDING (uint32_t) (0x00040000) /* Buffer Rounding */
donatien 4:fd826cad83c0 133 #define TD_SETUP (uint32_t)(0) /* Direction of Setup Packet */
donatien 4:fd826cad83c0 134 #define TD_IN (uint32_t)(0x00100000) /* Direction In */
donatien 4:fd826cad83c0 135 #define TD_OUT (uint32_t)(0x00080000) /* Direction Out */
donatien 4:fd826cad83c0 136 #define TD_DELAY_INT(x) (uint32_t)((x) << 21) /* Delay Interrupt */
donatien 4:fd826cad83c0 137 #define TD_TOGGLE_0 (uint32_t)(0x02000000) /* Toggle 0 */
donatien 4:fd826cad83c0 138 #define TD_TOGGLE_1 (uint32_t)(0x03000000) /* Toggle 1 */
donatien 4:fd826cad83c0 139 #define TD_CC (uint32_t)(0xF0000000) /* Completion Code */
donatien 4:fd826cad83c0 140
donatien 4:fd826cad83c0 141 /*
donatien 4:fd826cad83c0 142 **************************************************************************************************************
donatien 4:fd826cad83c0 143 * USB STANDARD REQUEST DEFINITIONS
donatien 4:fd826cad83c0 144 **************************************************************************************************************
donatien 4:fd826cad83c0 145 */
donatien 4:fd826cad83c0 146
donatien 4:fd826cad83c0 147 #define USB_DESCRIPTOR_TYPE_DEVICE 1
donatien 4:fd826cad83c0 148 #define USB_DESCRIPTOR_TYPE_CONFIGURATION 2
donatien 4:fd826cad83c0 149 #define USB_DESCRIPTOR_TYPE_INTERFACE 4
donatien 4:fd826cad83c0 150 #define USB_DESCRIPTOR_TYPE_ENDPOINT 5
donatien 4:fd826cad83c0 151 /* ----------- Control RequestType Fields ----------- */
donatien 4:fd826cad83c0 152 #define USB_DEVICE_TO_HOST 0x80
donatien 4:fd826cad83c0 153 #define USB_HOST_TO_DEVICE 0x00
donatien 4:fd826cad83c0 154 #define USB_REQUEST_TYPE_CLASS 0x20
donatien 4:fd826cad83c0 155 #define USB_RECIPIENT_DEVICE 0x00
donatien 4:fd826cad83c0 156 #define USB_RECIPIENT_INTERFACE 0x01
donatien 4:fd826cad83c0 157 /* -------------- USB Standard Requests -------------- */
donatien 4:fd826cad83c0 158 #define SET_ADDRESS 5
donatien 4:fd826cad83c0 159 #define GET_DESCRIPTOR 6
donatien 4:fd826cad83c0 160 #define SET_CONFIGURATION 9
donatien 4:fd826cad83c0 161 #define SET_INTERFACE 11
donatien 4:fd826cad83c0 162
donatien 4:fd826cad83c0 163 /*
donatien 4:fd826cad83c0 164 **************************************************************************************************************
donatien 4:fd826cad83c0 165 * TYPE DEFINITIONS
donatien 4:fd826cad83c0 166 **************************************************************************************************************
donatien 4:fd826cad83c0 167 */
donatien 4:fd826cad83c0 168
donatien 4:fd826cad83c0 169 typedef struct hcEd { /* ----------- HostController EndPoint Descriptor ------------- */
donatien 4:fd826cad83c0 170 volatile uint32_t Control; /* Endpoint descriptor control */
donatien 4:fd826cad83c0 171 volatile uint32_t TailTd; /* Physical address of tail in Transfer descriptor list */
donatien 4:fd826cad83c0 172 volatile uint32_t HeadTd; /* Physcial address of head in Transfer descriptor list */
donatien 4:fd826cad83c0 173 volatile uint32_t Next; /* Physical address of next Endpoint descriptor */
donatien 4:fd826cad83c0 174 } HCED;
donatien 4:fd826cad83c0 175
donatien 4:fd826cad83c0 176 typedef struct hcTd { /* ------------ HostController Transfer Descriptor ------------ */
donatien 4:fd826cad83c0 177 volatile uint32_t Control; /* Transfer descriptor control */
donatien 4:fd826cad83c0 178 volatile uint32_t CurrBufPtr; /* Physical address of current buffer pointer */
donatien 4:fd826cad83c0 179 volatile uint32_t Next; /* Physical pointer to next Transfer Descriptor */
donatien 4:fd826cad83c0 180 volatile uint32_t BufEnd; /* Physical address of end of buffer */
donatien 4:fd826cad83c0 181 } HCTD;
donatien 4:fd826cad83c0 182
donatien 4:fd826cad83c0 183 typedef struct hcca { /* ----------- Host Controller Communication Area ------------ */
donatien 4:fd826cad83c0 184 volatile uint32_t IntTable[32]; /* Interrupt Table */
donatien 4:fd826cad83c0 185 volatile uint32_t FrameNumber; /* Frame Number */
donatien 4:fd826cad83c0 186 volatile uint32_t DoneHead; /* Done Head */
donatien 4:fd826cad83c0 187 volatile uint8_t Reserved[116]; /* Reserved for future use */
donatien 4:fd826cad83c0 188 volatile uint8_t Unknown[4]; /* Unused */
donatien 4:fd826cad83c0 189 } HCCA;
donatien 4:fd826cad83c0 190
donatien 4:fd826cad83c0 191
donatien 4:fd826cad83c0 192
donatien 4:fd826cad83c0 193 #endif