diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index d830e03220..eae975a99b 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -1068,4 +1068,10 @@ #define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 0 #endif +/* Set to 1 if you want to receive eNetworkDown notification via vApplicationIPNetworkEventHook() callback. + * Not all drivers support this feature. */ +#ifndef ipconfigSUPPORT_NETWORK_DOWN_EVENT + #define ipconfigSUPPORT_NETWORK_DOWN_EVENT 0 +#endif + #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */ diff --git a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c index 9ab6a0d793..9ee73327f2 100644 --- a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c @@ -1308,6 +1308,15 @@ static void prvEMACHandlerTask( void * pvParameters ) { /* Something has changed to a Link Status, need re-check. */ prvEthernetUpdateConfig( pdFALSE ); + + #if ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) + { + if( xGetPhyLinkStatus() == pdFALSE ) + { + FreeRTOS_NetworkDown(); + } + } + #endif /* ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) */ } } } diff --git a/source/portable/NetworkInterface/STM32Fxx/readme.md b/source/portable/NetworkInterface/STM32Fxx/readme.md index 0b266875d8..e644a18706 100644 --- a/source/portable/NetworkInterface/STM32Fxx/readme.md +++ b/source/portable/NetworkInterface/STM32Fxx/readme.md @@ -81,6 +81,7 @@ Recommended settings for STM32Fxx Network Interface: #define ipconfigZERO_COPY_RX_DRIVER 1 #define ipconfigZERO_COPY_TX_DRIVER 1 #define ipconfigUSE_LINKED_RX_MESSAGES 1 +#define ipconfigSUPPORT_NETWORK_DOWN_EVENT 1 ``` **Defined in stm32f4xx_hal_conf.h**