Hardware Initialization

DM2_EmacInit()

void *DM2_EmacInit (uint8_t mode, char *mac_addr_str, void (*link_status)(unsigned char));
resets and configures the Ethernet Controller to the network hardware interface: 10, 100M or 1Gbits/s, full or half duplex. You may also use auto-negotiation mode if your network hub supports this mode. Auto-Negotiation starts with 1G bit/s full-duplex and tries to establish a connection. If unsuccessful, the other modes are checked: 100M bits/s full-duplex, 100M bits/s half-duplex, 10 bits/s full duplex, and 10M bits/s half-duplex, until a matching mode is found.
Setting the MAC address by passing the mac_addr_str is available on DM2DM642, DM2C6747, VibPilot2, Unidaq and DM2C6657 only
The link_status() callback function is a user defined function for link status change events. If no link status messages are required, this parameter can be set to NULL.

Example configuration for Autonegotiation and a link status callback:

/*******************************************************************************
@brief link status change callback function
@param link mode: HDX_10, HDX_100, FDX_10, FDX_100
@return nothing
*******************************************************************************/
far void link_status (uint8_t mode)
{
CPrintf ("\r\n Link status changed: ");
switch (mode)
{
case 0xff:
_link = 0;
CPrintf ("No Link\r\n");
break;
default:
_link = 1;
CPrintf ("Linked at %dMbit %s duplex\r\n",
(mode & SPEED_100) ? 100:10,
(mode & FULL_DUPLEX) ? "full":"half");
break;
}
}
...
/*******************************************************************************
initialize EMAC
*******************************************************************************/
{
prg_exit ("HW init function failed"); /* initialize EMAC error */
}


Example configuration for 100MBit full duplex without link status callback:

/*******************************************************************************
initialize EMAC
*******************************************************************************/
{
prg_exit ("HW init function failed"); /* initialize EMAC error */
}


Example configuration using variable network_mode from netconfig.c:

Refer to Device Specific Initialization file netconfig.c

/*******************************************************************************
initialize EMAC using variable from netconfig.c
*******************************************************************************/
{
prg_exit ("HW init function failed"); /* initialize EMAC error */
}