Skip to content

Commit 6ee355a

Browse files
authored
Merge pull request #11 from bcmi-labs/feature/iperf
Pulling in latest fixes from `MicrochipTech/oa-tc6-lib`
2 parents 5dad4a7 + cb581db commit 6ee355a

File tree

7 files changed

+25
-85
lines changed

7 files changed

+25
-85
lines changed

Diff for: README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
### How-to-compile/upload
1111
```bash
12-
arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf
13-
arduino-cli upload -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -p /dev/ttyACM0
14-
# or
15-
arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -u -p /dev/ttyACM0
12+
arduino-cli compile -b arduino:renesas_uno:unor4wifi -v examples/iperf-client -u -p /dev/ttyACM0
1613
```
1714

1815
### How-to-[`EVB-LAN8670-USB`](https://www.microchip.com/en-us/development-tool/EV08L38A)

Diff for: examples/LAN8651-iperf/README.md renamed to examples/iperf-client/README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
:floppy_disk: `LAN8651-iperf`
1+
:floppy_disk: `iperf-client`
22
=============================
33

44
This example sketch can be used to measure 10BASE-T1S network performance using this software stack. The required hardware is a Arduino [Nano 33 IoT](https://store.arduino.cc/products/arduino-nano-33-iot) and a Mikroe [2-Wire ETH](https://www.mikroe.com/two-wire-eth-click) click board.
55

66
### How-to-compile/upload
77
```bash
8-
arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf
9-
arduino-cli upload -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -p /dev/ttyACM0
10-
# or
11-
arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -u -p /dev/ttyACM0
8+
arduino-cli compile -b arduino:renesas_uno:unor4wifi -v examples/iperf-client -u -p /dev/ttyACM0
129
```
1310

1411
### How-to-`iperf`
@@ -35,5 +32,5 @@ PING 192.168.42.101 (192.168.42.101) 56(84) bytes of data.
3532
```
3633
Start `iperf` on your PC:
3734
```bash
38-
iperf -c 192.168.42.101 -u -b 10M
35+
iperf --client 192.168.42.101 --udp --bandwidth 10M
3936
```

Diff for: examples/LAN8651-iperf/LAN8651-iperf.ino renamed to examples/iperf-client/iperf-client.ino

+1-36
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,7 @@ void setup()
8787
for (;;) { }
8888
}
8989

90-
/* Obtain MAC address stored on EEPROM of Mikroe
91-
* Two-Wire ETH Click board.
92-
*/
93-
MacAddress mac_addr;
94-
if (!get_mac_address(mac_addr.data()))
95-
{
96-
Serial.println("'get_mac_address(...)' failed, using fallback MAC address.");
97-
memcpy(mac_addr.data(), TC6::TC6_Io::FALLBACK_MAC, MAC_ADDRESS_NUM_BYTES);
98-
}
90+
MacAddress const mac_addr = MacAddress::create_from_uid();
9991

10092
if (!tc6_inst->begin( ip_addr
10193
, network_mask
@@ -156,30 +148,3 @@ static void OnPlcaStatus(bool success, bool plcaStatus)
156148
tc6_inst->enablePlca();
157149
}
158150
}
159-
160-
static bool get_mac_address(uint8_t * p_mac)
161-
{
162-
static uint8_t const MAC_EEPROM_I2C_SLAVE_ADDR = 0x58;
163-
static uint8_t const MAC_EEPROM_EUI_REG_ADDR = 0x9A;
164-
static uint8_t const MAC_EEPROM_MAC_SIZE = 6;
165-
bool success = false;
166-
167-
Wire.beginTransmission(MAC_EEPROM_I2C_SLAVE_ADDR);
168-
Wire.write(MAC_EEPROM_EUI_REG_ADDR);
169-
Wire.endTransmission();
170-
171-
Wire.requestFrom(MAC_EEPROM_I2C_SLAVE_ADDR, MAC_EEPROM_MAC_SIZE);
172-
173-
uint32_t const start = millis();
174-
175-
size_t bytes_read = 0;
176-
while (bytes_read < MAC_EEPROM_MAC_SIZE && ((millis() - start) < 1000)) {
177-
if (Wire.available()) {
178-
p_mac[bytes_read] = Wire.read();
179-
bytes_read++;
180-
}
181-
}
182-
183-
success = (bytes_read == MAC_EEPROM_MAC_SIZE);
184-
return success;
185-
}

Diff for: examples/LAN8651-iperf/udp_perf_client.h renamed to examples/iperf-client/udp_perf_client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct perf_stats {
9292
#define UDP_TIME_INTERVAL 300
9393

9494
/* Server to connect with */
95-
#define UDP_SERVER_IP_ADDRESS "192.168.0.5"
95+
#define UDP_SERVER_IP_ADDRESS "192.168.42.100"
9696

9797
/* UDP buffer length in bytes */
9898
#define UDP_SEND_BUFSIZE 1460

Diff for: src/microchip/TC6_Arduino_10BASE_T1S.cpp

+12-37
Original file line numberDiff line numberDiff line change
@@ -398,58 +398,33 @@ void TC6_CB_OnRxEthernetSlice(TC6_t *pInst, const uint8_t *pRx, uint16_t offset,
398398
{
399399
TC6LwIP_t *lw = TC6::GetContextTC6(pInst);
400400
bool success = true;
401-
(void) pInst;
402-
(void) pGlobalTag;
401+
(void)pInst;
402+
(void)pGlobalTag;
403403
// TC6_ASSERT(lw->tc.tc6 == pInst);
404-
if (lw->tc.rxInvalid)
405-
{
404+
if (lw->tc.rxInvalid) {
406405
success = false;
407406
}
408-
if (success && ((offset + len) > TC6LwIP_MTU))
409-
{
410-
// PrintRateLimited("on_rx_slice:packet greater than MTU", (offset + len));
407+
if (success && ((offset + len) > TC6LwIP_MTU)) {
408+
// PRINT("on_rx_slice:packet greater than MTU", (offset + len));
411409
lw->tc.rxInvalid = true;
412410
success = false;
413411
}
414-
if (success && (0u != offset))
415-
{
416-
if (!lw->tc.pbuf || !lw->tc.rxLen)
417-
{
418-
// TC6_ASSERT(false);
419-
lw->tc.rxInvalid = true;
420-
success = false;
421-
}
422-
} else
423-
{
424-
if (success && (lw->tc.pbuf || lw->tc.rxLen))
425-
{
426-
// TC6_ASSERT(false);
412+
if (success && (NULL == lw->tc.pbuf)) {
413+
lw->tc.pbuf = pbuf_alloc(PBUF_RAW, TC6LwIP_MTU, PBUF_RAM);
414+
if (!lw->tc.pbuf) {
427415
lw->tc.rxInvalid = true;
428416
success = false;
429417
}
430-
431-
if (success)
432-
{
433-
lw->tc.pbuf = pbuf_alloc(PBUF_RAW, TC6LwIP_MTU, PBUF_RAM);
434-
if (!lw->tc.pbuf)
435-
{
436-
lw->tc.rxInvalid = true;
437-
success = false;
438-
}
439-
}
440-
if (success && (NULL != lw->tc.pbuf->next))
441-
{
442-
// TC6_ASSERT(lw->tc.pbuf->ref != 0);
443-
// PrintRateLimited("rx_slice: could not allocate unsegmented memory diff", (lw->tc.pbuf->tot_len - lw->tc.pbuf->len));
418+
if (success && (NULL != lw->tc.pbuf->next)) {
419+
// PRINT("rx_slice: could not allocate unsegmented memory diff", (lw->tc.pbuf->tot_len - lw->tc.pbuf->len));
444420
lw->tc.rxInvalid = true;
445421
pbuf_free(lw->tc.pbuf);
446422
lw->tc.pbuf = NULL;
447423
success = false;
448424
}
449425
}
450-
if (success)
451-
{
452-
(void) memcpy((uint8_t *) lw->tc.pbuf->payload + offset, pRx, len);
426+
if (success) {
427+
(void)memcpy(lw->tc.pbuf->payload + offset, pRx, len);
453428
lw->tc.rxLen += len;
454429
}
455430
}

Diff for: src/microchip/lib/libtc6/inc/tc6-regs.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ void TC6Regs_Reinit(TC6_t *pInst);
148148
*/
149149
bool TC6Regs_SetPlca(TC6_t *pInst, bool plcaEnable, uint8_t nodeId, uint8_t nodeCount);
150150

151+
/** \brief Returns the LAN865x Revision number.
152+
* \param pInst - The pointer returned by TC6_Init.
153+
* \return 0, in case of error. Otherwise, Chip Revision.
154+
*/
155+
uint8_t TC6Regs_GetChipRevision(TC6_t *pInst);
156+
151157
/** \brief Configure DIOAx GPIOs as output.
152158
*/
153159
void TC6Regs_EnableDio_A0(TC6_t *pTC6);
@@ -191,7 +197,7 @@ uint32_t TC6Regs_CB_GetTicksMs(void);
191197
void TC6Regs_CB_OnEvent(TC6_t *pInst, TC6Regs_Event_t event, void *pTag);
192198

193199
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
194-
/* CONVERSTION FUNCTIONS */
200+
/* CONVERSION FUNCTIONS */
195201
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
196202

197203
template <typename Enumeration>

0 commit comments

Comments
 (0)