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 #ifndef MBED_INTERRUPTMANAGER_H
sam_grove 5:3f93dd1d4cb3 2 #define MBED_INTERRUPTMANAGER_H
sam_grove 5:3f93dd1d4cb3 3
sam_grove 5:3f93dd1d4cb3 4 #include "cmsis.h"
sam_grove 5:3f93dd1d4cb3 5 #include "CallChain.h"
sam_grove 5:3f93dd1d4cb3 6 #include <string.h>
sam_grove 5:3f93dd1d4cb3 7
sam_grove 5:3f93dd1d4cb3 8 namespace mbed {
sam_grove 5:3f93dd1d4cb3 9
sam_grove 5:3f93dd1d4cb3 10 /** Use this singleton if you need to chain interrupt handlers.
sam_grove 5:3f93dd1d4cb3 11 *
sam_grove 5:3f93dd1d4cb3 12 * Example (for LPC1768):
sam_grove 5:3f93dd1d4cb3 13 * @code
sam_grove 5:3f93dd1d4cb3 14 * #include "InterruptManager.h"
sam_grove 5:3f93dd1d4cb3 15 * #include "mbed.h"
sam_grove 5:3f93dd1d4cb3 16 *
sam_grove 5:3f93dd1d4cb3 17 * Ticker flipper;
sam_grove 5:3f93dd1d4cb3 18 * DigitalOut led1(LED1);
sam_grove 5:3f93dd1d4cb3 19 * DigitalOut led2(LED2);
sam_grove 5:3f93dd1d4cb3 20 *
sam_grove 5:3f93dd1d4cb3 21 * void flip(void) {
sam_grove 5:3f93dd1d4cb3 22 * led1 = !led1;
sam_grove 5:3f93dd1d4cb3 23 * }
sam_grove 5:3f93dd1d4cb3 24 *
sam_grove 5:3f93dd1d4cb3 25 * void handler(void) {
sam_grove 5:3f93dd1d4cb3 26 * led2 = !led1;
sam_grove 5:3f93dd1d4cb3 27 * }
sam_grove 5:3f93dd1d4cb3 28 *
sam_grove 5:3f93dd1d4cb3 29 * int main() {
sam_grove 5:3f93dd1d4cb3 30 * led1 = led2 = 0;
sam_grove 5:3f93dd1d4cb3 31 * flipper.attach(&flip, 1.0);
sam_grove 5:3f93dd1d4cb3 32 * InterruptManager::get()->add_handler(handler, TIMER3_IRQn);
sam_grove 5:3f93dd1d4cb3 33 * }
sam_grove 5:3f93dd1d4cb3 34 * @endcode
sam_grove 5:3f93dd1d4cb3 35 */
sam_grove 5:3f93dd1d4cb3 36 class InterruptManager {
sam_grove 5:3f93dd1d4cb3 37 public:
sam_grove 5:3f93dd1d4cb3 38 /** Return the only instance of this class
sam_grove 5:3f93dd1d4cb3 39 */
sam_grove 5:3f93dd1d4cb3 40 static InterruptManager* get();
sam_grove 5:3f93dd1d4cb3 41
sam_grove 5:3f93dd1d4cb3 42 /** Destroy the current instance of the interrupt manager
sam_grove 5:3f93dd1d4cb3 43 */
sam_grove 5:3f93dd1d4cb3 44 static void destroy();
sam_grove 5:3f93dd1d4cb3 45
sam_grove 5:3f93dd1d4cb3 46 /** Add a handler for an interrupt at the end of the handler list
sam_grove 5:3f93dd1d4cb3 47 *
sam_grove 5:3f93dd1d4cb3 48 * @param function the handler to add
sam_grove 5:3f93dd1d4cb3 49 * @param irq interrupt number
sam_grove 5:3f93dd1d4cb3 50 *
sam_grove 5:3f93dd1d4cb3 51 * @returns
sam_grove 5:3f93dd1d4cb3 52 * The function object created for 'function'
sam_grove 5:3f93dd1d4cb3 53 */
sam_grove 5:3f93dd1d4cb3 54 pFunctionPointer_t add_handler(void (*function)(void), IRQn_Type irq) {
sam_grove 5:3f93dd1d4cb3 55 return add_common(function, irq);
sam_grove 5:3f93dd1d4cb3 56 }
sam_grove 5:3f93dd1d4cb3 57
sam_grove 5:3f93dd1d4cb3 58 /** Add a handler for an interrupt at the beginning of the handler list
sam_grove 5:3f93dd1d4cb3 59 *
sam_grove 5:3f93dd1d4cb3 60 * @param function the handler to add
sam_grove 5:3f93dd1d4cb3 61 * @param irq interrupt number
sam_grove 5:3f93dd1d4cb3 62 *
sam_grove 5:3f93dd1d4cb3 63 * @returns
sam_grove 5:3f93dd1d4cb3 64 * The function object created for 'function'
sam_grove 5:3f93dd1d4cb3 65 */
sam_grove 5:3f93dd1d4cb3 66 pFunctionPointer_t add_handler_front(void (*function)(void), IRQn_Type irq) {
sam_grove 5:3f93dd1d4cb3 67 return add_common(function, irq, true);
sam_grove 5:3f93dd1d4cb3 68 }
sam_grove 5:3f93dd1d4cb3 69
sam_grove 5:3f93dd1d4cb3 70 /** Add a handler for an interrupt at the end of the handler list
sam_grove 5:3f93dd1d4cb3 71 *
sam_grove 5:3f93dd1d4cb3 72 * @param tptr pointer to the object that has the handler function
sam_grove 5:3f93dd1d4cb3 73 * @param mptr pointer to the actual handler function
sam_grove 5:3f93dd1d4cb3 74 * @param irq interrupt number
sam_grove 5:3f93dd1d4cb3 75 *
sam_grove 5:3f93dd1d4cb3 76 * @returns
sam_grove 5:3f93dd1d4cb3 77 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 78 */
sam_grove 5:3f93dd1d4cb3 79 template<typename T>
sam_grove 5:3f93dd1d4cb3 80 pFunctionPointer_t add_handler(T* tptr, void (T::*mptr)(void), IRQn_Type irq) {
sam_grove 5:3f93dd1d4cb3 81 return add_common(tptr, mptr, irq);
sam_grove 5:3f93dd1d4cb3 82 }
sam_grove 5:3f93dd1d4cb3 83
sam_grove 5:3f93dd1d4cb3 84 /** Add a handler for an interrupt at the beginning of the handler list
sam_grove 5:3f93dd1d4cb3 85 *
sam_grove 5:3f93dd1d4cb3 86 * @param tptr pointer to the object that has the handler function
sam_grove 5:3f93dd1d4cb3 87 * @param mptr pointer to the actual handler function
sam_grove 5:3f93dd1d4cb3 88 * @param irq interrupt number
sam_grove 5:3f93dd1d4cb3 89 *
sam_grove 5:3f93dd1d4cb3 90 * @returns
sam_grove 5:3f93dd1d4cb3 91 * The function object created for 'tptr' and 'mptr'
sam_grove 5:3f93dd1d4cb3 92 */
sam_grove 5:3f93dd1d4cb3 93 template<typename T>
sam_grove 5:3f93dd1d4cb3 94 pFunctionPointer_t add_handler_front(T* tptr, void (T::*mptr)(void), IRQn_Type irq) {
sam_grove 5:3f93dd1d4cb3 95 return add_common(tptr, mptr, irq, true);
sam_grove 5:3f93dd1d4cb3 96 }
sam_grove 5:3f93dd1d4cb3 97
sam_grove 5:3f93dd1d4cb3 98 /** Remove a handler from an interrupt
sam_grove 5:3f93dd1d4cb3 99 *
sam_grove 5:3f93dd1d4cb3 100 * @param handler the function object for the handler to remove
sam_grove 5:3f93dd1d4cb3 101 * @param irq the interrupt number
sam_grove 5:3f93dd1d4cb3 102 *
sam_grove 5:3f93dd1d4cb3 103 * @returns
sam_grove 5:3f93dd1d4cb3 104 * true if the handler was found and removed, false otherwise
sam_grove 5:3f93dd1d4cb3 105 */
sam_grove 5:3f93dd1d4cb3 106 bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq);
sam_grove 5:3f93dd1d4cb3 107
sam_grove 5:3f93dd1d4cb3 108 private:
sam_grove 5:3f93dd1d4cb3 109 InterruptManager();
sam_grove 5:3f93dd1d4cb3 110 ~InterruptManager();
sam_grove 5:3f93dd1d4cb3 111
sam_grove 5:3f93dd1d4cb3 112 // We declare the copy contructor and the assignment operator, but we don't
sam_grove 5:3f93dd1d4cb3 113 // implement them. This way, if someone tries to copy/assign our instance,
sam_grove 5:3f93dd1d4cb3 114 // he will get an error at compile time.
sam_grove 5:3f93dd1d4cb3 115 InterruptManager(const InterruptManager&);
sam_grove 5:3f93dd1d4cb3 116 InterruptManager& operator =(const InterruptManager&);
sam_grove 5:3f93dd1d4cb3 117
sam_grove 5:3f93dd1d4cb3 118 template<typename T>
sam_grove 5:3f93dd1d4cb3 119 pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) {
sam_grove 5:3f93dd1d4cb3 120 int irq_pos = get_irq_index(irq);
sam_grove 5:3f93dd1d4cb3 121 bool change = must_replace_vector(irq);
sam_grove 5:3f93dd1d4cb3 122
sam_grove 5:3f93dd1d4cb3 123 pFunctionPointer_t pf = front ? _chains[irq_pos]->add_front(tptr, mptr) : _chains[irq_pos]->add(tptr, mptr);
sam_grove 5:3f93dd1d4cb3 124 if (change)
sam_grove 5:3f93dd1d4cb3 125 NVIC_SetVector(irq, (uint32_t)&InterruptManager::static_irq_helper);
sam_grove 5:3f93dd1d4cb3 126 return pf;
sam_grove 5:3f93dd1d4cb3 127 }
sam_grove 5:3f93dd1d4cb3 128
sam_grove 5:3f93dd1d4cb3 129 pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front=false);
sam_grove 5:3f93dd1d4cb3 130 bool must_replace_vector(IRQn_Type irq);
sam_grove 5:3f93dd1d4cb3 131 int get_irq_index(IRQn_Type irq);
sam_grove 5:3f93dd1d4cb3 132 void irq_helper();
sam_grove 5:3f93dd1d4cb3 133 void add_helper(void (*function)(void), IRQn_Type irq, bool front=false);
sam_grove 5:3f93dd1d4cb3 134 static void static_irq_helper();
sam_grove 5:3f93dd1d4cb3 135
sam_grove 5:3f93dd1d4cb3 136 CallChain* _chains[NVIC_NUM_VECTORS];
sam_grove 5:3f93dd1d4cb3 137 static InterruptManager* _instance;
sam_grove 5:3f93dd1d4cb3 138 };
sam_grove 5:3f93dd1d4cb3 139
sam_grove 5:3f93dd1d4cb3 140 } // namespace mbed
sam_grove 5:3f93dd1d4cb3 141
sam_grove 5:3f93dd1d4cb3 142 #endif
sam_grove 5:3f93dd1d4cb3 143