Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Tue Oct 08 00:08:22 2013 +0000
Revision:
21:3f45e53afe4f
Parent:
5:3f93dd1d4cb3
Added http client test. Return from post seems to be a bit wonky but haven't looked closely at this

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 5:3f93dd1d4cb3 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
sam_grove 5:3f93dd1d4cb3 2 *
sam_grove 5:3f93dd1d4cb3 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
sam_grove 5:3f93dd1d4cb3 4 * and associated documentation files (the "Software"), to deal in the Software without
sam_grove 5:3f93dd1d4cb3 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
sam_grove 5:3f93dd1d4cb3 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
sam_grove 5:3f93dd1d4cb3 7 * Software is furnished to do so, subject to the following conditions:
sam_grove 5:3f93dd1d4cb3 8 *
sam_grove 5:3f93dd1d4cb3 9 * The above copyright notice and this permission notice shall be included in all copies or
sam_grove 5:3f93dd1d4cb3 10 * substantial portions of the Software.
sam_grove 5:3f93dd1d4cb3 11 *
sam_grove 5:3f93dd1d4cb3 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
sam_grove 5:3f93dd1d4cb3 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
sam_grove 5:3f93dd1d4cb3 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
sam_grove 5:3f93dd1d4cb3 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
sam_grove 5:3f93dd1d4cb3 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sam_grove 5:3f93dd1d4cb3 17 */
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 #ifndef USBENDPOINT_H
sam_grove 5:3f93dd1d4cb3 20 #define USBENDPOINT_H
sam_grove 5:3f93dd1d4cb3 21
sam_grove 5:3f93dd1d4cb3 22 #include "stdint.h"
sam_grove 5:3f93dd1d4cb3 23 #include "FunctionPointer.h"
sam_grove 5:3f93dd1d4cb3 24 #include "USBHostTypes.h"
sam_grove 5:3f93dd1d4cb3 25
sam_grove 5:3f93dd1d4cb3 26
sam_grove 5:3f93dd1d4cb3 27 enum ENDPOINT_TYPE {
sam_grove 5:3f93dd1d4cb3 28 CONTROL_ENDPOINT = 0,
sam_grove 5:3f93dd1d4cb3 29 ISOCHRONOUS_ENDPOINT,
sam_grove 5:3f93dd1d4cb3 30 BULK_ENDPOINT,
sam_grove 5:3f93dd1d4cb3 31 INTERRUPT_ENDPOINT
sam_grove 5:3f93dd1d4cb3 32 };
sam_grove 5:3f93dd1d4cb3 33
sam_grove 5:3f93dd1d4cb3 34 enum ENDPOINT_DIRECTION {
sam_grove 5:3f93dd1d4cb3 35 OUT = 1,
sam_grove 5:3f93dd1d4cb3 36 IN
sam_grove 5:3f93dd1d4cb3 37 };
sam_grove 5:3f93dd1d4cb3 38
sam_grove 5:3f93dd1d4cb3 39 class USBEndpoint {
sam_grove 5:3f93dd1d4cb3 40 public:
sam_grove 5:3f93dd1d4cb3 41 /*
sam_grove 5:3f93dd1d4cb3 42 * Constructor
sam_grove 5:3f93dd1d4cb3 43 */
sam_grove 5:3f93dd1d4cb3 44 USBEndpoint() {state = USB_TYPE_FREE; nextEp = NULL;};
sam_grove 5:3f93dd1d4cb3 45
sam_grove 5:3f93dd1d4cb3 46 /*
sam_grove 5:3f93dd1d4cb3 47 * Initialize an endpoint
sam_grove 5:3f93dd1d4cb3 48 *
sam_grove 5:3f93dd1d4cb3 49 * @param hced hced associated to the endpoint
sam_grove 5:3f93dd1d4cb3 50 * @param type endpoint type
sam_grove 5:3f93dd1d4cb3 51 * @param dir endpoint direction
sam_grove 5:3f93dd1d4cb3 52 * @param size endpoint size
sam_grove 5:3f93dd1d4cb3 53 * @param ep_number endpoint number
sam_grove 5:3f93dd1d4cb3 54 */
sam_grove 5:3f93dd1d4cb3 55 void init(HCED * hced, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint32_t size, uint8_t ep_number, HCTD* td_list[2]);
sam_grove 5:3f93dd1d4cb3 56
sam_grove 5:3f93dd1d4cb3 57 /*
sam_grove 5:3f93dd1d4cb3 58 * Set next token. Warining: only useful for the control endpoint
sam_grove 5:3f93dd1d4cb3 59 *
sam_grove 5:3f93dd1d4cb3 60 * @param token IN, OUT or SETUP token
sam_grove 5:3f93dd1d4cb3 61 */
sam_grove 5:3f93dd1d4cb3 62 void setNextToken(uint32_t token);
sam_grove 5:3f93dd1d4cb3 63
sam_grove 5:3f93dd1d4cb3 64 /*
sam_grove 5:3f93dd1d4cb3 65 * Queue an endpoint
sam_grove 5:3f93dd1d4cb3 66 *
sam_grove 5:3f93dd1d4cb3 67 * endpoint endpoint which will be queued in the linked list
sam_grove 5:3f93dd1d4cb3 68 */
sam_grove 5:3f93dd1d4cb3 69 void queueEndpoint(USBEndpoint * endpoint);
sam_grove 5:3f93dd1d4cb3 70
sam_grove 5:3f93dd1d4cb3 71 /*
sam_grove 5:3f93dd1d4cb3 72 * Get a td to be queued
sam_grove 5:3f93dd1d4cb3 73 *
sam_grove 5:3f93dd1d4cb3 74 * @returns td hctd which will be queued
sam_grove 5:3f93dd1d4cb3 75 */
sam_grove 5:3f93dd1d4cb3 76 volatile HCTD* getNextTD();
sam_grove 5:3f93dd1d4cb3 77
sam_grove 5:3f93dd1d4cb3 78 /*
sam_grove 5:3f93dd1d4cb3 79 * Queue a transfer on the endpoint
sam_grove 5:3f93dd1d4cb3 80 *
sam_grove 5:3f93dd1d4cb3 81 */
sam_grove 5:3f93dd1d4cb3 82 void queueTransfer();
sam_grove 5:3f93dd1d4cb3 83
sam_grove 5:3f93dd1d4cb3 84 /*
sam_grove 5:3f93dd1d4cb3 85 * Get the currently processed td
sam_grove 5:3f93dd1d4cb3 86 *
sam_grove 5:3f93dd1d4cb3 87 * @returns td hctd that was queued
sam_grove 5:3f93dd1d4cb3 88 */
sam_grove 5:3f93dd1d4cb3 89 volatile HCTD * getProcessedTD();
sam_grove 5:3f93dd1d4cb3 90
sam_grove 5:3f93dd1d4cb3 91 /*
sam_grove 5:3f93dd1d4cb3 92 * Unqueue a transfer from the endpoint
sam_grove 5:3f93dd1d4cb3 93 *
sam_grove 5:3f93dd1d4cb3 94 * @param td hctd which will be unqueued
sam_grove 5:3f93dd1d4cb3 95 */
sam_grove 5:3f93dd1d4cb3 96 void unqueueTransfer(volatile HCTD * td);
sam_grove 5:3f93dd1d4cb3 97
sam_grove 5:3f93dd1d4cb3 98 /*
sam_grove 5:3f93dd1d4cb3 99 * Return the next endpoint in the linked list
sam_grove 5:3f93dd1d4cb3 100 *
sam_grove 5:3f93dd1d4cb3 101 * @returns next endpoint
sam_grove 5:3f93dd1d4cb3 102 */
sam_grove 5:3f93dd1d4cb3 103 USBEndpoint * nextEndpoint();
sam_grove 5:3f93dd1d4cb3 104
sam_grove 5:3f93dd1d4cb3 105 /**
sam_grove 5:3f93dd1d4cb3 106 * Attach a member function to call when a transfer is finished
sam_grove 5:3f93dd1d4cb3 107 *
sam_grove 5:3f93dd1d4cb3 108 * @param tptr pointer to the object to call the member function on
sam_grove 5:3f93dd1d4cb3 109 * @param mptr pointer to the member function to be called
sam_grove 5:3f93dd1d4cb3 110 */
sam_grove 5:3f93dd1d4cb3 111 template<typename T>
sam_grove 5:3f93dd1d4cb3 112 void attach(T* tptr, void (T::*mptr)(void)) {
sam_grove 5:3f93dd1d4cb3 113 if((mptr != NULL) && (tptr != NULL)) {
sam_grove 5:3f93dd1d4cb3 114 rx.attach(tptr, mptr);
sam_grove 5:3f93dd1d4cb3 115 }
sam_grove 5:3f93dd1d4cb3 116 }
sam_grove 5:3f93dd1d4cb3 117
sam_grove 5:3f93dd1d4cb3 118 /**
sam_grove 5:3f93dd1d4cb3 119 * Attach a callback called when a transfer is finished
sam_grove 5:3f93dd1d4cb3 120 *
sam_grove 5:3f93dd1d4cb3 121 * @param fptr function pointer
sam_grove 5:3f93dd1d4cb3 122 */
sam_grove 5:3f93dd1d4cb3 123 void attach(void (*fn)(void)) {
sam_grove 5:3f93dd1d4cb3 124 if(fn != NULL) {
sam_grove 5:3f93dd1d4cb3 125 rx.attach(fn);
sam_grove 5:3f93dd1d4cb3 126 }
sam_grove 5:3f93dd1d4cb3 127 }
sam_grove 5:3f93dd1d4cb3 128
sam_grove 5:3f93dd1d4cb3 129 /*
sam_grove 5:3f93dd1d4cb3 130 * Call the handler associted to the end of a transfer
sam_grove 5:3f93dd1d4cb3 131 */
sam_grove 5:3f93dd1d4cb3 132 void call() {
sam_grove 5:3f93dd1d4cb3 133 rx.call();
sam_grove 5:3f93dd1d4cb3 134 };
sam_grove 5:3f93dd1d4cb3 135
sam_grove 5:3f93dd1d4cb3 136
sam_grove 5:3f93dd1d4cb3 137 /*
sam_grove 5:3f93dd1d4cb3 138 * Setters
sam_grove 5:3f93dd1d4cb3 139 */
sam_grove 5:3f93dd1d4cb3 140 void setState(USB_TYPE st) { state = st;}
sam_grove 5:3f93dd1d4cb3 141 void setDeviceAddress(uint8_t addr);
sam_grove 5:3f93dd1d4cb3 142 void setLengthTransferred(int len);
sam_grove 5:3f93dd1d4cb3 143 void setSpeed(uint8_t speed);
sam_grove 5:3f93dd1d4cb3 144 void setSize(uint32_t size);
sam_grove 5:3f93dd1d4cb3 145 void setDir(ENDPOINT_DIRECTION d) {dir = d;}
sam_grove 5:3f93dd1d4cb3 146
sam_grove 5:3f93dd1d4cb3 147 /*
sam_grove 5:3f93dd1d4cb3 148 * Getters
sam_grove 5:3f93dd1d4cb3 149 */
sam_grove 5:3f93dd1d4cb3 150 USB_TYPE getState() {return state;}
sam_grove 5:3f93dd1d4cb3 151 ENDPOINT_TYPE getType();
sam_grove 5:3f93dd1d4cb3 152 uint8_t getDeviceAddress();
sam_grove 5:3f93dd1d4cb3 153 int getLengthTransferred() {return transferred;}
sam_grove 5:3f93dd1d4cb3 154 uint32_t getBufStart();
sam_grove 5:3f93dd1d4cb3 155 uint32_t getSize();
sam_grove 5:3f93dd1d4cb3 156 volatile HCTD * getHeadTD();
sam_grove 5:3f93dd1d4cb3 157 volatile HCTD** getTDList();
sam_grove 5:3f93dd1d4cb3 158 volatile HCED * getHCED();
sam_grove 5:3f93dd1d4cb3 159 ENDPOINT_DIRECTION getDir() {return dir;}
sam_grove 5:3f93dd1d4cb3 160 bool isSetup() {return setup;}
sam_grove 5:3f93dd1d4cb3 161
sam_grove 5:3f93dd1d4cb3 162
sam_grove 5:3f93dd1d4cb3 163 private:
sam_grove 5:3f93dd1d4cb3 164 ENDPOINT_TYPE type;
sam_grove 5:3f93dd1d4cb3 165 volatile USB_TYPE state;
sam_grove 5:3f93dd1d4cb3 166 ENDPOINT_DIRECTION dir;
sam_grove 5:3f93dd1d4cb3 167 bool setup;
sam_grove 5:3f93dd1d4cb3 168
sam_grove 5:3f93dd1d4cb3 169 int transfer_len;
sam_grove 5:3f93dd1d4cb3 170 int transferred;
sam_grove 5:3f93dd1d4cb3 171 uint32_t buf_start;
sam_grove 5:3f93dd1d4cb3 172
sam_grove 5:3f93dd1d4cb3 173 FunctionPointer rx;
sam_grove 5:3f93dd1d4cb3 174
sam_grove 5:3f93dd1d4cb3 175 USBEndpoint* nextEp;
sam_grove 5:3f93dd1d4cb3 176
sam_grove 5:3f93dd1d4cb3 177 // USBEndpoint descriptor
sam_grove 5:3f93dd1d4cb3 178 volatile HCED * hced;
sam_grove 5:3f93dd1d4cb3 179
sam_grove 5:3f93dd1d4cb3 180 volatile HCTD * td_list[2];
sam_grove 5:3f93dd1d4cb3 181 volatile HCTD * td_current;
sam_grove 5:3f93dd1d4cb3 182 volatile HCTD * td_next;
sam_grove 5:3f93dd1d4cb3 183 /*bool carry;*/
sam_grove 5:3f93dd1d4cb3 184
sam_grove 5:3f93dd1d4cb3 185 int count;
sam_grove 5:3f93dd1d4cb3 186
sam_grove 5:3f93dd1d4cb3 187 };
sam_grove 5:3f93dd1d4cb3 188
sam_grove 5:3f93dd1d4cb3 189 #endif