Skip to content

Commit b15dffa

Browse files
committed
STM32 EMAC : add PHY ID information
1 parent 01a186a commit b15dffa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ static osThreadId_t create_new_thread(const char *threadName, void (*thread)(voi
291291
bool STM32_EMAC::low_level_init_successful()
292292
#ifndef ETH_IP_VERSION_V2
293293
{
294+
uint32_t PHY_ID;
295+
294296
/* Init ETH */
295297
uint8_t MACAddr[6];
296298
EthHandle.Instance = ETH;
@@ -321,6 +323,17 @@ bool STM32_EMAC::low_level_init_successful()
321323
return false;
322324
}
323325

326+
uint32_t TempRegisterValue;
327+
if (HAL_ETH_ReadPHYRegister(&EthHandle, 2, &TempRegisterValue) != HAL_OK) {
328+
tr_error("HAL_ETH_ReadPHYRegister 2 issue");
329+
}
330+
PHY_ID = (TempRegisterValue << 16);
331+
if (HAL_ETH_ReadPHYRegister(&EthHandle, 3, &TempRegisterValue) != HAL_OK) {
332+
tr_error("HAL_ETH_ReadPHYRegister 3 issue");
333+
}
334+
PHY_ID |= (TempRegisterValue & 0XFFF0);
335+
tr_info("PHY ID %#X", PHY_ID);
336+
324337
/* Initialize Tx Descriptors list: Chain Mode */
325338
if (HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB) != HAL_OK) {
326339
tr_error("HAL_ETH_DMATxDescListInit issue");

0 commit comments

Comments
 (0)