1
- #include " w5100.h"
1
+ #include " utility/ w5100.h"
2
2
#include " Ethernet.h"
3
3
#include " Dhcp.h"
4
4
@@ -16,18 +16,22 @@ int EthernetClass::begin(uint8_t *mac_address)
16
16
17
17
// Initialise the basic info
18
18
W5100.init ();
19
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
19
20
W5100.setMACAddress (mac_address);
20
21
W5100.setIPAddress (IPAddress (0 ,0 ,0 ,0 ).raw_address ());
22
+ SPI.endTransaction ();
21
23
22
24
// Now try to get our config info from a DHCP server
23
25
int ret = _dhcp->beginWithDHCP (mac_address);
24
26
if (ret == 1 )
25
27
{
26
28
// We've successfully found a DHCP server and got our configuration info, so set things
27
29
// accordingly
30
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
28
31
W5100.setIPAddress (_dhcp->getLocalIp ().raw_address ());
29
32
W5100.setGatewayIp (_dhcp->getGatewayIp ().raw_address ());
30
33
W5100.setSubnetMask (_dhcp->getSubnetMask ().raw_address ());
34
+ SPI.endTransaction ();
31
35
_dnsServerAddress = _dhcp->getDnsServerIp ();
32
36
}
33
37
@@ -61,10 +65,12 @@ void EthernetClass::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dn
61
65
void EthernetClass::begin (uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet)
62
66
{
63
67
W5100.init ();
68
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
64
69
W5100.setMACAddress (mac);
65
- W5100.setIPAddress (local_ip._address );
66
- W5100.setGatewayIp (gateway._address );
67
- W5100.setSubnetMask (subnet._address );
70
+ W5100.setIPAddress (local_ip.raw_address ());
71
+ W5100.setGatewayIp (gateway.raw_address ());
72
+ W5100.setSubnetMask (subnet.raw_address ());
73
+ SPI.endTransaction ();
68
74
_dnsServerAddress = dns_server;
69
75
}
70
76
@@ -80,9 +86,11 @@ int EthernetClass::maintain(){
80
86
case DHCP_CHECK_RENEW_OK:
81
87
case DHCP_CHECK_REBIND_OK:
82
88
// we might have got a new IP.
89
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
83
90
W5100.setIPAddress (_dhcp->getLocalIp ().raw_address ());
84
91
W5100.setGatewayIp (_dhcp->getGatewayIp ().raw_address ());
85
92
W5100.setSubnetMask (_dhcp->getSubnetMask ().raw_address ());
93
+ SPI.endTransaction ();
86
94
_dnsServerAddress = _dhcp->getDnsServerIp ();
87
95
break ;
88
96
default :
@@ -96,21 +104,27 @@ int EthernetClass::maintain(){
96
104
IPAddress EthernetClass::localIP ()
97
105
{
98
106
IPAddress ret;
107
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
99
108
W5100.getIPAddress (ret.raw_address ());
109
+ SPI.endTransaction ();
100
110
return ret;
101
111
}
102
112
103
113
IPAddress EthernetClass::subnetMask ()
104
114
{
105
115
IPAddress ret;
116
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
106
117
W5100.getSubnetMask (ret.raw_address ());
118
+ SPI.endTransaction ();
107
119
return ret;
108
120
}
109
121
110
122
IPAddress EthernetClass::gatewayIP ()
111
123
{
112
124
IPAddress ret;
125
+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
113
126
W5100.getGatewayIp (ret.raw_address ());
127
+ SPI.endTransaction ();
114
128
return ret;
115
129
}
116
130
0 commit comments