@@ -446,7 +446,7 @@ esp_err_t ETHClass::eth_spi_write(uint32_t cmd, uint32_t addr, const void *data,
446
446
#endif
447
447
448
448
bool ETHClass::beginSPI (
449
- eth_phy_type_t type, int32_t phy_addr, int cs, int irq, int rst,
449
+ eth_phy_type_t type, int32_t phy_addr, uint8_t * mac_addr_p, int cs, int irq, int rst,
450
450
#if ETH_SPI_SUPPORTS_CUSTOM
451
451
SPIClass *spi,
452
452
#endif
@@ -654,16 +654,20 @@ bool ETHClass::beginSPI(
654
654
return false ;
655
655
}
656
656
657
- // Derive a new MAC address for this interface
658
- uint8_t base_mac_addr[ETH_ADDR_LEN];
659
- ret = esp_efuse_mac_get_default (base_mac_addr);
660
- if (ret != ESP_OK) {
661
- log_e (" Get EFUSE MAC failed: %d" , ret);
662
- return false ;
663
- }
664
657
uint8_t mac_addr[ETH_ADDR_LEN];
665
- base_mac_addr[ETH_ADDR_LEN - 1 ] += _eth_index; // Increment by the ETH number
666
- esp_derive_local_mac (mac_addr, base_mac_addr);
658
+ if (mac_addr_p != nullptr ) {
659
+ memcpy (mac_addr, mac_addr_p, ETH_ADDR_LEN);
660
+ } else {
661
+ // Derive a new MAC address for this interface
662
+ uint8_t base_mac_addr[ETH_ADDR_LEN];
663
+ ret = esp_efuse_mac_get_default (base_mac_addr);
664
+ if (ret != ESP_OK) {
665
+ log_e (" Get EFUSE MAC failed: %d" , ret);
666
+ return false ;
667
+ }
668
+ base_mac_addr[ETH_ADDR_LEN - 1 ] += _eth_index; // Increment by the ETH number
669
+ esp_derive_local_mac (mac_addr, base_mac_addr);
670
+ }
667
671
668
672
ret = esp_eth_ioctl (_eth_handle, ETH_CMD_S_MAC_ADDR, mac_addr);
669
673
if (ret != ESP_OK) {
@@ -776,7 +780,7 @@ bool ETHClass::beginSPI(
776
780
#if ETH_SPI_SUPPORTS_CUSTOM
777
781
bool ETHClass::begin (eth_phy_type_t type, int32_t phy_addr, int cs, int irq, int rst, SPIClass &spi, uint8_t spi_freq_mhz) {
778
782
779
- return beginSPI (type, phy_addr, cs, irq, rst, &spi, -1 , -1 , -1 , SPI2_HOST, spi_freq_mhz);
783
+ return beginSPI (type, phy_addr, nullptr , cs, irq, rst, &spi, -1 , -1 , -1 , SPI2_HOST, spi_freq_mhz);
780
784
}
781
785
#endif
782
786
@@ -785,7 +789,7 @@ bool ETHClass::begin(
785
789
) {
786
790
787
791
return beginSPI (
788
- type, phy_addr, cs, irq, rst,
792
+ type, phy_addr, nullptr , cs, irq, rst,
789
793
#if ETH_SPI_SUPPORTS_CUSTOM
790
794
NULL ,
791
795
#endif
0 commit comments