Middleware for the Azure RTOS NetX Duo Ether Driver on RZ MPUs.
Overview
This module provides a NetX Duo driver that is implemented using the Ethernet Interface.
Please refer to the NetXDuo documentation for further details.
Features
- Packet Types Supported
- Link status callback
- Configurable IP MTU
Configuration
Configurations for Networking > NetX Duo Ethernet Driver (rm_netxduo_ether)
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_netxduo_ether_0 | Module name. |
IP MTU | Value must be in the range [576, 1500] bytes. | 1500 | IP MTU |
Usage Notes
Calculating the Packet Size for an IP instance
In order to ensure that there is enough space to store an entire Ethernet frame, the packet pool used for receiving packets must have a payload size that is 32 bytes larger than the configured ether_cfg_t::ether_buffer_size. The extra 32 bytes is needed in order to ensure that the allocated packets are properly aligned to 32 bytes.
ether_cfg_t::ether_buffer_size is calcualted from the IP MTU using the following formula:
ceil(( rm_netxduo_ether_cfg_t::mtu + Ethernet Header (14) + Padding Bytes (2)) / 32 ) * 32
Examples
Basic Example
This is a basic example of minimal use of the NetX Duo Ether Driver in an application.
#define NETXDUO_EXAMPLE_IP_STACK_SIZE (2048U)
#define NETXDUO_EXAMPLE_ARP_CACHE_SIZE (2048U)
#define NETXDUO_EXAMPLE_PACKET_SIZE (1568U)
#define NETXDUO_EXAMPLE_PACKET_NUM (100U)
#define NETXDUO_EXAMPLE_PACKET_POOL_SIZE ((sizeof(NX_PACKET) + NETXDUO_EXAMPLE_PACKET_SIZE) * \
NETXDUO_EXAMPLE_PACKET_NUM)
static NX_IP g_ip;
static NX_PACKET_POOL g_packet_pool;
static uint8_t g_ip_stack_memory[NETXDUO_EXAMPLE_IP_STACK_SIZE] BSP_ALIGN_VARIABLE(4);
static uint8_t g_packet_pool_memory[NETXDUO_EXAMPLE_PACKET_POOL_SIZE] BSP_ALIGN_VARIABLE(4);
static uint8_t g_ip_arp_cache_memory[NETXDUO_EXAMPLE_ARP_CACHE_SIZE] BSP_ALIGN_VARIABLE(4);
static void rm_netxduo_ether0 (NX_IP_DRIVER * driver_req_ptr)
{
rm_netxduo_ether(driver_req_ptr, &g_netxduo_ether_instance);
}
void rm_netxduo_ether_example ()
{
UINT status;
nx_system_initialize();
status = nx_packet_pool_create(&g_packet_pool,
"Packet Pool",
NETXDUO_EXAMPLE_PACKET_SIZE,
&g_packet_pool_memory[0],
NETXDUO_EXAMPLE_PACKET_POOL_SIZE);
assert(NX_SUCCESS == status);
status = nx_ip_create(&g_ip,
"IP Instance",
IP_ADDRESS(192, 168, 1, 2),
IP_ADDRESS(255, 255, 255, 0),
&g_packet_pool,
rm_netxduo_ether0,
&g_ip_stack_memory[0],
sizeof(g_ip_stack_memory),
0);
assert(NX_SUCCESS == status);
status = nx_arp_enable(&g_ip, g_ip_arp_cache_memory, sizeof(g_ip_arp_cache_memory));
assert(NX_SUCCESS == status);
status = nx_tcp_enable(&g_ip);
assert(NX_SUCCESS == status);
status = nx_icmp_enable(&g_ip);
assert(NX_SUCCESS == status);
}