Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Ethernet.h Source File

Ethernet.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_ETHERNET_H
00018 #define MBED_ETHERNET_H
00019 
00020 #include "platform/platform.h"
00021 #include "platform/NonCopyable.h"
00022 
00023 #if DEVICE_ETHERNET || defined(DOXYGEN_ONLY)
00024 
00025 namespace mbed {
00026 
00027 /** \addtogroup drivers-public-api */
00028 /** @{*/
00029 
00030 /**
00031  * \defgroup drivers_Ethernet Ethernet class
00032  * @{
00033  */
00034 
00035 /** An ethernet interface, to use with the ethernet pins.
00036  *
00037  * @deprecated
00038  * EthInterface is now the preferred way to get an Ethernet object.
00039  * Alternatively, use NetworkInterface to get an instance of an appropriate network
00040  * interface (WiFi or Ethernet).
00041  *
00042  * @note Synchronization level: Not protected
00043  *
00044  * Example:
00045  * @code
00046  * // Read destination and source from every ethernet packet
00047  *
00048  * #include "mbed.h"
00049  *
00050  * Ethernet eth;
00051  *
00052  * int main() {
00053  *     char buf[0x600];
00054  *
00055  *     while(1) {
00056  *         int size = eth.receive();
00057  *         if(size > 0) {
00058  *             eth.read(buf, size);
00059  *             printf("Destination:  %02X:%02X:%02X:%02X:%02X:%02X\n",
00060  *                     buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
00061  *             printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
00062  *                     buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
00063  *         }
00064  *
00065  *         wait(1);
00066  *     }
00067  * }
00068  * @endcode
00069  */
00070 class
00071     MBED_DEPRECATED(
00072         "EthInterface is now the preferred way to get an Ethernet object. "
00073         "Alternatively, use NetworkInterface to get an instance of an appropriate network "
00074         "interface (WiFi or Ethernet)."
00075     ) Ethernet : private NonCopyable<Ethernet> {
00076 
00077 public:
00078 
00079     /**
00080      * @deprecated
00081      * Initialize the ethernet interface.
00082      */
00083     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00084     Ethernet();
00085 
00086     /**
00087      * @deprecated
00088      * Powers the hardware down.
00089      */
00090     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00091     virtual ~Ethernet();
00092 
00093     enum Mode {
00094         AutoNegotiate,
00095         HalfDuplex10,
00096         FullDuplex10,
00097         HalfDuplex100,
00098         FullDuplex100
00099     };
00100 
00101     /**
00102      * @deprecated
00103      *  Writes into an outgoing ethernet packet.
00104      *
00105      *  It will append size bytes of data to the previously written bytes.
00106      *
00107      *  @param data An array to write.
00108      *  @param size The size of data.
00109      *
00110      *  @returns
00111      *   The number of written bytes.
00112      */
00113     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00114     int write(const char *data, int size);
00115 
00116     /**
00117      * @deprecated
00118      *  Send an outgoing ethernet packet.
00119      *
00120      *  After filling in the data in an ethernet packet it must be send.
00121      *  Send will provide a new packet to write to.
00122      *
00123      *  @returns
00124      *    0 if the sending was failed,
00125      *    or the size of the packet successfully sent.
00126      */
00127     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00128     int send();
00129 
00130     /**
00131      * @deprecated
00132      *  Receives an arrived ethernet packet.
00133      *
00134      *  Receiving an ethernet packet will drop the last received ethernet packet
00135      *  and make a new ethernet packet ready to read.
00136      *  If no ethernet packet is arrived it will return 0.
00137      *
00138      *  @returns
00139      *    0 if no ethernet packet is arrived,
00140      *    or the size of the arrived packet.
00141      */
00142     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00143     int receive();
00144 
00145     /**
00146      * @deprecated
00147      *  Read from an received ethernet packet.
00148      *
00149      *  After receive returned a number bigger than 0 it is
00150      *  possible to read bytes from this packet.
00151      *
00152      *  @param data      Pointer to data packet
00153      *  @param size      Size of data to be read.
00154      *  @returns         The number of byte read.
00155      *
00156      *  @note It is possible to use read multiple times.
00157      *  Each time read will start reading after the last read byte before.
00158      *
00159      */
00160     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00161     int read(char *data, int size);
00162 
00163     /**
00164      * @deprecated
00165      *  Gives the ethernet address of the mbed.
00166      *
00167      *  @param mac Must be a pointer to a 6 byte char array to copy the ethernet address in.
00168      */
00169     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00170     void address(char *mac);
00171 
00172     /**
00173      * @deprecated
00174      *  Returns if an ethernet link is present or not. It takes a while after Ethernet initialization to show up.
00175      *
00176      *  @returns
00177      *   0 if no ethernet link is present,
00178      *   1 if an ethernet link is present.
00179      *
00180      * Example:
00181      * @code
00182      * // Using the Ethernet link function
00183      * #include "mbed.h"
00184      *
00185      * Ethernet eth;
00186      *
00187      * int main() {
00188      *     wait(1); // Needed after startup.
00189      *     if (eth.link()) {
00190      *          printf("online\n");
00191      *     } else {
00192      *          printf("offline\n");
00193      *     }
00194      * }
00195      * @endcode
00196      */
00197     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00198     int link();
00199 
00200     /**
00201      * @deprecated
00202      *  Sets the speed and duplex parameters of an ethernet link
00203      *
00204      * - AutoNegotiate      Auto negotiate speed and duplex
00205      * - HalfDuplex10       10 Mbit, half duplex
00206      * - FullDuplex10       10 Mbit, full duplex
00207      * - HalfDuplex100      100 Mbit, half duplex
00208      * - FullDuplex100      100 Mbit, full duplex
00209      *
00210      *  @param mode the speed and duplex mode to set the link to:
00211      */
00212     MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
00213     void set_link(Mode mode);
00214 };
00215 
00216 /** @}*/
00217 /** @}*/
00218 
00219 } // namespace mbed
00220 
00221 #endif
00222 
00223 #endif