Skip to content

Commit 5d1d8b4

Browse files
authored
Merge pull request #2685 from andreaslarssonublox/stm32f4_phy_fix
lwip - replace vendor specific register usage in stm32f4_emac.c with basic register
2 parents da14bce + 189d932 commit 5d1d8b4

File tree

1 file changed

+3
-19
lines changed
  • features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4

1 file changed

+3
-19
lines changed

features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_STM/TARGET_STM32F4/stm32f4_emac.c

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,6 @@ static void _eth_arch_low_level_init(struct netif *netif)
133133
/* Enable MAC and DMA transmission and reception */
134134
HAL_ETH_Start(&EthHandle);
135135

136-
/**** Configure PHY to generate an interrupt when Eth Link state changes ****/
137-
/* Read Register Configuration */
138-
HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MICR, &regvalue);
139-
140-
regvalue |= (PHY_MICR_INT_EN | PHY_MICR_INT_OE);
141-
142-
/* Enable Interrupts */
143-
HAL_ETH_WritePHYRegister(&EthHandle, PHY_MICR, regvalue);
144-
145-
/* Read Register Configuration */
146-
HAL_ETH_ReadPHYRegister(&EthHandle, PHY_MISR, &regvalue);
147-
148-
regvalue |= PHY_MISR_LINK_INT_EN;
149-
150-
/* Enable Interrupt on change of link status */
151-
HAL_ETH_WritePHYRegister(&EthHandle, PHY_MISR, regvalue);
152136
#endif
153137
}
154138

@@ -362,10 +346,10 @@ static void _eth_arch_phy_task(void *arg)
362346

363347
while (1) {
364348
uint32_t status;
365-
if (HAL_ETH_ReadPHYRegister(&EthHandle, PHY_SR, &status) == HAL_OK) {
366-
if ((status & PHY_LINK_STATUS) && !(phy_status & PHY_LINK_STATUS)) {
349+
if (HAL_ETH_ReadPHYRegister(&EthHandle, PHY_BSR, &status) == HAL_OK) {
350+
if ((status & PHY_LINKED_STATUS) && !(phy_status & PHY_LINKED_STATUS)) {
367351
tcpip_callback_with_block((tcpip_callback_fn)netif_set_link_up, (void*) netif, 1);
368-
} else if (!(status & PHY_LINK_STATUS) && (phy_status & PHY_LINK_STATUS)) {
352+
} else if (!(status & PHY_LINKED_STATUS) && (phy_status & PHY_LINKED_STATUS)) {
369353
tcpip_callback_with_block((tcpip_callback_fn)netif_set_link_down, (void*) netif, 1);
370354
}
371355
phy_status = status;

0 commit comments

Comments
 (0)