Hi @Gohil
There is no ready-made example, you need to add it by yourself.
The SDK example(enet_txrx_transfer.c) default function is to send/receive buf to verify enet driver&HW via ringbuf method(while loop), if you want to support interrupt for the receive frames, you need to customized by yourself, but there are some comments from my side, hope the below draf code which based on current reference SDK help you more.
enet_txrx_transfer.c:
/* Init the ENET. */
ENET_Init(EXAMPLE_ENET, &g_handle, &config, &buffConfig[0], &g_macAddr[0], EXAMPLE_CLOCK_FREQ);
|--> ENET_Up(....handle, config, bufferConfig, ....)
|--> ENET_SetHandler(....handle, config, bufferConfig....);
|---> check if rx interrupt happen.
if (0U != (config->interrupt & (uint32_t)ENET_RX_INTERRUPT))
{
ENET_SetRxISRHandler(base, ENET_ReceiveIRQHandler);
}
Plz note the comments of ENET_Up.
* param base ENET peripheral base address.
* param handle ENET handler pointer.
* param config ENET mac configuration structure pointer.
* The "enet_config_t" type mac configuration return from ENET_GetDefaultConfig can be used directly. It is also possible to verify the Mac configuration using other methods.
Please see more details from `ENET_ReceiveIRQHandler` to check
/* Check if the receive interrupt happen. */
/*!
* brief The receive IRQ handler.
*
* param base ENET peripheral base address.
* param handle The ENET handler pointer.
*/
#if FSL_FEATURE_ENET_QUEUE > 1
void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle, uint32_t ringId)
#else
void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle)
#endif /* FSL_FEATURE_ENET_QUEUE > 1 */
{
assert(handle != NULL);
uint32_t mask = (uint32_t)kENET_RxFrameInterrupt | (uint32_t)kENET_RxBufferInterrupt;
/* Check if the receive interrupt happen. */
#if FSL_FEATURE_ENET_QUEUE > 1
switch (ringId)
{
case kENET_Ring1:
mask = ((uint32_t)kENET_RxFrame1Interrupt | (uint32_t)kENET_RxBuffer1Interrupt);
break;
case kENET_Ring2:
mask = ((uint32_t)kENET_RxFrame2Interrupt | (uint32_t)kENET_RxBuffer2Interrupt);
break;
default:
mask = (uint32_t)kENET_RxFrameInterrupt | (uint32_t)kENET_RxBufferInterrupt;
break;
}
#endif /* FSL_FEATURE_ENET_QUEUE > 1 */
while (0U != (mask & base->EIR))
{
/* Clear the transmit interrupt event. */
base->EIR = mask;
/* Callback function. */
if (NULL != handle->callback)
{
#if FSL_FEATURE_ENET_QUEUE > 1
handle->callback(base, handle, ringId, kENET_RxEvent, NULL, handle->userData);
#else
handle->callback(base, handle, kENET_RxEvent, NULL, handle->userData);
#endif /* FSL_FEATURE_ENET_QUEUE > 1 */
}
}
}
Have a nice day,
Sam