Mistake on this page?
Report an issue in GitHub or email us
Ethernet.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_ETHERNET_H
18 #define MBED_ETHERNET_H
19 
20 #include "platform/platform.h"
21 #include "platform/NonCopyable.h"
22 
23 #if DEVICE_ETHERNET || defined(DOXYGEN_ONLY)
24 
25 namespace mbed {
26 
27 /** \addtogroup drivers-public-api */
28 /** @{*/
29 
30 /**
31  * \defgroup drivers_Ethernet Ethernet class
32  * @{
33  */
34 
35 /** An ethernet interface, to use with the ethernet pins.
36  *
37  * @deprecated
38  * EthInterface is now the preferred way to get an Ethernet object.
39  * Alternatively, use NetworkInterface to get an instance of an appropriate network
40  * interface (WiFi or Ethernet).
41  *
42  * @note Synchronization level: Not protected
43  *
44  * Example:
45  * @code
46  * // Read destination and source from every ethernet packet
47  *
48  * #include "mbed.h"
49  *
50  * Ethernet eth;
51  *
52  * int main() {
53  * char buf[0x600];
54  *
55  * while(1) {
56  * int size = eth.receive();
57  * if(size > 0) {
58  * eth.read(buf, size);
59  * printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n",
60  * buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
61  * printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
62  * buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
63  * }
64  *
65  * wait(1);
66  * }
67  * }
68  * @endcode
69  */
70 class
71  MBED_DEPRECATED(
72  "EthInterface is now the preferred way to get an Ethernet object. "
73  "Alternatively, use NetworkInterface to get an instance of an appropriate network "
74  "interface (WiFi or Ethernet)."
75  ) Ethernet : private NonCopyable<Ethernet> {
76 
77 public:
78 
79  /**
80  * @deprecated
81  * Initialize the ethernet interface.
82  */
83  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
84  Ethernet();
85 
86  /**
87  * @deprecated
88  * Powers the hardware down.
89  */
90  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
91  virtual ~Ethernet();
92 
93  enum Mode {
94  AutoNegotiate,
95  HalfDuplex10,
96  FullDuplex10,
97  HalfDuplex100,
98  FullDuplex100
99  };
100 
101  /**
102  * @deprecated
103  * Writes into an outgoing ethernet packet.
104  *
105  * It will append size bytes of data to the previously written bytes.
106  *
107  * @param data An array to write.
108  * @param size The size of data.
109  *
110  * @returns
111  * The number of written bytes.
112  */
113  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
114  int write(const char *data, int size);
115 
116  /**
117  * @deprecated
118  * Send an outgoing ethernet packet.
119  *
120  * After filling in the data in an ethernet packet it must be send.
121  * Send will provide a new packet to write to.
122  *
123  * @returns
124  * 0 if the sending was failed,
125  * or the size of the packet successfully sent.
126  */
127  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
128  int send();
129 
130  /**
131  * @deprecated
132  * Receives an arrived ethernet packet.
133  *
134  * Receiving an ethernet packet will drop the last received ethernet packet
135  * and make a new ethernet packet ready to read.
136  * If no ethernet packet is arrived it will return 0.
137  *
138  * @returns
139  * 0 if no ethernet packet is arrived,
140  * or the size of the arrived packet.
141  */
142  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
143  int receive();
144 
145  /**
146  * @deprecated
147  * Read from an received ethernet packet.
148  *
149  * After receive returned a number bigger than 0 it is
150  * possible to read bytes from this packet.
151  *
152  * @param data Pointer to data packet
153  * @param size Size of data to be read.
154  * @returns The number of byte read.
155  *
156  * @note It is possible to use read multiple times.
157  * Each time read will start reading after the last read byte before.
158  *
159  */
160  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
161  int read(char *data, int size);
162 
163  /**
164  * @deprecated
165  * Gives the ethernet address of the mbed.
166  *
167  * @param mac Must be a pointer to a 6 byte char array to copy the ethernet address in.
168  */
169  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
170  void address(char *mac);
171 
172  /**
173  * @deprecated
174  * Returns if an ethernet link is present or not. It takes a while after Ethernet initialization to show up.
175  *
176  * @returns
177  * 0 if no ethernet link is present,
178  * 1 if an ethernet link is present.
179  *
180  * Example:
181  * @code
182  * // Using the Ethernet link function
183  * #include "mbed.h"
184  *
185  * Ethernet eth;
186  *
187  * int main() {
188  * wait(1); // Needed after startup.
189  * if (eth.link()) {
190  * printf("online\n");
191  * } else {
192  * printf("offline\n");
193  * }
194  * }
195  * @endcode
196  */
197  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
198  int link();
199 
200  /**
201  * @deprecated
202  * Sets the speed and duplex parameters of an ethernet link
203  *
204  * - AutoNegotiate Auto negotiate speed and duplex
205  * - HalfDuplex10 10 Mbit, half duplex
206  * - FullDuplex10 10 Mbit, full duplex
207  * - HalfDuplex100 100 Mbit, half duplex
208  * - FullDuplex100 100 Mbit, full duplex
209  *
210  * @param mode the speed and duplex mode to set the link to:
211  */
212  MBED_DEPRECATED("The class has been deprecated and will be removed in the future.")
213  void set_link(Mode mode);
214 };
215 
216 /** @}*/
217 /** @}*/
218 
219 } // namespace mbed
220 
221 #endif
222 
223 #endif
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:169
An ethernet interface, to use with the ethernet pins.
Definition: Ethernet.h:70
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.