From b15dffaef2e8c321049caad0df9098789f43949b Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Thu, 20 Feb 2020 15:32:48 +0100 Subject: [PATCH] STM32 EMAC : add PHY ID information --- .../emac-drivers/TARGET_STM/stm32xx_emac.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp b/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp index 15fb7c70c3..e44b7b546d 100644 --- a/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp +++ b/features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp @@ -291,6 +291,8 @@ static osThreadId_t create_new_thread(const char *threadName, void (*thread)(voi bool STM32_EMAC::low_level_init_successful() #ifndef ETH_IP_VERSION_V2 { + uint32_t PHY_ID; + /* Init ETH */ uint8_t MACAddr[6]; EthHandle.Instance = ETH; @@ -321,6 +323,17 @@ bool STM32_EMAC::low_level_init_successful() return false; } + uint32_t TempRegisterValue; + if (HAL_ETH_ReadPHYRegister(&EthHandle, 2, &TempRegisterValue) != HAL_OK) { + tr_error("HAL_ETH_ReadPHYRegister 2 issue"); + } + PHY_ID = (TempRegisterValue << 16); + if (HAL_ETH_ReadPHYRegister(&EthHandle, 3, &TempRegisterValue) != HAL_OK) { + tr_error("HAL_ETH_ReadPHYRegister 3 issue"); + } + PHY_ID |= (TempRegisterValue & 0XFFF0); + tr_info("PHY ID %#X", PHY_ID); + /* Initialize Tx Descriptors list: Chain Mode */ if (HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB) != HAL_OK) { tr_error("HAL_ETH_DMATxDescListInit issue");