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 <stdio.h>
sam_grove 5:3f93dd1d4cb3 17 #include "mbed_interface.h"
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 #include "gpio_api.h"
sam_grove 5:3f93dd1d4cb3 20 #include "wait_api.h"
sam_grove 5:3f93dd1d4cb3 21 #include "semihost_api.h"
sam_grove 5:3f93dd1d4cb3 22 #include "error.h"
sam_grove 5:3f93dd1d4cb3 23 #include "toolchain.h"
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 #if DEVICE_SEMIHOST
sam_grove 5:3f93dd1d4cb3 26
sam_grove 5:3f93dd1d4cb3 27 // return true if a debugger is attached, indicating mbed interface is connected
sam_grove 5:3f93dd1d4cb3 28 int mbed_interface_connected(void) {
sam_grove 5:3f93dd1d4cb3 29 return semihost_connected();
sam_grove 5:3f93dd1d4cb3 30 }
sam_grove 5:3f93dd1d4cb3 31
sam_grove 5:3f93dd1d4cb3 32 int mbed_interface_reset(void) {
sam_grove 5:3f93dd1d4cb3 33 if (mbed_interface_connected()) {
sam_grove 5:3f93dd1d4cb3 34 semihost_reset();
sam_grove 5:3f93dd1d4cb3 35 return 0;
sam_grove 5:3f93dd1d4cb3 36 } else {
sam_grove 5:3f93dd1d4cb3 37 return -1;
sam_grove 5:3f93dd1d4cb3 38 }
sam_grove 5:3f93dd1d4cb3 39 }
sam_grove 5:3f93dd1d4cb3 40
sam_grove 5:3f93dd1d4cb3 41 WEAK int mbed_interface_uid(char *uid);
sam_grove 5:3f93dd1d4cb3 42 WEAK int mbed_interface_uid(char *uid) {
sam_grove 5:3f93dd1d4cb3 43 if (mbed_interface_connected()) {
sam_grove 5:3f93dd1d4cb3 44 return semihost_uid(uid); // Returns 0 if successful, -1 on failure
sam_grove 5:3f93dd1d4cb3 45 } else {
sam_grove 5:3f93dd1d4cb3 46 uid[0] = 0;
sam_grove 5:3f93dd1d4cb3 47 return -1;
sam_grove 5:3f93dd1d4cb3 48 }
sam_grove 5:3f93dd1d4cb3 49 }
sam_grove 5:3f93dd1d4cb3 50
sam_grove 5:3f93dd1d4cb3 51 int mbed_interface_disconnect(void) {
sam_grove 5:3f93dd1d4cb3 52 int res;
sam_grove 5:3f93dd1d4cb3 53 if (mbed_interface_connected()) {
sam_grove 5:3f93dd1d4cb3 54 if ((res = semihost_disabledebug()) != 0)
sam_grove 5:3f93dd1d4cb3 55 return res;
sam_grove 5:3f93dd1d4cb3 56 while (mbed_interface_connected());
sam_grove 5:3f93dd1d4cb3 57 return 0;
sam_grove 5:3f93dd1d4cb3 58 } else {
sam_grove 5:3f93dd1d4cb3 59 return -1;
sam_grove 5:3f93dd1d4cb3 60 }
sam_grove 5:3f93dd1d4cb3 61 }
sam_grove 5:3f93dd1d4cb3 62
sam_grove 5:3f93dd1d4cb3 63 int mbed_interface_powerdown(void) {
sam_grove 5:3f93dd1d4cb3 64 int res;
sam_grove 5:3f93dd1d4cb3 65 if (mbed_interface_connected()) {
sam_grove 5:3f93dd1d4cb3 66 if ((res = semihost_powerdown()) != 0)
sam_grove 5:3f93dd1d4cb3 67 return res;
sam_grove 5:3f93dd1d4cb3 68 while (mbed_interface_connected());
sam_grove 5:3f93dd1d4cb3 69 return 0;
sam_grove 5:3f93dd1d4cb3 70 } else {
sam_grove 5:3f93dd1d4cb3 71 return -1;
sam_grove 5:3f93dd1d4cb3 72 }
sam_grove 5:3f93dd1d4cb3 73 }
sam_grove 5:3f93dd1d4cb3 74
sam_grove 5:3f93dd1d4cb3 75 // for backward compatibility
sam_grove 5:3f93dd1d4cb3 76 void mbed_reset(void) {
sam_grove 5:3f93dd1d4cb3 77 mbed_interface_reset();
sam_grove 5:3f93dd1d4cb3 78 }
sam_grove 5:3f93dd1d4cb3 79
sam_grove 5:3f93dd1d4cb3 80 WEAK int mbed_uid(char *uid);
sam_grove 5:3f93dd1d4cb3 81 WEAK int mbed_uid(char *uid) {
sam_grove 5:3f93dd1d4cb3 82 return mbed_interface_uid(uid);
sam_grove 5:3f93dd1d4cb3 83 }
sam_grove 5:3f93dd1d4cb3 84 #endif
sam_grove 5:3f93dd1d4cb3 85
sam_grove 5:3f93dd1d4cb3 86 WEAK void mbed_mac_address(char *mac);
sam_grove 5:3f93dd1d4cb3 87 WEAK void mbed_mac_address(char *mac) {
sam_grove 5:3f93dd1d4cb3 88 #if DEVICE_SEMIHOST
sam_grove 5:3f93dd1d4cb3 89 char uid[DEVICE_ID_LENGTH + 1];
sam_grove 5:3f93dd1d4cb3 90 int i;
sam_grove 5:3f93dd1d4cb3 91
sam_grove 5:3f93dd1d4cb3 92 // if we have a UID, extract the MAC
sam_grove 5:3f93dd1d4cb3 93 if (mbed_interface_uid(uid) == 0) {
sam_grove 5:3f93dd1d4cb3 94 char *p = uid;
sam_grove 5:3f93dd1d4cb3 95 #if defined(DEVICE_MAC_OFFSET)
sam_grove 5:3f93dd1d4cb3 96 p += DEVICE_MAC_OFFSET;
sam_grove 5:3f93dd1d4cb3 97 #endif
sam_grove 5:3f93dd1d4cb3 98 for (i=0; i<6; i++) {
sam_grove 5:3f93dd1d4cb3 99 int byte;
sam_grove 5:3f93dd1d4cb3 100 sscanf(p, "%2x", &byte);
sam_grove 5:3f93dd1d4cb3 101 mac[i] = byte;
sam_grove 5:3f93dd1d4cb3 102 p += 2;
sam_grove 5:3f93dd1d4cb3 103 }
sam_grove 5:3f93dd1d4cb3 104 } else { // else return a default MAC
sam_grove 5:3f93dd1d4cb3 105 #endif
sam_grove 5:3f93dd1d4cb3 106 mac[0] = 0x00;
sam_grove 5:3f93dd1d4cb3 107 mac[1] = 0x02;
sam_grove 5:3f93dd1d4cb3 108 mac[2] = 0xF7;
sam_grove 5:3f93dd1d4cb3 109 mac[3] = 0xF0;
sam_grove 5:3f93dd1d4cb3 110 mac[4] = 0x00;
sam_grove 5:3f93dd1d4cb3 111 mac[5] = 0x00;
sam_grove 5:3f93dd1d4cb3 112 #if DEVICE_SEMIHOST
sam_grove 5:3f93dd1d4cb3 113 }
sam_grove 5:3f93dd1d4cb3 114 #endif
sam_grove 5:3f93dd1d4cb3 115 }