Skip to content

Pulling in latest fixes from MicrochipTech/oa-tc6-lib #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 12 additions & 37 deletions src/microchip/TC6_Arduino_10BASE_T1S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/microchip/lib/libtc6/inc/tc6-regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 <typename Enumeration>
Expand Down
Loading