/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); TCP_Init(); Webserver_Init(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { if (Ethernet_RNDIS_Interface.State.FrameIN.FrameInBuffer) { LEDs_SetAllLEDs(LEDMASK_USB_BUSY); Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.State.FrameIN, &Ethernet_RNDIS_Interface.State.FrameOUT); LEDs_SetAllLEDs(LEDMASK_USB_READY); } TCP_TCPTask(&Ethernet_RNDIS_Interface); RNDIS_Device_USBTask(&Ethernet_RNDIS_Interface); USB_USBTask(); } }
/** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); TCP_Init(); Webserver_Init(); LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { if (RNDIS_Device_IsPacketReceived(&Ethernet_RNDIS_Interface)) { LEDs_SetAllLEDs(LEDMASK_USB_BUSY); RNDIS_Device_ReadPacket(&Ethernet_RNDIS_Interface, &FrameIN.FrameData, &FrameIN.FrameLength); Ethernet_ProcessPacket(&FrameIN, &FrameOUT); if (FrameOUT.FrameLength) { RNDIS_Device_SendPacket(&Ethernet_RNDIS_Interface, &FrameOUT.FrameData, FrameOUT.FrameLength); FrameOUT.FrameLength = 0; } LEDs_SetAllLEDs(LEDMASK_USB_READY); } TCP_TCPTask(&Ethernet_RNDIS_Interface, &FrameOUT); RNDIS_Device_USBTask(&Ethernet_RNDIS_Interface); USB_USBTask(); } }
/** Ethernet frame processing task. This task checks to see if a frame has been received, and if so hands off the processing * of the frame to the Ethernet processing routines. */ void Ethernet_Task(void) { /* Task for Ethernet processing. Incoming ethernet frames are loaded into the FrameIN structure, and outgoing frames should be loaded into the FrameOUT structure. Both structures can only hold a single Ethernet frame at a time, so the FrameInBuffer bool is used to indicate when the buffers contain data. */ /* Device must be connected and configured for the task to run */ if (USB_DeviceState != DEVICE_STATE_Configured) return; /* Check if a frame has been written to the IN frame buffer */ if (FrameIN.FrameLength) { /* Indicate packet processing started */ LEDs_SetAllLEDs(LEDMASK_USB_BUSY); /* Process the ethernet frame - replace this with your own Ethernet handler code as desired */ Ethernet_ProcessPacket(); /* Indicate packet processing complete */ LEDs_SetAllLEDs(LEDMASK_USB_READY); } }