Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Ethernet.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #include "drivers/Ethernet.h" 00017 00018 #if DEVICE_ETHERNET 00019 00020 #include "hal/ethernet_api.h" 00021 00022 namespace mbed { 00023 00024 Ethernet::Ethernet() 00025 { 00026 ethernet_init(); 00027 } 00028 00029 Ethernet::~Ethernet() 00030 { 00031 ethernet_free(); 00032 } 00033 00034 int Ethernet::write(const char *data, int size) 00035 { 00036 return ethernet_write(data, size); 00037 } 00038 00039 int Ethernet::send() 00040 { 00041 return ethernet_send(); 00042 } 00043 00044 int Ethernet::receive() 00045 { 00046 return ethernet_receive(); 00047 } 00048 00049 int Ethernet::read(char *data, int size) 00050 { 00051 return ethernet_read(data, size); 00052 } 00053 00054 void Ethernet::address(char *mac) 00055 { 00056 return ethernet_address(mac); 00057 } 00058 00059 int Ethernet::link() 00060 { 00061 return ethernet_link(); 00062 } 00063 00064 void Ethernet::set_link(Mode mode) 00065 { 00066 int speed = -1; 00067 int duplex = 0; 00068 00069 switch (mode) { 00070 case AutoNegotiate : 00071 speed = -1; 00072 duplex = 0; 00073 break; 00074 case HalfDuplex10 : 00075 speed = 0; 00076 duplex = 0; 00077 break; 00078 case FullDuplex10 : 00079 speed = 0; 00080 duplex = 1; 00081 break; 00082 case HalfDuplex100 : 00083 speed = 1; 00084 duplex = 0; 00085 break; 00086 case FullDuplex100 : 00087 speed = 1; 00088 duplex = 1; 00089 break; 00090 } 00091 00092 ethernet_set_link(speed, duplex); 00093 } 00094 00095 } // namespace mbed 00096 00097 #endif
Generated on Tue Aug 9 2022 00:37:06 by
