mbed library sources modify the rtc/i2c

Dependents:   SSD1306_smart_watch

Fork of mbed-src by eunkyoung kim

Committer:
mbed_official
Date:
Thu Nov 21 10:45:04 2013 +0000
Revision:
48:40454ec5d50d
Parent:
13:0645d8841f51
Synchronized with git revision 5278dd43f2ce1cc2eb64aeb4aec3b6a05557cf7c

Full URL: https://github.com/mbedmicro/mbed/commit/5278dd43f2ce1cc2eb64aeb4aec3b6a05557cf7c/

fix the documentation to ethernet api to match implementation

Who changed what in which revision?

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