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_ETHERNET_H
sam_grove 5:3f93dd1d4cb3 17 #define MBED_ETHERNET_H
sam_grove 5:3f93dd1d4cb3 18
sam_grove 5:3f93dd1d4cb3 19 #include "platform.h"
sam_grove 5:3f93dd1d4cb3 20
sam_grove 5:3f93dd1d4cb3 21 #if DEVICE_ETHERNET
sam_grove 5:3f93dd1d4cb3 22
sam_grove 5:3f93dd1d4cb3 23 namespace mbed {
sam_grove 5:3f93dd1d4cb3 24
sam_grove 5:3f93dd1d4cb3 25 /** An ethernet interface, to use with the ethernet pins.
sam_grove 5:3f93dd1d4cb3 26 *
sam_grove 5:3f93dd1d4cb3 27 * Example:
sam_grove 5:3f93dd1d4cb3 28 * @code
sam_grove 5:3f93dd1d4cb3 29 * // Read destination and source from every ethernet packet
sam_grove 5:3f93dd1d4cb3 30 *
sam_grove 5:3f93dd1d4cb3 31 * #include "mbed.h"
sam_grove 5:3f93dd1d4cb3 32 *
sam_grove 5:3f93dd1d4cb3 33 * Ethernet eth;
sam_grove 5:3f93dd1d4cb3 34 *
sam_grove 5:3f93dd1d4cb3 35 * int main() {
sam_grove 5:3f93dd1d4cb3 36 * char buf[0x600];
sam_grove 5:3f93dd1d4cb3 37 *
sam_grove 5:3f93dd1d4cb3 38 * while(1) {
sam_grove 5:3f93dd1d4cb3 39 * int size = eth.receive();
sam_grove 5:3f93dd1d4cb3 40 * if(size > 0) {
sam_grove 5:3f93dd1d4cb3 41 * eth.read(buf, size);
sam_grove 5:3f93dd1d4cb3 42 * printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n",
sam_grove 5:3f93dd1d4cb3 43 * buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
sam_grove 5:3f93dd1d4cb3 44 * printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
sam_grove 5:3f93dd1d4cb3 45 * buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
sam_grove 5:3f93dd1d4cb3 46 * }
sam_grove 5:3f93dd1d4cb3 47 *
sam_grove 5:3f93dd1d4cb3 48 * wait(1);
sam_grove 5:3f93dd1d4cb3 49 * }
sam_grove 5:3f93dd1d4cb3 50 * }
sam_grove 5:3f93dd1d4cb3 51 * @endcode
sam_grove 5:3f93dd1d4cb3 52 */
sam_grove 5:3f93dd1d4cb3 53 class Ethernet {
sam_grove 5:3f93dd1d4cb3 54
sam_grove 5:3f93dd1d4cb3 55 public:
sam_grove 5:3f93dd1d4cb3 56
sam_grove 5:3f93dd1d4cb3 57 /** Initialise the ethernet interface.
sam_grove 5:3f93dd1d4cb3 58 */
sam_grove 5:3f93dd1d4cb3 59 Ethernet();
sam_grove 5:3f93dd1d4cb3 60
sam_grove 5:3f93dd1d4cb3 61 /** Powers the hardware down.
sam_grove 5:3f93dd1d4cb3 62 */
sam_grove 5:3f93dd1d4cb3 63 virtual ~Ethernet();
sam_grove 5:3f93dd1d4cb3 64
sam_grove 5:3f93dd1d4cb3 65 enum Mode {
sam_grove 5:3f93dd1d4cb3 66 AutoNegotiate,
sam_grove 5:3f93dd1d4cb3 67 HalfDuplex10,
sam_grove 5:3f93dd1d4cb3 68 FullDuplex10,
sam_grove 5:3f93dd1d4cb3 69 HalfDuplex100,
sam_grove 5:3f93dd1d4cb3 70 FullDuplex100
sam_grove 5:3f93dd1d4cb3 71 };
sam_grove 5:3f93dd1d4cb3 72
sam_grove 5:3f93dd1d4cb3 73 /** Writes into an outgoing ethernet packet.
sam_grove 5:3f93dd1d4cb3 74 *
sam_grove 5:3f93dd1d4cb3 75 * It will append size bytes of data to the previously written bytes.
sam_grove 5:3f93dd1d4cb3 76 *
sam_grove 5:3f93dd1d4cb3 77 * @param data An array to write.
sam_grove 5:3f93dd1d4cb3 78 * @param size The size of data.
sam_grove 5:3f93dd1d4cb3 79 *
sam_grove 5:3f93dd1d4cb3 80 * @returns
sam_grove 5:3f93dd1d4cb3 81 * The number of written bytes.
sam_grove 5:3f93dd1d4cb3 82 */
sam_grove 5:3f93dd1d4cb3 83 int write(const char *data, int size);
sam_grove 5:3f93dd1d4cb3 84
sam_grove 5:3f93dd1d4cb3 85 /** Send an outgoing ethernet packet.
sam_grove 5:3f93dd1d4cb3 86 *
sam_grove 5:3f93dd1d4cb3 87 * After filling in the data in an ethernet packet it must be send.
sam_grove 5:3f93dd1d4cb3 88 * Send will provide a new packet to write to.
sam_grove 5:3f93dd1d4cb3 89 *
sam_grove 5:3f93dd1d4cb3 90 * @returns
sam_grove 5:3f93dd1d4cb3 91 * 0 if the sending was failed,
sam_grove 5:3f93dd1d4cb3 92 * 1 if the package is successfully sent.
sam_grove 5:3f93dd1d4cb3 93 */
sam_grove 5:3f93dd1d4cb3 94 int send();
sam_grove 5:3f93dd1d4cb3 95
sam_grove 5:3f93dd1d4cb3 96 /** Recevies an arrived ethernet packet.
sam_grove 5:3f93dd1d4cb3 97 *
sam_grove 5:3f93dd1d4cb3 98 * Receiving an ethernet packet will drop the last received ethernet packet
sam_grove 5:3f93dd1d4cb3 99 * and make a new ethernet packet ready to read.
sam_grove 5:3f93dd1d4cb3 100 * If no ethernet packet is arrived it will return 0.
sam_grove 5:3f93dd1d4cb3 101 *
sam_grove 5:3f93dd1d4cb3 102 * @returns
sam_grove 5:3f93dd1d4cb3 103 * 0 if no ethernet packet is arrived,
sam_grove 5:3f93dd1d4cb3 104 * or the size of the arrived packet.
sam_grove 5:3f93dd1d4cb3 105 */
sam_grove 5:3f93dd1d4cb3 106 int receive();
sam_grove 5:3f93dd1d4cb3 107
sam_grove 5:3f93dd1d4cb3 108 /** Read from an recevied ethernet packet.
sam_grove 5:3f93dd1d4cb3 109 *
sam_grove 5:3f93dd1d4cb3 110 * After receive returnd a number bigger than 0it is
sam_grove 5:3f93dd1d4cb3 111 * possible to read bytes from this packet.
sam_grove 5:3f93dd1d4cb3 112 * Read will write up to size bytes into data.
sam_grove 5:3f93dd1d4cb3 113 *
sam_grove 5:3f93dd1d4cb3 114 * It is possible to use read multible times.
sam_grove 5:3f93dd1d4cb3 115 * Each time read will start reading after the last read byte before.
sam_grove 5:3f93dd1d4cb3 116 *
sam_grove 5:3f93dd1d4cb3 117 * @returns
sam_grove 5:3f93dd1d4cb3 118 * The number of byte read.
sam_grove 5:3f93dd1d4cb3 119 */
sam_grove 5:3f93dd1d4cb3 120 int read(char *data, int size);
sam_grove 5:3f93dd1d4cb3 121
sam_grove 5:3f93dd1d4cb3 122 /** Gives the ethernet address of the mbed.
sam_grove 5:3f93dd1d4cb3 123 *
sam_grove 5:3f93dd1d4cb3 124 * @param mac Must be a pointer to a 6 byte char array to copy the ethernet address in.
sam_grove 5:3f93dd1d4cb3 125 */
sam_grove 5:3f93dd1d4cb3 126 void address(char *mac);
sam_grove 5:3f93dd1d4cb3 127
sam_grove 5:3f93dd1d4cb3 128 /** Returns if an ethernet link is pressent or not. It takes a wile after Ethernet initializion to show up.
sam_grove 5:3f93dd1d4cb3 129 *
sam_grove 5:3f93dd1d4cb3 130 * @returns
sam_grove 5:3f93dd1d4cb3 131 * 0 if no ethernet link is pressent,
sam_grove 5:3f93dd1d4cb3 132 * 1 if an ethernet link is pressent.
sam_grove 5:3f93dd1d4cb3 133 *
sam_grove 5:3f93dd1d4cb3 134 * Example:
sam_grove 5:3f93dd1d4cb3 135 * @code
sam_grove 5:3f93dd1d4cb3 136 * // Using the Ethernet link function
sam_grove 5:3f93dd1d4cb3 137 * #include "mbed.h"
sam_grove 5:3f93dd1d4cb3 138 *
sam_grove 5:3f93dd1d4cb3 139 * Ethernet eth;
sam_grove 5:3f93dd1d4cb3 140 *
sam_grove 5:3f93dd1d4cb3 141 * int main() {
sam_grove 5:3f93dd1d4cb3 142 * wait(1); // Needed after startup.
sam_grove 5:3f93dd1d4cb3 143 * if (eth.link()) {
sam_grove 5:3f93dd1d4cb3 144 * printf("online\n");
sam_grove 5:3f93dd1d4cb3 145 * } else {
sam_grove 5:3f93dd1d4cb3 146 * printf("offline\n");
sam_grove 5:3f93dd1d4cb3 147 * }
sam_grove 5:3f93dd1d4cb3 148 * }
sam_grove 5:3f93dd1d4cb3 149 * @endcode
sam_grove 5:3f93dd1d4cb3 150 */
sam_grove 5:3f93dd1d4cb3 151 int link();
sam_grove 5:3f93dd1d4cb3 152
sam_grove 5:3f93dd1d4cb3 153 /** Sets the speed and duplex parameters of an ethernet link
sam_grove 5:3f93dd1d4cb3 154 *
sam_grove 5:3f93dd1d4cb3 155 * - AutoNegotiate Auto negotiate speed and duplex
sam_grove 5:3f93dd1d4cb3 156 * - HalfDuplex10 10 Mbit, half duplex
sam_grove 5:3f93dd1d4cb3 157 * - FullDuplex10 10 Mbit, full duplex
sam_grove 5:3f93dd1d4cb3 158 * - HalfDuplex100 100 Mbit, half duplex
sam_grove 5:3f93dd1d4cb3 159 * - FullDuplex100 100 Mbit, full duplex
sam_grove 5:3f93dd1d4cb3 160 *
sam_grove 5:3f93dd1d4cb3 161 * @param mode the speed and duplex mode to set the link to:
sam_grove 5:3f93dd1d4cb3 162 */
sam_grove 5:3f93dd1d4cb3 163 void set_link(Mode mode);
sam_grove 5:3f93dd1d4cb3 164 };
sam_grove 5:3f93dd1d4cb3 165
sam_grove 5:3f93dd1d4cb3 166 } // namespace mbed
sam_grove 5:3f93dd1d4cb3 167
sam_grove 5:3f93dd1d4cb3 168 #endif
sam_grove 5:3f93dd1d4cb3 169
sam_grove 5:3f93dd1d4cb3 170 #endif