x-cube-azrtos-f4 icon indicating copy to clipboard operation
x-cube-azrtos-f4 copied to clipboard

Where is best place to call LAN8742_StartAutoNego()?

Open gausstop opened this issue 2 years ago • 0 comments

I have a custom stm32f407igt6 board with LAN8742A eth interface.

I got a problem that i can get eth work in 10MBITS_HALFDUPLEX mode only. I have checked nx_stm32_phy_driver.c and nx_stm32_eth_driver.c, there are no LAN8742_StartAutoNego() calling.

After add following modification, It's work fine.

int32_t nx_eth_phy_init(void)
{
    int32_t ret = ETH_PHY_STATUS_ERROR;
    /* Set PHY IO functions */

    LAN8742_RegisterBusIO(&LAN8742, &LAN8742_IOCtx);
    /* Initialize the LAN8742 ETH PHY */

    if (LAN8742_Init(&LAN8742) == LAN8742_STATUS_OK)
    {
      printf("LAN8742 Inital OK\n");
      ret = ETH_PHY_STATUS_OK;
    }else{
      printf("LAN8742 Fail\n");
      ret = ETH_PHY_STATUS_ERROR;
    }

    if (LAN8742_StartAutoNego(&LAN8742) == LAN8742_STATUS_OK)
    {
      ret = ETH_PHY_STATUS_OK;
    }else{
      ret = ETH_PHY_STATUS_ERROR;
    }

    do{
      //wait AUTONEGO done
    }while(LAN8742_STATUS_AUTONEGO_NOTDONE == LAN8742_GetLinkState(&LAN8742));

    do{
      //wait link state go up
    }while(LAN8742_STATUS_LINK_DOWN == LAN8742_GetLinkState(&LAN8742));
    
    return ret;
}

but after update souce code with stm32cubemx , it will be replaced.

please help work it around.

gausstop avatar Feb 16 '23 14:02 gausstop