diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-10-20 22:16:19 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2011-10-20 22:16:19 -0700 |
commit | fc944ff979dbbd49a57722fe2d1d2acf47312eb4 (patch) | |
tree | 38cc3a5c5c8f24f55068fc4ffa73d018169fc2df /libraries/Ethernet/Ethernet.cpp |
Inital commit... halfway through the project
Diffstat (limited to 'libraries/Ethernet/Ethernet.cpp')
-rw-r--r-- | libraries/Ethernet/Ethernet.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libraries/Ethernet/Ethernet.cpp b/libraries/Ethernet/Ethernet.cpp new file mode 100644 index 0000000..94550ea --- /dev/null +++ b/libraries/Ethernet/Ethernet.cpp @@ -0,0 +1,36 @@ +#include "w5100.h"
+#include "Ethernet.h"
+
+// XXX: don't make assumptions about the value of MAX_SOCK_NUM.
+uint8_t EthernetClass::_state[MAX_SOCK_NUM] = {
+ 0, 0, 0, 0 };
+uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
+ 0, 0, 0, 0 };
+
+void EthernetClass::begin(uint8_t *mac, uint8_t *ip)
+{
+ uint8_t gateway[4];
+ gateway[0] = ip[0];
+ gateway[1] = ip[1];
+ gateway[2] = ip[2];
+ gateway[3] = 1;
+ begin(mac, ip, gateway);
+}
+
+void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway)
+{
+ uint8_t subnet[] = {
+ 255, 255, 255, 0 };
+ begin(mac, ip, gateway, subnet);
+}
+
+void EthernetClass::begin(uint8_t *mac, uint8_t *ip, uint8_t *gateway, uint8_t *subnet)
+{
+ W5100.init();
+ W5100.setMACAddress(mac);
+ W5100.setIPAddress(ip);
+ W5100.setGatewayIp(gateway);
+ W5100.setSubnetMask(subnet);
+}
+
+EthernetClass Ethernet;
|