Merge pull request #2692 from SummerGGift/phy_check
[bsp][stm32][driver] fix phy detection driver
This commit is contained in:
commit
361754e037
|
@ -91,10 +91,10 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev)
|
||||||
EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE;
|
EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE;
|
||||||
#ifdef RT_LWIP_USING_HW_CHECKSUM
|
#ifdef RT_LWIP_USING_HW_CHECKSUM
|
||||||
EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
|
EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
|
||||||
#else
|
#else
|
||||||
EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE;
|
EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HAL_ETH_DeInit(&EthHandle);
|
HAL_ETH_DeInit(&EthHandle);
|
||||||
|
|
||||||
/* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
|
/* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
|
||||||
|
@ -431,31 +431,34 @@ static void phy_monitor_thread_entry(void *parameter)
|
||||||
uint8_t phy_addr = 0xFF;
|
uint8_t phy_addr = 0xFF;
|
||||||
uint8_t phy_speed_new = 0;
|
uint8_t phy_speed_new = 0;
|
||||||
rt_uint32_t status = 0;
|
rt_uint32_t status = 0;
|
||||||
|
uint8_t detected_count = 0;
|
||||||
|
|
||||||
/* phy search */
|
while(phy_addr == 0xFF)
|
||||||
rt_uint32_t i, temp;
|
|
||||||
for (i = 0; i <= 0x1F; i++)
|
|
||||||
{
|
{
|
||||||
EthHandle.Init.PhyAddress = i;
|
/* phy search */
|
||||||
|
rt_uint32_t i, temp;
|
||||||
HAL_ETH_ReadPHYRegister(&EthHandle, PHY_ID1_REG, (uint32_t *)&temp);
|
for (i = 0; i <= 0x1F; i++)
|
||||||
|
|
||||||
if (temp != 0xFFFF && temp != 0x00)
|
|
||||||
{
|
{
|
||||||
phy_addr = i;
|
EthHandle.Init.PhyAddress = i;
|
||||||
break;
|
HAL_ETH_ReadPHYRegister(&EthHandle, PHY_ID1_REG, (uint32_t *)&temp);
|
||||||
|
|
||||||
|
if (temp != 0xFFFF && temp != 0x00)
|
||||||
|
{
|
||||||
|
phy_addr = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
detected_count++;
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
|
if (detected_count > 10)
|
||||||
|
{
|
||||||
|
LOG_E("No PHY device was detected, please check hardware!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phy_addr == 0xFF)
|
LOG_D("Found a phy, address:0x%02X", phy_addr);
|
||||||
{
|
|
||||||
LOG_E("phy not probe!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOG_D("found a phy, address:0x%02X", phy_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RESET PHY */
|
/* RESET PHY */
|
||||||
LOG_D("RESET PHY!");
|
LOG_D("RESET PHY!");
|
||||||
|
|
Loading…
Reference in New Issue