Specifications

netmain()
netmain() is responsible for initializing and launching the NicheStack tasks. The prototype for
netmain() is:
void netmain(void)
netmain() returns nothing and has no parameters.
iniche_net_ready
When the NicheStack stack has completed initialization, it sets the global variable iniche_net_ready to a
non-zero value.
Note: Do not call any NicheStack API functions (other than for initialization) until iniche_net_ready is
true.
Example 11-1: Instantiating the NicheStack TCP/IP Stack Using iniche_net_ready
void SSSInitialTask(void *task_data)
{
INT8U error_code;
alt_iniche_init();
netmain();
while (!iniche_net_ready)
TK_SLEEP(1);
/* Now that the stack is running, perform the application
initialization steps */
.
.
.
}
Macro TK_SLEEP() is part of the NicheStack TCP/IP Stack operating system (OS) porting layer.
get_mac_addr() and get_ip_addr()
The NicheStack TCP/IP Stack system code calls get_mac_addr() and get_ip_addr() during the device
initialization process. These functions are necessary for the system code to set the MAC and IP addresses
for the network interface, which you select with the altera_iniche.iniche_default_if BSP setting.
Because you write these functions yourself, your system has the flexibility to store the MAC address and
IP address in an arbitrary location, rather than a fixed location hard-coded in the device driver. For
example, some systems might store the MAC address in flash memory, while others might have the MAC
address in on-chip embedded memory.
Both functions take as parameters device structures used internally by the NicheStack TCP/IP Stack.
However, you do not need to know the details of the structures. You only need to know enough to fill in
the MAC and IP addresses.
Prototype for get_mac_addr()
The prototype for get_mac_addr() is:
int get_mac_addr(NET net, unsigned char mac_addr[6]);
You must implement the get_mac_addr() function to assign the MAC address to the mac_addr
argument. Leave the net argument untouched.
NII5V2
2015.05.14
netmain()
11-5
Ethernet and the NicheStack TCP/IP Stack - Nios II Edition
Altera Corporation
Send Feedback