Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

Ethernet Device Driver

Hello,

I am working with a nios development board with a stratixII_2s60.

I am trying to write my own ethernet device driver for an Ethernet MAC called "rtmac" that was build at my institute. Following the advise in the nios II software developer's handbook I startet out with the device driver for the lan91c111 called "altera_avalon_lan91c111" and changed it according to my needs.

When altera_avalon_rtmac.h is compiled I get the error:

error: `name' undeclared here (not in a function)[/cygdrive/z/Altera_examples/vhdl/niosII_stratixII_2s60_ES/testsys/rtmac/UCOSII/inc/altera_avalon_rtmac.h] web_server_6 line 102 12.

Does anyone have an idea why this error occurs? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif

I would be very happy for any answer!

Here is my code for the altera_avalon_rtmac.h:

-----------------------------------------------------------------------------------------------# ifndef __ALTERA_AVALON_RTMAC_H__ # define __ALTERA_AVALON_RTMAC_H__

# ifdef LWIP# include <stdlib.h># include <stdio.h># include "alt_types.h"# include "system.h"# include "lwip/netif.h"# include "arch/sys_arch.h"# include "alt_lwip_dev.h"# include "sys/alt_warning.h"

# ifdef __cplusplus

extern "C"

{# endif /* __cplusplus */

err_t alt_avalon_rtmac_init(struct netif *netif);

void alt_avalon_rtmac_rx();

typedef struct

{

alt_lwip_dev_list lwip_dev_list;

int base_addr;

int irq;

// a DATA_BUS_WIDTH is not listed in system.h for the rtmac_0

// int bus_width;

sys_sem_t semaphore;

alt_u8 tx_packet_no; /* Number of packet allocated for Tx */

}alt_avalon_rtmac_if;

# define ALTERA_AVALON_RTMAC_INSTANCE(name, dev) \

alt_avalon_rtmac_if dev =

{

{

ALT_LLIST_ENTRY,

{

0,

name##_NAME,

alt_avalon_rtmac_init,

alt_avalon_rtmac_rx,

},

},

name##_BASE,

// a Register_offset is not listed in system.h for the rtmac_0

// name##_BASE + name##_RTMAC_REGISTERS_OFFSET,

name##_IRQ,

// a DATA_BUS_WIDTH is not listed in system.h for the rtmac_0

// name##_RTMAC_DATA_BUS_WIDTH,

0,

0

};

# define ALTERA_AVALON_RTMAC_INIT(name, dev)

if (name##_IRQ == ALT_IRQ_NOT_CONNECTED)

{

ALT_LINK_ERROR ("Error: Interrupt not connected for "# dev ". "

"The ALTERA Avalon rtmac driver requires that an "

"interrupt is connected. Please select an IRQ for "

"this device in SOPC builder.");

}

// a DATA_BUS_WIDTH is not listed in system.h for the rtmac_0

// else if (name##_RTMAC_DATA_BUS_WIDTH != 32)

// {

// ALT_LINK_ERROR ("Error: Invalid configuration for "# dev ". "

// "The ALTERA Avalon rtmac driver currently only "

// "supports the configuration of MAC/PHY on the "

// "development board. Please select this option "

// "in SOPC builder.");

// }

else

{

alt_lwip_dev_reg(dev);

}

# ifdef __cplusplus

}# endif /* __cplusplus */

# else# warning excluding drivers for the rtmac as you do not have the LWIP software component selected# define ALTERA_AVALON_RTMAC_INSTANCE(name, dev) extern int alt_no_storage# define ALTERA_AVALON_RTMAC_INIT(name, dev) while(0) # endif /* LWIP */

# endif /* __ALTERA_AVALON_RTMAC_H__ */