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 USBHALHOST_H
sam_grove 5:3f93dd1d4cb3 20 #define USBHALHOST_H
sam_grove 5:3f93dd1d4cb3 21
sam_grove 5:3f93dd1d4cb3 22 #include "rtos.h"
sam_grove 5:3f93dd1d4cb3 23
sam_grove 5:3f93dd1d4cb3 24 #include "USBHostTypes.h"
sam_grove 5:3f93dd1d4cb3 25
sam_grove 5:3f93dd1d4cb3 26 #define MAX_ENDPOINT 5
sam_grove 5:3f93dd1d4cb3 27 #define MAX_TD (MAX_ENDPOINT*2)
sam_grove 5:3f93dd1d4cb3 28
sam_grove 5:3f93dd1d4cb3 29 #define USBHALHOST_SIG_INIT 0x01
sam_grove 5:3f93dd1d4cb3 30 #define USBHALHOST_SIG_IRQ 0x02
sam_grove 5:3f93dd1d4cb3 31
sam_grove 5:3f93dd1d4cb3 32 class USBHALHost {
sam_grove 5:3f93dd1d4cb3 33 public:
sam_grove 5:3f93dd1d4cb3 34
sam_grove 5:3f93dd1d4cb3 35 /*
sam_grove 5:3f93dd1d4cb3 36 * Constructor
sam_grove 5:3f93dd1d4cb3 37 * init variables and memory where will be stored HCCA, ED and TD
sam_grove 5:3f93dd1d4cb3 38 */
sam_grove 5:3f93dd1d4cb3 39 USBHALHost();
sam_grove 5:3f93dd1d4cb3 40
sam_grove 5:3f93dd1d4cb3 41 /*
sam_grove 5:3f93dd1d4cb3 42 * Initialize host controller. Enable USB interrupts. This part is not in the constructor because,
sam_grove 5:3f93dd1d4cb3 43 * this function calls a virtual method if a device is already connected
sam_grove 5:3f93dd1d4cb3 44 */
sam_grove 5:3f93dd1d4cb3 45 void init();
sam_grove 5:3f93dd1d4cb3 46
sam_grove 5:3f93dd1d4cb3 47 /*
sam_grove 5:3f93dd1d4cb3 48 * reset a port of a specific hub
sam_grove 5:3f93dd1d4cb3 49 * TODO: support hub
sam_grove 5:3f93dd1d4cb3 50 */
sam_grove 5:3f93dd1d4cb3 51 void resetPort(int hub, int port);
sam_grove 5:3f93dd1d4cb3 52
sam_grove 5:3f93dd1d4cb3 53 /*
sam_grove 5:3f93dd1d4cb3 54 * return the value contained in the control HEAD ED register
sam_grove 5:3f93dd1d4cb3 55 *
sam_grove 5:3f93dd1d4cb3 56 * @returns address of the control Head ED
sam_grove 5:3f93dd1d4cb3 57 */
sam_grove 5:3f93dd1d4cb3 58 uint32_t controlHeadED();
sam_grove 5:3f93dd1d4cb3 59
sam_grove 5:3f93dd1d4cb3 60 /*
sam_grove 5:3f93dd1d4cb3 61 * return the value contained in the bulk HEAD ED register
sam_grove 5:3f93dd1d4cb3 62 *
sam_grove 5:3f93dd1d4cb3 63 * @returns address of the bulk head ED
sam_grove 5:3f93dd1d4cb3 64 */
sam_grove 5:3f93dd1d4cb3 65 uint32_t bulkHeadED();
sam_grove 5:3f93dd1d4cb3 66
sam_grove 5:3f93dd1d4cb3 67 /*
sam_grove 5:3f93dd1d4cb3 68 * return the value of the head interrupt ED contained in the HCCA
sam_grove 5:3f93dd1d4cb3 69 *
sam_grove 5:3f93dd1d4cb3 70 * @returns address of the head interrupt ED contained in the HCCA
sam_grove 5:3f93dd1d4cb3 71 */
sam_grove 5:3f93dd1d4cb3 72 uint32_t interruptHeadED();
sam_grove 5:3f93dd1d4cb3 73
sam_grove 5:3f93dd1d4cb3 74
sam_grove 5:3f93dd1d4cb3 75 /*
sam_grove 5:3f93dd1d4cb3 76 * Update the head ED for control transfers
sam_grove 5:3f93dd1d4cb3 77 */
sam_grove 5:3f93dd1d4cb3 78 void updateControlHeadED(uint32_t addr);
sam_grove 5:3f93dd1d4cb3 79
sam_grove 5:3f93dd1d4cb3 80 /*
sam_grove 5:3f93dd1d4cb3 81 * Update the head ED for bulk transfers
sam_grove 5:3f93dd1d4cb3 82 */
sam_grove 5:3f93dd1d4cb3 83 void updateBulkHeadED(uint32_t addr);
sam_grove 5:3f93dd1d4cb3 84
sam_grove 5:3f93dd1d4cb3 85 /*
sam_grove 5:3f93dd1d4cb3 86 * Update the head ED for interrupt transfers
sam_grove 5:3f93dd1d4cb3 87 */
sam_grove 5:3f93dd1d4cb3 88 void updateInterruptHeadED(uint32_t addr);
sam_grove 5:3f93dd1d4cb3 89
sam_grove 5:3f93dd1d4cb3 90 /*
sam_grove 5:3f93dd1d4cb3 91 * Enable control list ED
sam_grove 5:3f93dd1d4cb3 92 */
sam_grove 5:3f93dd1d4cb3 93 void enableControlList();
sam_grove 5:3f93dd1d4cb3 94
sam_grove 5:3f93dd1d4cb3 95 /*
sam_grove 5:3f93dd1d4cb3 96 * Enable bulk list ED
sam_grove 5:3f93dd1d4cb3 97 */
sam_grove 5:3f93dd1d4cb3 98 void enableBulkList();
sam_grove 5:3f93dd1d4cb3 99
sam_grove 5:3f93dd1d4cb3 100 /*
sam_grove 5:3f93dd1d4cb3 101 * Enable Interrupt list ED
sam_grove 5:3f93dd1d4cb3 102 */
sam_grove 5:3f93dd1d4cb3 103 void enableInterruptList();
sam_grove 5:3f93dd1d4cb3 104
sam_grove 5:3f93dd1d4cb3 105 /*
sam_grove 5:3f93dd1d4cb3 106 * Disable control list ED
sam_grove 5:3f93dd1d4cb3 107 */
sam_grove 5:3f93dd1d4cb3 108 bool disableControlList();
sam_grove 5:3f93dd1d4cb3 109
sam_grove 5:3f93dd1d4cb3 110 /*
sam_grove 5:3f93dd1d4cb3 111 * Disable bulk list ED
sam_grove 5:3f93dd1d4cb3 112 */
sam_grove 5:3f93dd1d4cb3 113 bool disableBulkList();
sam_grove 5:3f93dd1d4cb3 114
sam_grove 5:3f93dd1d4cb3 115 /*
sam_grove 5:3f93dd1d4cb3 116 * Disable Interrupt list ED
sam_grove 5:3f93dd1d4cb3 117 */
sam_grove 5:3f93dd1d4cb3 118 bool disableInterruptList();
sam_grove 5:3f93dd1d4cb3 119
sam_grove 5:3f93dd1d4cb3 120 //Lock processing
sam_grove 5:3f93dd1d4cb3 121 void lock();
sam_grove 5:3f93dd1d4cb3 122
sam_grove 5:3f93dd1d4cb3 123 void unlock();
sam_grove 5:3f93dd1d4cb3 124
sam_grove 5:3f93dd1d4cb3 125
sam_grove 5:3f93dd1d4cb3 126 protected:
sam_grove 5:3f93dd1d4cb3 127 /*
sam_grove 5:3f93dd1d4cb3 128 * Virtual method called when a device has been connected
sam_grove 5:3f93dd1d4cb3 129 *
sam_grove 5:3f93dd1d4cb3 130 * @param hub hub number of the device
sam_grove 5:3f93dd1d4cb3 131 * @param port port number of the device
sam_grove 5:3f93dd1d4cb3 132 * @param lowSpeed 1 if low speed, 0 otherwise
sam_grove 5:3f93dd1d4cb3 133 */
sam_grove 5:3f93dd1d4cb3 134 virtual void deviceConnected(int hub, int port, bool lowSpeed) {};
sam_grove 5:3f93dd1d4cb3 135
sam_grove 5:3f93dd1d4cb3 136 /*
sam_grove 5:3f93dd1d4cb3 137 * Virtuel method called when a device has been disconnected
sam_grove 5:3f93dd1d4cb3 138 *
sam_grove 5:3f93dd1d4cb3 139 * @param hub hub number of the device
sam_grove 5:3f93dd1d4cb3 140 * @param port port number of the device
sam_grove 5:3f93dd1d4cb3 141 * @param addr list of the TDs which have been completed to dequeue freed TDs
sam_grove 5:3f93dd1d4cb3 142 */
sam_grove 5:3f93dd1d4cb3 143 virtual void deviceDisconnected(int hub, int port, volatile uint32_t addr) {};
sam_grove 5:3f93dd1d4cb3 144
sam_grove 5:3f93dd1d4cb3 145 /*
sam_grove 5:3f93dd1d4cb3 146 * Virtual method called when a transfer has been completed
sam_grove 5:3f93dd1d4cb3 147 *
sam_grove 5:3f93dd1d4cb3 148 * @param addr list of the TDs which have been completed
sam_grove 5:3f93dd1d4cb3 149 */
sam_grove 5:3f93dd1d4cb3 150 virtual void transferCompleted(volatile uint32_t addr){};
sam_grove 5:3f93dd1d4cb3 151
sam_grove 5:3f93dd1d4cb3 152 /*
sam_grove 5:3f93dd1d4cb3 153 * Find a memory section for a new ED
sam_grove 5:3f93dd1d4cb3 154 *
sam_grove 5:3f93dd1d4cb3 155 * @returns the address of this section
sam_grove 5:3f93dd1d4cb3 156 */
sam_grove 5:3f93dd1d4cb3 157 volatile uint8_t * getED();
sam_grove 5:3f93dd1d4cb3 158
sam_grove 5:3f93dd1d4cb3 159 /*
sam_grove 5:3f93dd1d4cb3 160 * Find a memory section for a new TD
sam_grove 5:3f93dd1d4cb3 161 *
sam_grove 5:3f93dd1d4cb3 162 * @returns the address of this section
sam_grove 5:3f93dd1d4cb3 163 */
sam_grove 5:3f93dd1d4cb3 164 volatile uint8_t * getTD();
sam_grove 5:3f93dd1d4cb3 165
sam_grove 5:3f93dd1d4cb3 166 /*
sam_grove 5:3f93dd1d4cb3 167 * Release a previous memory section reserved for an ED
sam_grove 5:3f93dd1d4cb3 168 *
sam_grove 5:3f93dd1d4cb3 169 * @param ed address of the ED
sam_grove 5:3f93dd1d4cb3 170 */
sam_grove 5:3f93dd1d4cb3 171 void freeED(volatile uint8_t * ed);
sam_grove 5:3f93dd1d4cb3 172
sam_grove 5:3f93dd1d4cb3 173 /*
sam_grove 5:3f93dd1d4cb3 174 * Release a previous memory section reserved for an TD
sam_grove 5:3f93dd1d4cb3 175 *
sam_grove 5:3f93dd1d4cb3 176 * @param ed address of the TD
sam_grove 5:3f93dd1d4cb3 177 */
sam_grove 5:3f93dd1d4cb3 178 void freeTD(volatile uint8_t * td);
sam_grove 5:3f93dd1d4cb3 179
sam_grove 5:3f93dd1d4cb3 180
sam_grove 5:3f93dd1d4cb3 181 private:
sam_grove 5:3f93dd1d4cb3 182 static void _usbisr(void);
sam_grove 5:3f93dd1d4cb3 183 void UsbIrqhandler();
sam_grove 5:3f93dd1d4cb3 184
sam_grove 5:3f93dd1d4cb3 185 void memInit();
sam_grove 5:3f93dd1d4cb3 186
sam_grove 5:3f93dd1d4cb3 187 void process();
sam_grove 5:3f93dd1d4cb3 188
sam_grove 5:3f93dd1d4cb3 189 static void staticCb(void const* p);
sam_grove 5:3f93dd1d4cb3 190
sam_grove 5:3f93dd1d4cb3 191 HCCA volatile * usb_hcca; //256 bytes aligned!
sam_grove 5:3f93dd1d4cb3 192 uint8_t volatile * usb_edBuf; //4 bytes aligned!
sam_grove 5:3f93dd1d4cb3 193 uint8_t volatile * usb_tdBuf; //4 bytes aligned!
sam_grove 5:3f93dd1d4cb3 194
sam_grove 5:3f93dd1d4cb3 195 static USBHALHost * instHost;
sam_grove 5:3f93dd1d4cb3 196
sam_grove 5:3f93dd1d4cb3 197 bool volatile edBufAlloc[MAX_ENDPOINT];
sam_grove 5:3f93dd1d4cb3 198 bool volatile tdBufAlloc[MAX_TD];
sam_grove 5:3f93dd1d4cb3 199
sam_grove 5:3f93dd1d4cb3 200 //RTOS impl
sam_grove 5:3f93dd1d4cb3 201 Thread thread;
sam_grove 5:3f93dd1d4cb3 202 Mutex mtx;
sam_grove 5:3f93dd1d4cb3 203
sam_grove 5:3f93dd1d4cb3 204 };
sam_grove 5:3f93dd1d4cb3 205
sam_grove 5:3f93dd1d4cb3 206 #endif