Dependents:   UMTSStickNetIfExample PMK_UMTSStickNetIfExample

Committer:
donatien
Date:
Thu Aug 05 15:18:28 2010 +0000
Revision:
3:62e3d7a3cc68
Parent:
0:45cd39946923

        

Who changed what in which revision?

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