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 #include "Serial.h"
sam_grove 5:3f93dd1d4cb3 17 #include "wait_api.h"
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 #if DEVICE_SERIAL
sam_grove 5:3f93dd1d4cb3 20
sam_grove 5:3f93dd1d4cb3 21 namespace mbed {
sam_grove 5:3f93dd1d4cb3 22
sam_grove 5:3f93dd1d4cb3 23 Serial::Serial(PinName tx, PinName rx, const char *name) : Stream(name) {
sam_grove 5:3f93dd1d4cb3 24 serial_init(&_serial, tx, rx);
sam_grove 5:3f93dd1d4cb3 25 _baud = 9600;
sam_grove 5:3f93dd1d4cb3 26 serial_irq_handler(&_serial, Serial::_irq_handler, (uint32_t)this);
sam_grove 5:3f93dd1d4cb3 27 }
sam_grove 5:3f93dd1d4cb3 28
sam_grove 5:3f93dd1d4cb3 29 void Serial::baud(int baudrate) {
sam_grove 5:3f93dd1d4cb3 30 serial_baud(&_serial, baudrate);
sam_grove 5:3f93dd1d4cb3 31 _baud = baudrate;
sam_grove 5:3f93dd1d4cb3 32 }
sam_grove 5:3f93dd1d4cb3 33
sam_grove 5:3f93dd1d4cb3 34 void Serial::format(int bits, Parity parity, int stop_bits) {
sam_grove 5:3f93dd1d4cb3 35 serial_format(&_serial, bits, (SerialParity)parity, stop_bits);
sam_grove 5:3f93dd1d4cb3 36 }
sam_grove 5:3f93dd1d4cb3 37
sam_grove 5:3f93dd1d4cb3 38 int Serial::readable() {
sam_grove 5:3f93dd1d4cb3 39 return serial_readable(&_serial);
sam_grove 5:3f93dd1d4cb3 40 }
sam_grove 5:3f93dd1d4cb3 41
sam_grove 5:3f93dd1d4cb3 42
sam_grove 5:3f93dd1d4cb3 43 int Serial::writeable() {
sam_grove 5:3f93dd1d4cb3 44 return serial_writable(&_serial);
sam_grove 5:3f93dd1d4cb3 45 }
sam_grove 5:3f93dd1d4cb3 46
sam_grove 5:3f93dd1d4cb3 47 pFunctionPointer_t Serial::attach(void (*fptr)(void), IrqType type) {
sam_grove 5:3f93dd1d4cb3 48 pFunctionPointer_t pf = NULL;
sam_grove 5:3f93dd1d4cb3 49 _irq[type].clear();
sam_grove 5:3f93dd1d4cb3 50 if (fptr) {
sam_grove 5:3f93dd1d4cb3 51 pf = _irq[type].add(fptr);
sam_grove 5:3f93dd1d4cb3 52 serial_irq_set(&_serial, (SerialIrq)type, 1);
sam_grove 5:3f93dd1d4cb3 53 } else {
sam_grove 5:3f93dd1d4cb3 54 serial_irq_set(&_serial, (SerialIrq)type, 0);
sam_grove 5:3f93dd1d4cb3 55 }
sam_grove 5:3f93dd1d4cb3 56 return pf;
sam_grove 5:3f93dd1d4cb3 57 }
sam_grove 5:3f93dd1d4cb3 58
sam_grove 5:3f93dd1d4cb3 59 pFunctionPointer_t Serial::add_handler_helper(void (*fptr)(void), IrqType type, bool front) {
sam_grove 5:3f93dd1d4cb3 60 if (NULL == fptr)
sam_grove 5:3f93dd1d4cb3 61 return NULL;
sam_grove 5:3f93dd1d4cb3 62 pFunctionPointer_t pf = front ? _irq[type].add_front(fptr) : _irq[type].add(fptr);
sam_grove 5:3f93dd1d4cb3 63 serial_irq_set(&_serial, (SerialIrq)type, 1);
sam_grove 5:3f93dd1d4cb3 64 return pf;
sam_grove 5:3f93dd1d4cb3 65 }
sam_grove 5:3f93dd1d4cb3 66
sam_grove 5:3f93dd1d4cb3 67 bool Serial::remove_handler(pFunctionPointer_t pf, IrqType type) {
sam_grove 5:3f93dd1d4cb3 68 bool res = _irq[type].remove(pf);
sam_grove 5:3f93dd1d4cb3 69 if (res && _irq[type].size() == 0)
sam_grove 5:3f93dd1d4cb3 70 serial_irq_set(&_serial, (SerialIrq)type, 0);
sam_grove 5:3f93dd1d4cb3 71 return res;
sam_grove 5:3f93dd1d4cb3 72 }
sam_grove 5:3f93dd1d4cb3 73
sam_grove 5:3f93dd1d4cb3 74 void Serial::_irq_handler(uint32_t id, SerialIrq irq_type) {
sam_grove 5:3f93dd1d4cb3 75 Serial *handler = (Serial*)id;
sam_grove 5:3f93dd1d4cb3 76 handler->_irq[irq_type].call();
sam_grove 5:3f93dd1d4cb3 77 }
sam_grove 5:3f93dd1d4cb3 78
sam_grove 5:3f93dd1d4cb3 79 int Serial::_getc() {
sam_grove 5:3f93dd1d4cb3 80 return serial_getc(&_serial);
sam_grove 5:3f93dd1d4cb3 81 }
sam_grove 5:3f93dd1d4cb3 82
sam_grove 5:3f93dd1d4cb3 83 int Serial::_putc(int c) {
sam_grove 5:3f93dd1d4cb3 84 serial_putc(&_serial, c);
sam_grove 5:3f93dd1d4cb3 85 return c;
sam_grove 5:3f93dd1d4cb3 86 }
sam_grove 5:3f93dd1d4cb3 87
sam_grove 5:3f93dd1d4cb3 88 void Serial::send_break() {
sam_grove 5:3f93dd1d4cb3 89 // Wait for 1.5 frames before clearing the break condition
sam_grove 5:3f93dd1d4cb3 90 // This will have different effects on our platforms, but should
sam_grove 5:3f93dd1d4cb3 91 // ensure that we keep the break active for at least one frame.
sam_grove 5:3f93dd1d4cb3 92 // We consider a full frame (1 start bit + 8 data bits bits +
sam_grove 5:3f93dd1d4cb3 93 // 1 parity bit + 2 stop bits = 12 bits) for computation.
sam_grove 5:3f93dd1d4cb3 94 // One bit time (in us) = 1000000/_baud
sam_grove 5:3f93dd1d4cb3 95 // Twelve bits: 12000000/baud delay
sam_grove 5:3f93dd1d4cb3 96 // 1.5 frames: 18000000/baud delay
sam_grove 5:3f93dd1d4cb3 97 serial_break_set(&_serial);
sam_grove 5:3f93dd1d4cb3 98 wait_us(18000000/_baud);
sam_grove 5:3f93dd1d4cb3 99 serial_break_clear(&_serial);
sam_grove 5:3f93dd1d4cb3 100 }
sam_grove 5:3f93dd1d4cb3 101
sam_grove 5:3f93dd1d4cb3 102 } // namespace mbed
sam_grove 5:3f93dd1d4cb3 103
sam_grove 5:3f93dd1d4cb3 104 #endif