diff --git a/README.md b/README.md index 1106d86..082d6fc 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,7 @@ ### How-to-compile/upload ```bash -arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -arduino-cli upload -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -p /dev/ttyACM0 -# or -arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -u -p /dev/ttyACM0 +arduino-cli compile -b arduino:renesas_uno:unor4wifi -v examples/iperf-client -u -p /dev/ttyACM0 ``` ### How-to-[`EVB-LAN8670-USB`](https://www.microchip.com/en-us/development-tool/EV08L38A) diff --git a/examples/LAN8651-iperf/README.md b/examples/iperf-client/README.md similarity index 76% rename from examples/LAN8651-iperf/README.md rename to examples/iperf-client/README.md index 9fe95b5..cde80d7 100644 --- a/examples/LAN8651-iperf/README.md +++ b/examples/iperf-client/README.md @@ -1,14 +1,11 @@ -:floppy_disk: `LAN8651-iperf` +:floppy_disk: `iperf-client` ============================= 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. ### How-to-compile/upload ```bash -arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -arduino-cli upload -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -p /dev/ttyACM0 -# or -arduino-cli compile -b arduino:samd:nano_33_iot -v examples/LAN8651-iperf -u -p /dev/ttyACM0 +arduino-cli compile -b arduino:renesas_uno:unor4wifi -v examples/iperf-client -u -p /dev/ttyACM0 ``` ### How-to-`iperf` @@ -35,5 +32,5 @@ PING 192.168.42.101 (192.168.42.101) 56(84) bytes of data. ``` Start `iperf` on your PC: ```bash -iperf -c 192.168.42.101 -u -b 10M +iperf --client 192.168.42.101 --udp --bandwidth 10M ``` diff --git a/examples/LAN8651-iperf/LAN8651-iperf.ino b/examples/iperf-client/iperf-client.ino similarity index 79% rename from examples/LAN8651-iperf/LAN8651-iperf.ino rename to examples/iperf-client/iperf-client.ino index d610ad7..f39e7d3 100644 --- a/examples/LAN8651-iperf/LAN8651-iperf.ino +++ b/examples/iperf-client/iperf-client.ino @@ -87,15 +87,7 @@ void setup() for (;;) { } } - /* Obtain MAC address stored on EEPROM of Mikroe - * Two-Wire ETH Click board. - */ - MacAddress mac_addr; - if (!get_mac_address(mac_addr.data())) - { - Serial.println("'get_mac_address(...)' failed, using fallback MAC address."); - memcpy(mac_addr.data(), TC6::TC6_Io::FALLBACK_MAC, MAC_ADDRESS_NUM_BYTES); - } + MacAddress const mac_addr = MacAddress::create_from_uid(); if (!tc6_inst->begin( ip_addr , network_mask @@ -156,30 +148,3 @@ static void OnPlcaStatus(bool success, bool plcaStatus) tc6_inst->enablePlca(); } } - -static bool get_mac_address(uint8_t * p_mac) -{ - static uint8_t const MAC_EEPROM_I2C_SLAVE_ADDR = 0x58; - static uint8_t const MAC_EEPROM_EUI_REG_ADDR = 0x9A; - static uint8_t const MAC_EEPROM_MAC_SIZE = 6; - bool success = false; - - Wire.beginTransmission(MAC_EEPROM_I2C_SLAVE_ADDR); - Wire.write(MAC_EEPROM_EUI_REG_ADDR); - Wire.endTransmission(); - - Wire.requestFrom(MAC_EEPROM_I2C_SLAVE_ADDR, MAC_EEPROM_MAC_SIZE); - - uint32_t const start = millis(); - - size_t bytes_read = 0; - while (bytes_read < MAC_EEPROM_MAC_SIZE && ((millis() - start) < 1000)) { - if (Wire.available()) { - p_mac[bytes_read] = Wire.read(); - bytes_read++; - } - } - - success = (bytes_read == MAC_EEPROM_MAC_SIZE); - return success; -} diff --git a/examples/LAN8651-iperf/udp_perf_client.cpp b/examples/iperf-client/udp_perf_client.cpp similarity index 100% rename from examples/LAN8651-iperf/udp_perf_client.cpp rename to examples/iperf-client/udp_perf_client.cpp diff --git a/examples/LAN8651-iperf/udp_perf_client.h b/examples/iperf-client/udp_perf_client.h similarity index 98% rename from examples/LAN8651-iperf/udp_perf_client.h rename to examples/iperf-client/udp_perf_client.h index ac770d5..08650a0 100644 --- a/examples/LAN8651-iperf/udp_perf_client.h +++ b/examples/iperf-client/udp_perf_client.h @@ -92,7 +92,7 @@ struct perf_stats { #define UDP_TIME_INTERVAL 300 /* Server to connect with */ -#define UDP_SERVER_IP_ADDRESS "192.168.0.5" +#define UDP_SERVER_IP_ADDRESS "192.168.42.100" /* UDP buffer length in bytes */ #define UDP_SEND_BUFSIZE 1460 diff --git a/src/microchip/TC6_Arduino_10BASE_T1S.cpp b/src/microchip/TC6_Arduino_10BASE_T1S.cpp index 2c48185..208040a 100644 --- a/src/microchip/TC6_Arduino_10BASE_T1S.cpp +++ b/src/microchip/TC6_Arduino_10BASE_T1S.cpp @@ -398,58 +398,33 @@ void TC6_CB_OnRxEthernetSlice(TC6_t *pInst, const uint8_t *pRx, uint16_t offset, { TC6LwIP_t *lw = TC6::GetContextTC6(pInst); bool success = true; - (void) pInst; - (void) pGlobalTag; + (void)pInst; + (void)pGlobalTag; // TC6_ASSERT(lw->tc.tc6 == pInst); - if (lw->tc.rxInvalid) - { + if (lw->tc.rxInvalid) { success = false; } - if (success && ((offset + len) > TC6LwIP_MTU)) - { -// PrintRateLimited("on_rx_slice:packet greater than MTU", (offset + len)); + if (success && ((offset + len) > TC6LwIP_MTU)) { +// PRINT("on_rx_slice:packet greater than MTU", (offset + len)); lw->tc.rxInvalid = true; success = false; } - if (success && (0u != offset)) - { - if (!lw->tc.pbuf || !lw->tc.rxLen) - { -// TC6_ASSERT(false); - lw->tc.rxInvalid = true; - success = false; - } - } else - { - if (success && (lw->tc.pbuf || lw->tc.rxLen)) - { -// TC6_ASSERT(false); + if (success && (NULL == lw->tc.pbuf)) { + lw->tc.pbuf = pbuf_alloc(PBUF_RAW, TC6LwIP_MTU, PBUF_RAM); + if (!lw->tc.pbuf) { lw->tc.rxInvalid = true; success = false; } - - if (success) - { - lw->tc.pbuf = pbuf_alloc(PBUF_RAW, TC6LwIP_MTU, PBUF_RAM); - if (!lw->tc.pbuf) - { - lw->tc.rxInvalid = true; - success = false; - } - } - if (success && (NULL != lw->tc.pbuf->next)) - { -// TC6_ASSERT(lw->tc.pbuf->ref != 0); -// PrintRateLimited("rx_slice: could not allocate unsegmented memory diff", (lw->tc.pbuf->tot_len - lw->tc.pbuf->len)); + if (success && (NULL != lw->tc.pbuf->next)) { +// PRINT("rx_slice: could not allocate unsegmented memory diff", (lw->tc.pbuf->tot_len - lw->tc.pbuf->len)); lw->tc.rxInvalid = true; pbuf_free(lw->tc.pbuf); lw->tc.pbuf = NULL; success = false; } } - if (success) - { - (void) memcpy((uint8_t *) lw->tc.pbuf->payload + offset, pRx, len); + if (success) { + (void)memcpy(lw->tc.pbuf->payload + offset, pRx, len); lw->tc.rxLen += len; } } diff --git a/src/microchip/lib/libtc6/inc/tc6-regs.h b/src/microchip/lib/libtc6/inc/tc6-regs.h index b0d117c..e0d078c 100644 --- a/src/microchip/lib/libtc6/inc/tc6-regs.h +++ b/src/microchip/lib/libtc6/inc/tc6-regs.h @@ -148,6 +148,12 @@ void TC6Regs_Reinit(TC6_t *pInst); */ bool TC6Regs_SetPlca(TC6_t *pInst, bool plcaEnable, uint8_t nodeId, uint8_t nodeCount); +/** \brief Returns the LAN865x Revision number. + * \param pInst - The pointer returned by TC6_Init. + * \return 0, in case of error. Otherwise, Chip Revision. + */ +uint8_t TC6Regs_GetChipRevision(TC6_t *pInst); + /** \brief Configure DIOAx GPIOs as output. */ void TC6Regs_EnableDio_A0(TC6_t *pTC6); @@ -191,7 +197,7 @@ uint32_t TC6Regs_CB_GetTicksMs(void); void TC6Regs_CB_OnEvent(TC6_t *pInst, TC6Regs_Event_t event, void *pTag); /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ -/* CONVERSTION FUNCTIONS */ +/* CONVERSION FUNCTIONS */ /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ template