1 /* mbed Microcontroller Library
2  * Copyright (c) 2006-2013 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MBED_ETHERNET_API_H
17 #define MBED_ETHERNET_API_H
18 
19 #include "device.h"
20 
21 #if DEVICE_ETHERNET
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /** @addtogroup ethernet ETHERNET
28  *  @ingroup    hal
29  *  @brief      ETHERNET functions
30  *  @{
31  */
32 
33 /**
34  *  @brief To initialize the Ethernet MAC controller.
35  *
36  *  @param  None
37  *
38  *  @returns    The result.
39  */
40 int ethernet_init(void);
41 
42 /**
43  *  @brief To de-initialize the Ethernet MAC controller.
44  *
45  *  @param None
46  *
47  *  @returns    void.
48  */
49 void ethernet_free(void);
50 
51 /**
52  *  @brief To write "size" bytes of data from "data" to the Tx packet buffer.
53  *
54  *  @param[in]  data The buffer of packet data.
55  *  @param[in]  size The size of the packet data.
56  *
57  *  @returns    The number of bytes written, or (-1) if errors.
58  */
59 int ethernet_write(const char *data, int size);
60 
61 /**
62  *  @brief To send the packet from Tx packet buffer.
63  *
64  *  @param None
65  *
66  *  @returns    The packet size.
67  */
68 int ethernet_send(void);
69 
70 /**
71  *  @brief To receive a packet into the Rx packet buffer.
72  *
73  *  @param None
74  *
75  *  @returns    The packet size, or 0 if no packet received.
76  */
77 int ethernet_receive(void);
78 
79 /**
80  *  @brief To read packet data from Rx packet buffer to the "data" buffer.
81  *
82  *  @param[in]  data A buffer for the packet data.
83  *  @param[in]  size The specified length (in bytes) to be read.
84  *
85  *  @returns    The actual size (in bytes) of data read.
86  */
87 int ethernet_read(char *data, int size);
88 
89 /**
90  *  @brief To get the ethernet MAC address.
91  *
92  *  @param[in]  mac The buffer of MAC address.
93  *
94  *  @returns    void.
95  */
96 void ethernet_address(char *mac);
97 
98 /**
99  *  @brief To get the link status.
100  *
101  *  @param None
102  *
103  *  @returns    1 for link up, 0 for link down.
104  */
105 int ethernet_link(void);
106 
107 /**
108  *  @brief To set the link speed and duplex mode.
109  *
110  *  @param[in]  speed The specified link speed.
111  *  @param[in]  duplex The specifed duplex mode.
112  *
113  *  @returns    void.
114  */
115 void ethernet_set_link(int speed, int duplex);
116 
117 /** @} */ /* End of group ethernet */
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif
124 
125 #endif
126 
127