Skip to content

Commit 159344a

Browse files
committed
Eliminate reading MAC address from EEPROM - we've moved past the Mikroe Two-Wire-Eth boards by now.
1 parent 2a252e2 commit 159344a

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

examples/LAN8651-iperf/LAN8651-iperf.ino

Lines changed: 1 addition & 36 deletions
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-
}

0 commit comments

Comments
 (0)