From a747194e21c46665b9f73241d555b7a0199939f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Thu, 21 Sep 2023 14:08:02 +0200 Subject: [PATCH 1/4] Support network down event --- source/portable/NetworkInterface/STM32/NetworkInterface.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/portable/NetworkInterface/STM32/NetworkInterface.c b/source/portable/NetworkInterface/STM32/NetworkInterface.c index a2f6dd582..feaa05f98 100644 --- a/source/portable/NetworkInterface/STM32/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32/NetworkInterface.c @@ -787,6 +787,10 @@ static void prvEthernetUpdateConfig( void ) /* iptraceNETWORK_INTERFACE_STATUS_CHANGE(); */ xHalResult = HAL_ETH_Stop_IT( &xEthHandle ); configASSERT( xHalResult == HAL_OK ); + + #if ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) + FreeRTOS_NetworkDown( pxMyInterface ); + #endif } } From 08604cf839180afd79d32c100ee6f71515ee9ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Fri, 22 Sep 2023 13:47:37 +0200 Subject: [PATCH 2/4] Don't return pdPASS on interface initialize when link is down --- source/portable/NetworkInterface/STM32/NetworkInterface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/portable/NetworkInterface/STM32/NetworkInterface.c b/source/portable/NetworkInterface/STM32/NetworkInterface.c index feaa05f98..59512d3e7 100644 --- a/source/portable/NetworkInterface/STM32/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32/NetworkInterface.c @@ -396,7 +396,10 @@ static BaseType_t xSTM32_NetworkInterfaceInitialise( NetworkInterface_t * pxInte case eMACInitComplete: configASSERT( xEthHandle.gState != HAL_ETH_STATE_ERROR ); - xInitResult = pdPASS; + if( xSTM32_GetPhyLinkStatus( pxInterface ) == pdPASS ) + { + xInitResult = pdPASS; + } } return xInitResult; From 57d78d95ae6b28908d60f8b7e2ee94d0374c3fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Mon, 25 Sep 2023 11:17:57 +0200 Subject: [PATCH 3/4] Fix formatting --- source/portable/NetworkInterface/STM32/NetworkInterface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/portable/NetworkInterface/STM32/NetworkInterface.c b/source/portable/NetworkInterface/STM32/NetworkInterface.c index 59512d3e7..5730f5dfb 100644 --- a/source/portable/NetworkInterface/STM32/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32/NetworkInterface.c @@ -396,6 +396,7 @@ static BaseType_t xSTM32_NetworkInterfaceInitialise( NetworkInterface_t * pxInte case eMACInitComplete: configASSERT( xEthHandle.gState != HAL_ETH_STATE_ERROR ); + if( xSTM32_GetPhyLinkStatus( pxInterface ) == pdPASS ) { xInitResult = pdPASS; From 41d699ce235babca20fd095f22206c4bc4aa84d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Sowa?= Date: Mon, 25 Sep 2023 14:08:57 +0200 Subject: [PATCH 4/4] Clean redundant comment --- .../portable/NetworkInterface/STM32/NetworkInterface.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/source/portable/NetworkInterface/STM32/NetworkInterface.c b/source/portable/NetworkInterface/STM32/NetworkInterface.c index 5730f5dfb..20f0d329b 100644 --- a/source/portable/NetworkInterface/STM32/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32/NetworkInterface.c @@ -695,16 +695,6 @@ static void prvEMACHandlerTask( void * pvParameters ) if( xPhyCheckLinkStatus( &xPhyObject, xResult ) != pdFALSE ) { prvEthernetUpdateConfig(); - - /* - #if ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) - { - if( xGetPhyLinkStatus() == pdFALSE ) - { - FreeRTOS_NetworkDown(); - } - } - */ } } }