How to port Azure Rtos NetX driver to an external spi controller?
Hi,
I'm having trouble understanding the function of NetX that reads data received from ethernet:
static VOID _nx_driver_hardware_packet_received(VOID)
{
NX_PACKET *packet_ptr;
NX_PACKET *received_packet_ptr;
INT i;
uint32_t framelength = 0;
static ETH_BufferTypeDef RxBuff[NX_DRIVER_RX_DESCRIPTORS];
memset(RxBuff, 0 , NX_DRIVER_RX_DESCRIPTORS*sizeof(ETH_BufferTypeDef));
for(i = 0; i < NX_DRIVER_RX_DESCRIPTORS -1; i++)
{
RxBuff[i].next=&RxBuff[i+1];
}
while (HAL_ETH_GetRxDataBuffer(&heth, RxBuff) == HAL_OK)
{
HAL_ETH_GetRxDataLength(&heth, &framelength);
ETH_RxDescListTypeDef *dmarxdesclist = &heth.RxDescList;
uint32_t FirstAppDesc = dmarxdesclist->FirstAppDesc;
/* This driver assumes the recieved packet size is 1536 bytes */
received_packet_ptr = nx_driver_information.nx_driver_information_receive_packets[FirstAppDesc];
received_packet_ptr->nx_packet_append_ptr = received_packet_ptr->nx_packet_prepend_ptr + framelength;
received_packet_ptr->nx_packet_length = framelength;
received_packet_ptr->nx_packet_next = NULL;
if (nx_packet_allocate(nx_driver_information.nx_driver_information_packet_pool_ptr, &packet_ptr,
NX_RECEIVE_PACKET, NX_NO_WAIT) == NX_SUCCESS)
{
/* Adjust the packet. */
packet_ptr -> nx_packet_prepend_ptr += 2;
SCB_InvalidateDCache_by_Addr((uint32_t*)packet_ptr -> nx_packet_data_start, packet_ptr -> nx_packet_data_end - packet_ptr -> nx_packet_data_start);
HAL_ETH_DescAssignMemory(&heth, FirstAppDesc, packet_ptr -> nx_packet_prepend_ptr, NULL);
nx_driver_information.nx_driver_information_receive_packets[FirstAppDesc] = packet_ptr;
/* Build Rx descriptor to be ready for next data reception */
HAL_ETH_BuildRxDescriptors(&heth);
/* Transfer the packet to NetX. */
_nx_driver_transfer_to_netx(nx_driver_information.nx_driver_information_ip_ptr, received_packet_ptr);
}
else
{
HAL_ETH_BuildRxDescriptors(&heth);
}
}
}
I don't understand where RxBuff is used after the function HAL_ETH_GetRxDataBuffer(&heth, RxBuff).
How can I modify the funtion "static VOID _nx_driver_hardware_packet_received(VOID)" to use my custom ethernet controller read funtion:
Packet_Length = ReadPacket(pBuf);
pBuf is a pointer where the packet will be transfered to, and the Packet_Length is the packet size.
