Re-enable cppcheck static analysis unused function checks after adding in special...
[pub/USBasp.git] / Demos / Device / ClassDriver / RNDISEthernet / RNDISEthernet.c
index 5856046..2a8ba97 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -63,6 +63,12 @@ USB_ClassInfo_RNDIS_Device_t Ethernet_RNDIS_Interface =
                        },
        };
 
                        },
        };
 
+/** Global to store the incoming frame from the host before it is processed by the device. */
+static Ethernet_Frame_Info_t FrameIN;
+
+/** Global to store the outgoing frame created in the device before it is sent to the host. */
+static Ethernet_Frame_Info_t FrameOUT;
+
 /** Main program entry point. This routine contains the overall program flow, including initial
  *  setup of all components and the main program loop.
  */
 /** Main program entry point. This routine contains the overall program flow, including initial
  *  setup of all components and the main program loop.
  */
@@ -78,14 +84,23 @@ int main(void)
 
        for (;;)
        {
 
        for (;;)
        {
-               if (Ethernet_RNDIS_Interface.State.FrameIN.FrameInBuffer)
+               if (RNDIS_Device_IsPacketReceived(&Ethernet_RNDIS_Interface))
                {
                        LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
                {
                        LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
-                       Ethernet_ProcessPacket(&Ethernet_RNDIS_Interface.State.FrameIN, &Ethernet_RNDIS_Interface.State.FrameOUT);
+
+                       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);
                }
 
                        LEDs_SetAllLEDs(LEDMASK_USB_READY);
                }
 
-               TCP_TCPTask(&Ethernet_RNDIS_Interface);
+               TCP_TCPTask(&Ethernet_RNDIS_Interface, &FrameOUT);
 
                RNDIS_Device_USBTask(&Ethernet_RNDIS_Interface);
                USB_USBTask();
 
                RNDIS_Device_USBTask(&Ethernet_RNDIS_Interface);
                USB_USBTask();