X-Git-Url: http://git.linex4red.de/pub/lufa.git/blobdiff_plain/eee252603be67c539f9986cde76454f756e55d95..refs/heads/master:/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c index 7d01c0d04..ec6c08912 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c @@ -1,13 +1,13 @@ /* LUFA Library - Copyright (C) Dean Camera, 2012. + Copyright (C) Dean Camera, 2021. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2021 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 @@ -36,6 +36,12 @@ #include "RNDISEthernet.h" +/** 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 configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -43,17 +49,12 @@ int main(void) { SetupHardware(); - /* Webserver Initialization */ - TCP_Init(); - Webserver_Init(); - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); GlobalInterruptEnable(); for (;;) { Ethernet_Task(); - TCP_Task(); RNDIS_Task(); USB_USBTask(); } @@ -62,12 +63,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ LEDs_Init(); @@ -118,6 +131,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) */ void EVENT_USB_Device_ControlRequest(void) { + /* Send MS OS Compatibility descriptor if requested by the host. */ + CheckIfMSCompatibilityDescriptorRequest(); + /* Process RNDIS class commands */ switch (USB_ControlRequest.bRequest) { @@ -272,8 +288,7 @@ void Ethernet_Task(void) /* 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(); + // TODO: Process FrameIN here, and optionally fill FrameOUT. /* Indicate packet processing complete */ LEDs_SetAllLEDs(LEDMASK_USB_READY);