},\r
};\r
\r
-volatile uint8_t uIPManagementTimeout;\r
+struct timer ConnectionTimer, ARPTimer;\r
+uint16_t MillisecondTickCount;\r
\r
/** ISR for the management of the connection management timeout counter */\r
ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
{\r
- if (uIPManagementTimeout)\r
- uIPManagementTimeout--;\r
+ MillisecondTickCount++;\r
}\r
\r
void TCPCallback(void)\r
printf("0x%02X ", uip_buf[i]);\r
printf("\r\n\r\n");\r
\r
- #define BUF ((struct uip_eth_hdr *)&uip_buf[0])\r
-\r
- if (BUF->type == HTONS(UIP_ETHTYPE_IP))\r
+ struct uip_eth_hdr* EthernetHeader = (struct uip_eth_hdr*)&uip_buf[0];\r
+ if (EthernetHeader->type == HTONS(UIP_ETHTYPE_IP))\r
{\r
/* Filter packet by MAC destination */\r
uip_arp_ipin();\r
if (uip_len > 0)\r
uip_arp_out();\r
}\r
- else if (BUF->type == HTONS(UIP_ETHTYPE_ARP))\r
+ else if (EthernetHeader->type == HTONS(UIP_ETHTYPE_ARP))\r
{\r
/* Process ARP packet */\r
uip_arp_arpin();\r
\r
void ManageConnections(void)\r
{\r
- if (!(uIPManagementTimeout))\r
+ if (timer_expired(&ConnectionTimer))\r
{\r
+ timer_reset(&ConnectionTimer);\r
+\r
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
\r
for (uint8_t i = 0; i < UIP_CONNS; i++)\r
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf, uip_len);\r
}\r
\r
- uip_arp_timer();\r
- \r
- uIPManagementTimeout = 250;\r
-\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
}\r
+\r
+ if (timer_expired(&ARPTimer))\r
+ {\r
+ timer_reset(&ARPTimer);\r
+ uip_arp_timer();\r
+ }\r
}\r
\r
/** Configures the board hardware and chip peripherals for the demo's functionality. */\r
LEDs_Init();\r
USB_Init();\r
\r
- /* Millisecond timer initialization for managing the command timeout counter */\r
- OCR0A = ((F_CPU / 64) / 1000);\r
- TCCR0A = (1 << WGM01);\r
- TCCR0B = ((1 << CS01) | (1 << CS00));\r
- \r
+ /* uIP Timing Initialization */\r
+ clock_init();\r
+ timer_set(&ConnectionTimer, CLOCK_SECOND / 2);\r
+ timer_set(&ARPTimer, CLOCK_SECOND * 10); \r
+\r
/* uIP Stack Initialization */\r
uip_init();\r
-\r
uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress;\r
- uip_ipaddr(&IPAddress, 192, 168, 1, 10);\r
- uip_ipaddr(&Netmask, 0xFF, 0xFF, 0xFF, 0x00);\r
+ uip_ipaddr(&IPAddress, 192, 168, 1, 10);\r
+ uip_ipaddr(&Netmask, 255, 255, 255, 0);\r
uip_ipaddr(&GatewayIPAddress, 192, 168, 1, 1);\r
uip_sethostaddr(&IPAddress);\r
uip_setnetmask(&Netmask);\r
uip_setdraddr(&GatewayIPAddress);\r
- \r
+ \r
/* HTTP Webserver Initialization */\r
uip_listen(HTONS(80));\r
}\r