@@ -71,7 +71,7 @@ uint8_t EthernetClass::socketBegin(uint8_t protocol, uint16_t port)
71
71
if (chip == 51 ) maxindex = 4 ; // W5100 chip never supports more than 4 sockets
72
72
#endif
73
73
// Serial.printf("W5000socket begin, protocol=%d, port=%d\n", protocol, port);
74
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
74
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
75
75
// look at all the hardware sockets, use any that are closed (unused)
76
76
for (s=0 ; s < maxindex; s++) {
77
77
status[s] = W5100.readSnSR (s);
@@ -95,7 +95,7 @@ uint8_t EthernetClass::socketBegin(uint8_t protocol, uint16_t port)
95
95
if (stat == SnSR::CLOSE_WAIT) goto closemakesocket;
96
96
}
97
97
#endif
98
- SPI .endTransaction ();
98
+ spiETH .endTransaction ();
99
99
return MAX_SOCK_NUM; // all sockets are in use
100
100
closemakesocket:
101
101
// Serial.printf("W5000socket close\n");
@@ -119,7 +119,7 @@ uint8_t EthernetClass::socketBegin(uint8_t protocol, uint16_t port)
119
119
state[s].RX_inc = 0 ;
120
120
state[s].TX_FSR = 0 ;
121
121
// Serial.printf("W5000socket prot=%d, RX_RD=%d\n", W5100.readSnMR(s), state[s].RX_RD);
122
- SPI .endTransaction ();
122
+ spiETH .endTransaction ();
123
123
return s;
124
124
}
125
125
@@ -135,7 +135,7 @@ uint8_t EthernetClass::socketBeginMulticast(uint8_t protocol, IPAddress ip, uint
135
135
if (chip == 51 ) maxindex = 4 ; // W5100 chip never supports more than 4 sockets
136
136
#endif
137
137
// Serial.printf("W5000socket begin, protocol=%d, port=%d\n", protocol, port);
138
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
138
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
139
139
// look at all the hardware sockets, use any that are closed (unused)
140
140
for (s=0 ; s < maxindex; s++) {
141
141
status[s] = W5100.readSnSR (s);
@@ -159,7 +159,7 @@ uint8_t EthernetClass::socketBeginMulticast(uint8_t protocol, IPAddress ip, uint
159
159
if (stat == SnSR::CLOSE_WAIT) goto closemakesocket;
160
160
}
161
161
#endif
162
- SPI .endTransaction ();
162
+ spiETH .endTransaction ();
163
163
return MAX_SOCK_NUM; // all sockets are in use
164
164
closemakesocket:
165
165
// Serial.printf("W5000socket close\n");
@@ -191,16 +191,16 @@ uint8_t EthernetClass::socketBeginMulticast(uint8_t protocol, IPAddress ip, uint
191
191
state[s].RX_inc = 0 ;
192
192
state[s].TX_FSR = 0 ;
193
193
// Serial.printf("W5000socket prot=%d, RX_RD=%d\n", W5100.readSnMR(s), state[s].RX_RD);
194
- SPI .endTransaction ();
194
+ spiETH .endTransaction ();
195
195
return s;
196
196
}
197
197
// Return the socket's status
198
198
//
199
199
uint8_t EthernetClass::socketStatus (uint8_t s)
200
200
{
201
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
201
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
202
202
uint8_t status = W5100.readSnSR (s);
203
- SPI .endTransaction ();
203
+ spiETH .endTransaction ();
204
204
return status;
205
205
}
206
206
@@ -209,23 +209,23 @@ uint8_t EthernetClass::socketStatus(uint8_t s)
209
209
//
210
210
void EthernetClass::socketClose (uint8_t s)
211
211
{
212
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
212
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
213
213
W5100.execCmdSn (s, Sock_CLOSE);
214
- SPI .endTransaction ();
214
+ spiETH .endTransaction ();
215
215
}
216
216
217
217
218
218
// Place the socket in listening (server) mode
219
219
//
220
220
uint8_t EthernetClass::socketListen (uint8_t s)
221
221
{
222
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
222
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
223
223
if (W5100.readSnSR (s) != SnSR::INIT) {
224
- SPI .endTransaction ();
224
+ spiETH .endTransaction ();
225
225
return 0 ;
226
226
}
227
227
W5100.execCmdSn (s, Sock_LISTEN);
228
- SPI .endTransaction ();
228
+ spiETH .endTransaction ();
229
229
return 1 ;
230
230
}
231
231
@@ -235,11 +235,11 @@ uint8_t EthernetClass::socketListen(uint8_t s)
235
235
void EthernetClass::socketConnect (uint8_t s, uint8_t * addr, uint16_t port)
236
236
{
237
237
// set destination IP
238
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
238
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
239
239
W5100.writeSnDIPR (s, addr);
240
240
W5100.writeSnDPORT (s, port);
241
241
W5100.execCmdSn (s, Sock_CONNECT);
242
- SPI .endTransaction ();
242
+ spiETH .endTransaction ();
243
243
}
244
244
245
245
@@ -248,9 +248,9 @@ void EthernetClass::socketConnect(uint8_t s, uint8_t * addr, uint16_t port)
248
248
//
249
249
void EthernetClass::socketDisconnect (uint8_t s)
250
250
{
251
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
251
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
252
252
W5100.execCmdSn (s, Sock_DISCON);
253
- SPI .endTransaction ();
253
+ spiETH .endTransaction ();
254
254
}
255
255
256
256
@@ -305,7 +305,7 @@ int EthernetClass::socketRecv(uint8_t s, uint8_t *buf, int16_t len)
305
305
{
306
306
// Check how much data is available
307
307
int ret = state[s].RX_RSR ;
308
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
308
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
309
309
if (ret < len) {
310
310
uint16_t rsr = getSnRX_RSR (s);
311
311
ret = rsr - state[s].RX_inc ;
@@ -342,7 +342,7 @@ int EthernetClass::socketRecv(uint8_t s, uint8_t *buf, int16_t len)
342
342
state[s].RX_inc = inc;
343
343
}
344
344
}
345
- SPI .endTransaction ();
345
+ spiETH .endTransaction ();
346
346
// Serial.printf("socketRecv, ret=%d\n", ret);
347
347
return ret;
348
348
}
@@ -351,9 +351,9 @@ uint16_t EthernetClass::socketRecvAvailable(uint8_t s)
351
351
{
352
352
uint16_t ret = state[s].RX_RSR ;
353
353
if (ret == 0 ) {
354
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
354
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
355
355
uint16_t rsr = getSnRX_RSR (s);
356
- SPI .endTransaction ();
356
+ spiETH .endTransaction ();
357
357
ret = rsr - state[s].RX_inc ;
358
358
state[s].RX_RSR = ret;
359
359
// Serial.printf("sockRecvAvailable s=%d, RX_RSR=%d\n", s, ret);
@@ -366,10 +366,10 @@ uint16_t EthernetClass::socketRecvAvailable(uint8_t s)
366
366
uint8_t EthernetClass::socketPeek (uint8_t s)
367
367
{
368
368
uint8_t b;
369
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
369
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
370
370
uint16_t ptr = state[s].RX_RD ;
371
371
W5100.read ((ptr & W5100.SMASK ) + W5100.RBASE (s), &b, 1 );
372
- SPI .endTransaction ();
372
+ spiETH .endTransaction ();
373
373
return b;
374
374
}
375
375
@@ -433,10 +433,10 @@ uint16_t EthernetClass::socketSend(uint8_t s, const uint8_t * buf, uint16_t len)
433
433
434
434
// if freebuf is available, start.
435
435
do {
436
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
436
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
437
437
freesize = getSnTX_FSR (s);
438
438
status = W5100.readSnSR (s);
439
- SPI .endTransaction ();
439
+ spiETH .endTransaction ();
440
440
if ((status != SnSR::ESTABLISHED) && (status != SnSR::CLOSE_WAIT)) {
441
441
ret = 0 ;
442
442
break ;
@@ -445,35 +445,35 @@ uint16_t EthernetClass::socketSend(uint8_t s, const uint8_t * buf, uint16_t len)
445
445
} while (freesize < ret);
446
446
447
447
// copy data
448
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
448
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
449
449
write_data (s, 0 , (uint8_t *)buf, ret);
450
450
W5100.execCmdSn (s, Sock_SEND);
451
451
452
452
/* +2008.01 bj */
453
453
while ( (W5100.readSnIR (s) & SnIR::SEND_OK) != SnIR::SEND_OK ) {
454
454
/* m2008.01 [bj] : reduce code */
455
455
if ( W5100.readSnSR (s) == SnSR::CLOSED ) {
456
- SPI .endTransaction ();
456
+ spiETH .endTransaction ();
457
457
return 0 ;
458
458
}
459
- SPI .endTransaction ();
459
+ spiETH .endTransaction ();
460
460
yield ();
461
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
461
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
462
462
}
463
463
/* +2008.01 bj */
464
464
W5100.writeSnIR (s, SnIR::SEND_OK);
465
- SPI .endTransaction ();
465
+ spiETH .endTransaction ();
466
466
return ret;
467
467
}
468
468
469
469
uint16_t EthernetClass::socketSendAvailable (uint8_t s)
470
470
{
471
471
uint8_t status=0 ;
472
472
uint16_t freesize=0 ;
473
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
473
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
474
474
freesize = getSnTX_FSR (s);
475
475
status = W5100.readSnSR (s);
476
- SPI .endTransaction ();
476
+ spiETH .endTransaction ();
477
477
if ((status == SnSR::ESTABLISHED) || (status == SnSR::CLOSE_WAIT)) {
478
478
return freesize;
479
479
}
@@ -484,15 +484,15 @@ uint16_t EthernetClass::socketBufferData(uint8_t s, uint16_t offset, const uint8
484
484
{
485
485
// Serial.printf(" bufferData, offset=%d, len=%d\n", offset, len);
486
486
uint16_t ret =0 ;
487
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
487
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
488
488
uint16_t txfree = getSnTX_FSR (s);
489
489
if (len > txfree) {
490
490
ret = txfree; // check size not to exceed MAX size.
491
491
} else {
492
492
ret = len;
493
493
}
494
494
write_data (s, offset, buf, ret);
495
- SPI .endTransaction ();
495
+ spiETH .endTransaction ();
496
496
return ret;
497
497
}
498
498
@@ -502,35 +502,35 @@ bool EthernetClass::socketStartUDP(uint8_t s, uint8_t* addr, uint16_t port)
502
502
((port == 0x00 )) ) {
503
503
return false ;
504
504
}
505
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
505
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
506
506
W5100.writeSnDIPR (s, addr);
507
507
W5100.writeSnDPORT (s, port);
508
- SPI .endTransaction ();
508
+ spiETH .endTransaction ();
509
509
return true ;
510
510
}
511
511
512
512
bool EthernetClass::socketSendUDP (uint8_t s)
513
513
{
514
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
514
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
515
515
W5100.execCmdSn (s, Sock_SEND);
516
516
517
517
/* +2008.01 bj */
518
518
while ( (W5100.readSnIR (s) & SnIR::SEND_OK) != SnIR::SEND_OK ) {
519
519
if (W5100.readSnIR (s) & SnIR::TIMEOUT) {
520
520
/* +2008.01 [bj]: clear interrupt */
521
521
W5100.writeSnIR (s, (SnIR::SEND_OK|SnIR::TIMEOUT));
522
- SPI .endTransaction ();
522
+ spiETH .endTransaction ();
523
523
// Serial.printf("sendUDP timeout\n");
524
524
return false ;
525
525
}
526
- SPI .endTransaction ();
526
+ spiETH .endTransaction ();
527
527
yield ();
528
- SPI .beginTransaction (SPI_ETHERNET_SETTINGS);
528
+ spiETH .beginTransaction (SPI_ETHERNET_SETTINGS);
529
529
}
530
530
531
531
/* +2008.01 bj */
532
532
W5100.writeSnIR (s, SnIR::SEND_OK);
533
- SPI .endTransaction ();
533
+ spiETH .endTransaction ();
534
534
535
535
// Serial.printf("sendUDP ok\n");
536
536
/* Sent ok */
0 commit comments