Skip to content
Merged
6 changes: 6 additions & 0 deletions source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
9 changes: 9 additions & 0 deletions source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) */
}
}
}
Expand Down
1 change: 1 addition & 0 deletions source/portable/NetworkInterface/STM32Fxx/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down