The link status callback function is called from net_isq() any time the link status has changed. Use this function to print a message, switch LED's, set global variables (e.g. _link) to enable/ disable specific sections of code.
Install this callback by passing this function as parameter to DM2_EmacInit() during initialization.
You shouldn't make use of long operation functions (like stdio printf) within this callback. Use global flags instead.
In case of DHCP configuration the internal IP address should be reset, if no link is available and the DHCP request should be re-triggered if a link is established. Optionally the ARP cache can be cleared (arp_clear_cache()) to avoid long response times if a destination route has changed.
- Parameters
-
mode | - HDX_10, HDX_100, FDX_10, FDX_100, FDX1000 |
- Returns
- nothing
- See also
- DM2_EmacInit
-
Hardware Initialization, _link, BoardSpecific.c
-
HDX_10, HDX_100, FDX_10, FDX_100, FDX_1000
- Examples:
- BoardSpecific.c.
448 if (!((
eth.
ip[0]-
'0')<=9))
uint8_t _link_mode
Definition: BoardSpecific.c:138
volatile uint16_t _link
Definition: BoardSpecific.c:143
uint32_t(* dhcp_setting)(char *, uint16_t)
Definition: net.h:168
char ip[31]
Definition: net.h:170
adapter_t eth
Definition: netconfig.c:62
void arp_clear_cache(void)
Invalidate ARP cache.
uint32_t set_ip_address(uint16_t dev_nr, char *addr_str)
Set IP address.
- Parameters
-
pLog | - printf function or NULL |
- Returns
- TRUE (1) - link status changed
-
FALSE (0) - link status not changed
Use this function in your main loop to detect a link status change. Global flag _link_mode is monitored and in case of change a LED can be toggled or a message can be printed on the default output terminal. Parameter pLog can be a standard formatted print function like printf or CPrintf. If this parameter is NULL, no output is printed. The return value can be used for event processing in case of a status change.
- Note
- _link_mode is only valid, if a link_status callback function is used and the _link_mode is set.
- See also
- DHCPTest.c
- Examples:
- BoardSpecific.c.
502 static uint8_t _link_mode_old = 0xff;
507 if (pLog) pLog (
"\n\r Link status changed: ");
512 if (pLog) pLog (
"No Link\r\n");
517 if (pLog) pLog (
"Linked at %d%sMbit %s duplex\r\n",
uint8_t _link_mode
Definition: BoardSpecific.c:138
void LED_on(unsigned int ledNum)
Definition: BoardSpecific.c:1302
#define SPEED_1000
Definition: net.h:254
unsigned char uint8_t
Definition: stdint.h:43
void LED_off(unsigned int ledNum)
Definition: BoardSpecific.c:1284
#define SPEED_100
Definition: net.h:246
#define FULL_DUPLEX
Definition: net.h:231
- Parameters
-
pLog | - printf function or NULL |
- Returns
- TRUE (1) - IP address assigned
-
FALSE (0) - IP address not changed
Use this function to monitor IP assignment. Useful when the IP address is assigned dynamically by DHCP. The return value can be used for event processing, e.g. send a welcome message or email. Parameter pLog can be a standard formatted print function like printf or CPrintf. If this parameter is NULL, no output is printed.
- See also
- DHCPTest.c
- Examples:
- BoardSpecific.c.
572 pLog (
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
573 pLog (
" !!! warning: no DHCP server available !!!\r\n");
574 pLog (
" !!! assigned IP address is a link-local address !!!\r\n");
575 pLog (
" !!! make sure your host is in the same local !!!\r\n");
576 pLog (
" !!! subnet: 169.254.x.x !!!\r\n");
577 pLog (
" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
580 pLog (
"\r\n network configuration:");
unsigned short uint16_t
Definition: stdint.h:45
#define UINT32_C(value)
Definition: stdint.h:210
unsigned int uint32_t
Definition: stdint.h:47
uint32_t get_ip_address(uint16_t dev_nr)
Get configured IP address.
void net_print_stat(uint16_t dev_nr, tpOutputFunc pLog)
Print statistic TCP stack information.
#define IS_LINKLOCAL(a)
Definition: net.h:746