Dear forum
I'm planning a IIoT node based on ESP32-WROOM module and a LAN9354 IEEE1588 switch. The switch chip has an RMII and MIIM PHY interface connection to the EMAC of the ESP32.
http://ww1.microchip.com/downloads/en/D ... 01926B.pdf
My question is, how do I modifie the example PHY drivers in the ESP32 IDF to get a LAN9354 chip supporting driver.
Thank you very much for your help
MIIM Driver for LAN9354
Re: MIIM Driver for LAN9354
Dear forum
MIIM communication is based on the functions "void esp_eth_smi_write (uint32_t reg_num, uint16_t value)", "uint16_t esp_eth_smi_read (uint32_t reg_num)" and "esp_err_t esp_eth_smi_wait_value (uint32_t reg_num, uint16_t value, uint16_t value_mask, int timeout_ms)" of the source file. .. \ esp-idf \ components \ ethernet \ emac_main.c ". These features are not compatible with the LAN9354. The LAN9354 uses the PHY addresses 16 to 32 with the 32 register addresses each as the address space of the 256 32 bit chip registers.
If the source file "emac_main.c" is extended by the following method, a dump of the LAN9354 registers is possible.
and a universal dump methode.
Thank you very much for your help
MIIM communication is based on the functions "void esp_eth_smi_write (uint32_t reg_num, uint16_t value)", "uint16_t esp_eth_smi_read (uint32_t reg_num)" and "esp_err_t esp_eth_smi_wait_value (uint32_t reg_num, uint16_t value, uint16_t value_mask, int timeout_ms)" of the source file. .. \ esp-idf \ components \ ethernet \ emac_main.c ". These features are not compatible with the LAN9354. The LAN9354 uses the PHY addresses 16 to 32 with the 32 register addresses each as the address space of the 256 32 bit chip registers.
If the source file "emac_main.c" is extended by the following method, a dump of the LAN9354 registers is possible.
Code: Select all
uint32_t esp_eth_smi_u32read(uint32_t reg_num)
{
//uint32_t phy_num = emac_config.phy_addr;
uint32_t value = 0;
while (REG_GET_BIT(EMAC_GMIIADDR_REG, EMAC_MIIBUSY) == 1 ) {
}
//REG_WRITE(EMAC_GMIIADDR_REG, 0x1 | ((reg_num & 0x1f) << 6) | ((phy_num & 0x1f) << 11) | (0x3 << 2));
//read upper word
REG_WRITE(EMAC_GMIIADDR_REG, 0x1 | (((reg_num +1)& 0x3FF) << 6) | (0x3 << 2));
while (REG_GET_BIT(EMAC_GMIIADDR_REG, EMAC_MIIBUSY) == 1 ) {
}
value = ((REG_READ(EMAC_MIIDATA_REG) & 0xffff)<< 16);
//read lower word
REG_WRITE(EMAC_GMIIADDR_REG, 0x1 | ((reg_num & 0x3FF) << 6) | (0x3 << 2));
while (REG_GET_BIT(EMAC_GMIIADDR_REG, EMAC_MIIBUSY) == 1 ) {
}
value = value | (REG_READ(EMAC_MIIDATA_REG) & 0xffff);
return value;
}
Code: Select all
void phy_lan9354_unidump_registers()
{
ESP_LOGD(TAG, "LAN9354 Registers:");
for(uint32 i=0; i<250; i++)
{
ESP_LOGD(TAG, "Registers 0x%08x", esp_eth_smi_u32read(i));
}
}
Re: MIIM Driver for LAN9354
Hi,
Did you success to make LAN9354 working with esp32?
Did you success to make LAN9354 working with esp32?
Who is online
Users browsing this forum: morgana2313 and 135 guests