Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 5:3f93dd1d4cb3 1 /* mbed Microcontroller Library
sam_grove 5:3f93dd1d4cb3 2 * Copyright (c) 2006-2013 ARM Limited
sam_grove 5:3f93dd1d4cb3 3 *
sam_grove 5:3f93dd1d4cb3 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 5:3f93dd1d4cb3 5 * you may not use this file except in compliance with the License.
sam_grove 5:3f93dd1d4cb3 6 * You may obtain a copy of the License at
sam_grove 5:3f93dd1d4cb3 7 *
sam_grove 5:3f93dd1d4cb3 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 5:3f93dd1d4cb3 9 *
sam_grove 5:3f93dd1d4cb3 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 5:3f93dd1d4cb3 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 5:3f93dd1d4cb3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 5:3f93dd1d4cb3 13 * See the License for the specific language governing permissions and
sam_grove 5:3f93dd1d4cb3 14 * limitations under the License.
sam_grove 5:3f93dd1d4cb3 15 */
sam_grove 5:3f93dd1d4cb3 16 #ifndef MBED_TICKER_H
sam_grove 5:3f93dd1d4cb3 17 #define MBED_TICKER_H
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 #include "TimerEvent.h"
sam_grove 5:3f93dd1d4cb3 20 #include "FunctionPointer.h"
sam_grove 5:3f93dd1d4cb3 21 #include "CallChain.h"
sam_grove 5:3f93dd1d4cb3 22
sam_grove 5:3f93dd1d4cb3 23 namespace mbed {
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 /** A Ticker is used to call a function at a recurring interval
sam_grove 5:3f93dd1d4cb3 26 *
sam_grove 5:3f93dd1d4cb3 27 * You can use as many seperate Ticker objects as you require.
sam_grove 5:3f93dd1d4cb3 28 *
sam_grove 5:3f93dd1d4cb3 29 * Example:
sam_grove 5:3f93dd1d4cb3 30 * @code
sam_grove 5:3f93dd1d4cb3 31 * // Toggle the blinking led after 5 seconds
sam_grove 5:3f93dd1d4cb3 32 *
sam_grove 5:3f93dd1d4cb3 33 * #include "mbed.h"
sam_grove 5:3f93dd1d4cb3 34 *
sam_grove 5:3f93dd1d4cb3 35 * Ticker timer;
sam_grove 5:3f93dd1d4cb3 36 * DigitalOut led1(LED1);
sam_grove 5:3f93dd1d4cb3 37 * DigitalOut led2(LED2);
sam_grove 5:3f93dd1d4cb3 38 *
sam_grove 5:3f93dd1d4cb3 39 * int flip = 0;
sam_grove 5:3f93dd1d4cb3 40 *
sam_grove 5:3f93dd1d4cb3 41 * void attime() {
sam_grove 5:3f93dd1d4cb3 42 * flip = !flip;
sam_grove 5:3f93dd1d4cb3 43 * }
sam_grove 5:3f93dd1d4cb3 44 *
sam_grove 5:3f93dd1d4cb3 45 * int main() {
sam_grove 5:3f93dd1d4cb3 46 * timer.attach(&attime, 5);
sam_grove 5:3f93dd1d4cb3 47 * while(1) {
sam_grove 5:3f93dd1d4cb3 48 * if(flip == 0) {
sam_grove 5:3f93dd1d4cb3 49 * led1 = !led1;
sam_grove 5:3f93dd1d4cb3 50 * } else {
sam_grove 5:3f93dd1d4cb3 51 * led2 = !led2;
sam_grove 5:3f93dd1d4cb3 52 * }
sam_grove 5:3f93dd1d4cb3 53 * wait(0.2);
sam_grove 5:3f93dd1d4cb3 54 * }
sam_grove 5:3f93dd1d4cb3 55 * }
sam_grove 5:3f93dd1d4cb3 56 * @endcode
sam_grove 5:3f93dd1d4cb3 57 */
sam_grove 5:3f93dd1d4cb3 58 class Ticker : public TimerEvent {
sam_grove 5:3f93dd1d4cb3 59
sam_grove 5:3f93dd1d4cb3 60 public:
sam_grove 5:3f93dd1d4cb3 61
sam_grove 5:3f93dd1d4cb3 62 /** Attach a function to be called by the Ticker, specifiying the interval in seconds
sam_grove 5:3f93dd1d4cb3 63 *
sam_grove 5:3f93dd1d4cb3 64 * @param fptr pointer to the function to be called
sam_grove 5:3f93dd1d4cb3 65 * @param t the time between calls in seconds
sam_grove 5:3f93dd1d4cb3 66 *
sam_grove 5:3f93dd1d4cb3 67 * @returns
sam_grove 5:3f93dd1d4cb3 68 * The function object created for 'fptr'
sam_grove 5:3f93dd1d4cb3 69 */
sam_grove 5:3f93dd1d4cb3 70 pFunctionPointer_t attach(void (*fptr)(void), float t) {
sam_grove 5:3f93dd1d4cb3 71 return attach_us(fptr, t * 1000000.0f);
sam_grove 5:3f93dd1d4cb3 72 }
sam_grove 5:3f93dd1d4cb3 73
sam_grove 5:3f93dd1d4cb3 74 /** Add a function to be called by the Ticker at the end of the call chain
sam_grove 5:3f93dd1d4cb3 75 *
sam_grove 5:3f93dd1d4cb3 76 * @param fptr the function to add
sam_grove 5:3f93dd1d4cb3 77 *
sam_grove 5:3f93dd1d4cb3 78 * @returns
sam_grove 5:3f93dd1d4cb3 79 * The function object created for 'fptr'
sam_grove 5:3f93dd1d4cb3 80 */
sam_grove 5:3f93dd1d4cb3 81 pFunctionPointer_t add_function(void (*fptr)(void)) {
sam_grove 5:3f93dd1d4cb3 82 return add_function_helper(fptr);
sam_grove 5:3f93dd1d4cb3 83 }
sam_grove 5:3f93dd1d4cb3 84
sam_grove 5:3f93dd1d4cb3 85 /** Add a function to be called by the Ticker at the beginning of the call chain
sam_grove 5:3f93dd1d4cb3 86 *
sam_grove 5:3f93dd1d4cb3 87 * @param fptr the function to add
sam_grove 5:3f93dd1d4cb3 88 *
sam_grove 5:3f93dd1d4cb3 89 * @returns
sam_grove 5:3f93dd1d4cb3 90 * The function object created for 'fptr'
sam_grove 5:3f93dd1d4cb3 91 */
sam_grove 5:3f93dd1d4cb3 92 pFunctionPointer_t add_function_front(void (*fptr)(void)) {
sam_grove 5:3f93dd1d4cb3 93 return add_function_helper(fptr, true);
sam_grove 5:3f93dd1d4cb3 94 }
sam_grove 5:3f93dd1d4cb3 95
sam_grove 5:3f93dd1d4cb3 96 /** Attach a member function to be called by the Ticker, specifiying the interval in seconds
sam_grove 5:3f93dd1d4cb3 97 *
sam_grove 5:3f93dd1d4cb3 98 * @param tptr pointer to the object to call the member function on
sam_grove 5:3f93dd1d4cb3 99 * @param mptr pointer to the member function to be called
sam_grove 5:3f93dd1d4cb3 100 * @param t the time between calls in seconds
sam_grove 5:3f93dd1d4cb3 101 *
sam_grove 5:3f93dd1d4cb3 102 * @returns
sam_grove 5:3f93dd1d4cb3 103 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 104 */
sam_grove 5:3f93dd1d4cb3 105 template<typename T>
sam_grove 5:3f93dd1d4cb3 106 pFunctionPointer_t attach(T* tptr, void (T::*mptr)(void), float t) {
sam_grove 5:3f93dd1d4cb3 107 return attach_us(tptr, mptr, t * 1000000.0f);
sam_grove 5:3f93dd1d4cb3 108 }
sam_grove 5:3f93dd1d4cb3 109
sam_grove 5:3f93dd1d4cb3 110 /** Add a function to be called by the Ticker at the end of the call chain
sam_grove 5:3f93dd1d4cb3 111 *
sam_grove 5:3f93dd1d4cb3 112 * @param tptr pointer to the object to call the member function on
sam_grove 5:3f93dd1d4cb3 113 * @param mptr pointer to the member function to be called
sam_grove 5:3f93dd1d4cb3 114 *
sam_grove 5:3f93dd1d4cb3 115 * @returns
sam_grove 5:3f93dd1d4cb3 116 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 117 */
sam_grove 5:3f93dd1d4cb3 118 template<typename T>
sam_grove 5:3f93dd1d4cb3 119 pFunctionPointer_t add_function(T* tptr, void (T::*mptr)(void)) {
sam_grove 5:3f93dd1d4cb3 120 return add_function_helper(tptr, mptr);
sam_grove 5:3f93dd1d4cb3 121 }
sam_grove 5:3f93dd1d4cb3 122
sam_grove 5:3f93dd1d4cb3 123 /** Add a function to be called by the Ticker at the beginning of the call chain
sam_grove 5:3f93dd1d4cb3 124 *
sam_grove 5:3f93dd1d4cb3 125 * @param tptr pointer to the object to call the member function on
sam_grove 5:3f93dd1d4cb3 126 * @param mptr pointer to the member function to be called
sam_grove 5:3f93dd1d4cb3 127 *
sam_grove 5:3f93dd1d4cb3 128 * @returns
sam_grove 5:3f93dd1d4cb3 129 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 130 */
sam_grove 5:3f93dd1d4cb3 131 template<typename T>
sam_grove 5:3f93dd1d4cb3 132 pFunctionPointer_t add_function_front(T* tptr, void (T::*mptr)(void)) {
sam_grove 5:3f93dd1d4cb3 133 return add_function_helper(tptr, mptr, true);
sam_grove 5:3f93dd1d4cb3 134 }
sam_grove 5:3f93dd1d4cb3 135
sam_grove 5:3f93dd1d4cb3 136 /** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
sam_grove 5:3f93dd1d4cb3 137 *
sam_grove 5:3f93dd1d4cb3 138 * @param fptr pointer to the function to be called
sam_grove 5:3f93dd1d4cb3 139 * @param t the time between calls in micro-seconds
sam_grove 5:3f93dd1d4cb3 140 *
sam_grove 5:3f93dd1d4cb3 141 * @returns
sam_grove 5:3f93dd1d4cb3 142 * The function object created for 'fptr'
sam_grove 5:3f93dd1d4cb3 143 */
sam_grove 5:3f93dd1d4cb3 144 pFunctionPointer_t attach_us(void (*fptr)(void), unsigned int t) {
sam_grove 5:3f93dd1d4cb3 145 _chain.clear();
sam_grove 5:3f93dd1d4cb3 146 pFunctionPointer_t pf = _chain.add(fptr);
sam_grove 5:3f93dd1d4cb3 147 setup(t);
sam_grove 5:3f93dd1d4cb3 148 return pf;
sam_grove 5:3f93dd1d4cb3 149 }
sam_grove 5:3f93dd1d4cb3 150
sam_grove 5:3f93dd1d4cb3 151 /** Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
sam_grove 5:3f93dd1d4cb3 152 *
sam_grove 5:3f93dd1d4cb3 153 * @param tptr pointer to the object to call the member function on
sam_grove 5:3f93dd1d4cb3 154 * @param mptr pointer to the member function to be called
sam_grove 5:3f93dd1d4cb3 155 * @param t the time between calls in micro-seconds
sam_grove 5:3f93dd1d4cb3 156 *
sam_grove 5:3f93dd1d4cb3 157 * @returns
sam_grove 5:3f93dd1d4cb3 158 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 159 */
sam_grove 5:3f93dd1d4cb3 160 template<typename T>
sam_grove 5:3f93dd1d4cb3 161 pFunctionPointer_t attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) {
sam_grove 5:3f93dd1d4cb3 162 _chain.clear();
sam_grove 5:3f93dd1d4cb3 163 pFunctionPointer_t pf = _chain.add(tptr, mptr);
sam_grove 5:3f93dd1d4cb3 164 setup(t);
sam_grove 5:3f93dd1d4cb3 165 return pf;
sam_grove 5:3f93dd1d4cb3 166 }
sam_grove 5:3f93dd1d4cb3 167
sam_grove 5:3f93dd1d4cb3 168 /** Detach the function
sam_grove 5:3f93dd1d4cb3 169 */
sam_grove 5:3f93dd1d4cb3 170 void detach();
sam_grove 5:3f93dd1d4cb3 171
sam_grove 5:3f93dd1d4cb3 172 /** Remove a function from the Ticker's call chain
sam_grove 5:3f93dd1d4cb3 173 *
sam_grove 5:3f93dd1d4cb3 174 * @param pf the function object to remove
sam_grove 5:3f93dd1d4cb3 175 *
sam_grove 5:3f93dd1d4cb3 176 * @returns
sam_grove 5:3f93dd1d4cb3 177 * true if the function was found and removed, false otherwise
sam_grove 5:3f93dd1d4cb3 178 */
sam_grove 5:3f93dd1d4cb3 179 bool remove_function(pFunctionPointer_t pf) {
sam_grove 5:3f93dd1d4cb3 180 bool res = _chain.remove(pf);
sam_grove 5:3f93dd1d4cb3 181 if (res && _chain.size() == 0)
sam_grove 5:3f93dd1d4cb3 182 detach();
sam_grove 5:3f93dd1d4cb3 183 return res;
sam_grove 5:3f93dd1d4cb3 184 }
sam_grove 5:3f93dd1d4cb3 185
sam_grove 5:3f93dd1d4cb3 186 protected:
sam_grove 5:3f93dd1d4cb3 187 void setup(unsigned int t);
sam_grove 5:3f93dd1d4cb3 188 pFunctionPointer_t add_function_helper(void (*fptr)(void), bool front=false);
sam_grove 5:3f93dd1d4cb3 189 virtual void handler();
sam_grove 5:3f93dd1d4cb3 190
sam_grove 5:3f93dd1d4cb3 191 template<typename T>
sam_grove 5:3f93dd1d4cb3 192 pFunctionPointer_t add_function_helper(T* tptr, void (T::*mptr)(void), bool front=false) {
sam_grove 5:3f93dd1d4cb3 193 if (_chain.size() == 0)
sam_grove 5:3f93dd1d4cb3 194 return NULL;
sam_grove 5:3f93dd1d4cb3 195 return front ? _chain.add_front(tptr, mptr) : _chain.add(tptr, mptr);
sam_grove 5:3f93dd1d4cb3 196 }
sam_grove 5:3f93dd1d4cb3 197
sam_grove 5:3f93dd1d4cb3 198 unsigned int _delay;
sam_grove 5:3f93dd1d4cb3 199 CallChain _chain;
sam_grove 5:3f93dd1d4cb3 200 };
sam_grove 5:3f93dd1d4cb3 201
sam_grove 5:3f93dd1d4cb3 202 } // namespace mbed
sam_grove 5:3f93dd1d4cb3 203
sam_grove 5:3f93dd1d4cb3 204 #endif