Modified version of NetServices. Fixes an issue where connections failed should the HTTP response status line be received in a packet on its own prior to any further headers. Changes are made to the HTTPClient.cpp file's readHeaders method.

Committer:
andrewbonney
Date:
Fri Apr 08 14:39:41 2011 +0000
Revision:
0:ec559500a63f

        

Who changed what in which revision?

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