Ethernet
The Ethernet Interface allows the mbed Microcontroller to connect and communicate with an Ethernet network. This can therefore be used to talk to other devices on a network, including communication with other computers such as web and email servers on the internet, or act as a webserver.
Hello World!
// Read destination and source from every ethernet packet
#include "mbed.h"
Ethernet eth;
int main() {
char buf[0x600];
while(1) {
int size = eth.receive();
if(size > 0) {
eth.read(buf, size);
printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
}
wait(1);
}
}
API
| Ethernet | An ethernet interface, to use with the ethernet pins. |
| Functions | |
| Ethernet | Initialise the ethernet interface. |
| Ethernet | Powers the hardware down. |
| write | Writes into an outgoing ethernet packet. |
| send | Send an outgoing ethernet packet. |
| receive | Recevies an arrived ethernet packet. |
| read | Read from an recevied ethernet packet. |
| address | Gives the ethernet address of the mbed. |
| link | Returns if an ethernet link is pressent or not. |
All of the required passive termination circuits are implemented on the mbed Microcontoller, allowing direct connection to the ethernet network.