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 #include "CallChain.h"
sam_grove 5:3f93dd1d4cb3 2 #include "cmsis.h"
sam_grove 5:3f93dd1d4cb3 3
sam_grove 5:3f93dd1d4cb3 4 namespace mbed {
sam_grove 5:3f93dd1d4cb3 5
sam_grove 5:3f93dd1d4cb3 6 CallChain::CallChain(int size) : _size(size), _elements(0) {
sam_grove 5:3f93dd1d4cb3 7 _chain = new pFunctionPointer_t[size]();
sam_grove 5:3f93dd1d4cb3 8 }
sam_grove 5:3f93dd1d4cb3 9
sam_grove 5:3f93dd1d4cb3 10 CallChain::~CallChain() {
sam_grove 5:3f93dd1d4cb3 11 clear();
sam_grove 5:3f93dd1d4cb3 12 delete _chain;
sam_grove 5:3f93dd1d4cb3 13 }
sam_grove 5:3f93dd1d4cb3 14
sam_grove 5:3f93dd1d4cb3 15 pFunctionPointer_t CallChain::add(void (*function)(void)) {
sam_grove 5:3f93dd1d4cb3 16 return common_add(new FunctionPointer(function));
sam_grove 5:3f93dd1d4cb3 17 }
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 pFunctionPointer_t CallChain::add_front(void (*function)(void)) {
sam_grove 5:3f93dd1d4cb3 20 return common_add_front(new FunctionPointer(function));
sam_grove 5:3f93dd1d4cb3 21 }
sam_grove 5:3f93dd1d4cb3 22
sam_grove 5:3f93dd1d4cb3 23 int CallChain::size() const {
sam_grove 5:3f93dd1d4cb3 24 return _elements;
sam_grove 5:3f93dd1d4cb3 25 }
sam_grove 5:3f93dd1d4cb3 26
sam_grove 5:3f93dd1d4cb3 27 pFunctionPointer_t CallChain::get(int i) const {
sam_grove 5:3f93dd1d4cb3 28 if (i < 0 || i >= _elements)
sam_grove 5:3f93dd1d4cb3 29 return NULL;
sam_grove 5:3f93dd1d4cb3 30 return _chain[i];
sam_grove 5:3f93dd1d4cb3 31 }
sam_grove 5:3f93dd1d4cb3 32
sam_grove 5:3f93dd1d4cb3 33 int CallChain::find(pFunctionPointer_t f) const {
sam_grove 5:3f93dd1d4cb3 34 for (int i = 0; i < _elements; i++)
sam_grove 5:3f93dd1d4cb3 35 if (f == _chain[i])
sam_grove 5:3f93dd1d4cb3 36 return i;
sam_grove 5:3f93dd1d4cb3 37 return -1;
sam_grove 5:3f93dd1d4cb3 38 }
sam_grove 5:3f93dd1d4cb3 39
sam_grove 5:3f93dd1d4cb3 40 void CallChain::clear() {
sam_grove 5:3f93dd1d4cb3 41 __disable_irq();
sam_grove 5:3f93dd1d4cb3 42 for(int i = 0; i < _elements; i ++) {
sam_grove 5:3f93dd1d4cb3 43 delete _chain[i];
sam_grove 5:3f93dd1d4cb3 44 _chain[i] = NULL;
sam_grove 5:3f93dd1d4cb3 45 }
sam_grove 5:3f93dd1d4cb3 46 _elements = 0;
sam_grove 5:3f93dd1d4cb3 47 __enable_irq();
sam_grove 5:3f93dd1d4cb3 48 }
sam_grove 5:3f93dd1d4cb3 49
sam_grove 5:3f93dd1d4cb3 50 bool CallChain::remove(pFunctionPointer_t f) {
sam_grove 5:3f93dd1d4cb3 51 int i;
sam_grove 5:3f93dd1d4cb3 52
sam_grove 5:3f93dd1d4cb3 53 if ((i = find(f)) == -1)
sam_grove 5:3f93dd1d4cb3 54 return false;
sam_grove 5:3f93dd1d4cb3 55 __disable_irq();
sam_grove 5:3f93dd1d4cb3 56 if (i != _elements - 1)
sam_grove 5:3f93dd1d4cb3 57 memmove(_chain + i, _chain + i + 1, (_elements - i - 1) * sizeof(pFunctionPointer_t));
sam_grove 5:3f93dd1d4cb3 58 delete f;
sam_grove 5:3f93dd1d4cb3 59 _elements --;
sam_grove 5:3f93dd1d4cb3 60 __enable_irq();
sam_grove 5:3f93dd1d4cb3 61 return true;
sam_grove 5:3f93dd1d4cb3 62 }
sam_grove 5:3f93dd1d4cb3 63
sam_grove 5:3f93dd1d4cb3 64 void CallChain::call() {
sam_grove 5:3f93dd1d4cb3 65 for(int i = 0; i < _elements; i++)
sam_grove 5:3f93dd1d4cb3 66 _chain[i]->call();
sam_grove 5:3f93dd1d4cb3 67 }
sam_grove 5:3f93dd1d4cb3 68
sam_grove 5:3f93dd1d4cb3 69 void CallChain::_check_size() {
sam_grove 5:3f93dd1d4cb3 70 if (_elements < _size)
sam_grove 5:3f93dd1d4cb3 71 return;
sam_grove 5:3f93dd1d4cb3 72 __disable_irq();
sam_grove 5:3f93dd1d4cb3 73 _size = (_size < 4) ? 4 : _size + 4;
sam_grove 5:3f93dd1d4cb3 74 pFunctionPointer_t* new_chain = new pFunctionPointer_t[_size]();
sam_grove 5:3f93dd1d4cb3 75 memcpy(new_chain, _chain, _elements * sizeof(pFunctionPointer_t));
sam_grove 5:3f93dd1d4cb3 76 delete _chain;
sam_grove 5:3f93dd1d4cb3 77 _chain = new_chain;
sam_grove 5:3f93dd1d4cb3 78 __enable_irq();
sam_grove 5:3f93dd1d4cb3 79 }
sam_grove 5:3f93dd1d4cb3 80
sam_grove 5:3f93dd1d4cb3 81 pFunctionPointer_t CallChain::common_add(pFunctionPointer_t pf) {
sam_grove 5:3f93dd1d4cb3 82 _check_size();
sam_grove 5:3f93dd1d4cb3 83 _chain[_elements] = pf;
sam_grove 5:3f93dd1d4cb3 84 _elements ++;
sam_grove 5:3f93dd1d4cb3 85 return pf;
sam_grove 5:3f93dd1d4cb3 86 }
sam_grove 5:3f93dd1d4cb3 87
sam_grove 5:3f93dd1d4cb3 88 pFunctionPointer_t CallChain::common_add_front(pFunctionPointer_t pf) {
sam_grove 5:3f93dd1d4cb3 89 _check_size();
sam_grove 5:3f93dd1d4cb3 90 __disable_irq();
sam_grove 5:3f93dd1d4cb3 91 memmove(_chain + 1, _chain, _elements * sizeof(pFunctionPointer_t));
sam_grove 5:3f93dd1d4cb3 92 _chain[0] = pf;
sam_grove 5:3f93dd1d4cb3 93 _elements ++;
sam_grove 5:3f93dd1d4cb3 94 __enable_irq();
sam_grove 5:3f93dd1d4cb3 95 return pf;
sam_grove 5:3f93dd1d4cb3 96 }
sam_grove 5:3f93dd1d4cb3 97
sam_grove 5:3f93dd1d4cb3 98 } // namespace mbed