From 958d28d05dcf29530cc552ba75b53fc41bd89c7e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 27 Nov 2009 06:32:26 +0000 Subject: Better checking of whether a packet is received in the RNDISEthernetHost Class driver demo - show busy LED status while packets are being printed out. --- .../ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c | 15 +++++++++------ .../ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'Demos/Host/ClassDriver') diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c index 28d7b172d..02dd46a5d 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c @@ -159,18 +159,21 @@ int main(void) /** Prints incomming packets from the attached RNDIS device to the serial port. */ void PrintIncommingPackets(void) { - uint16_t PacketLength; - - RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); - - if (PacketLength) + if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)) { + LEDs_SetAllLEDs(LEDMASK_USB_BUSY); + + uint16_t PacketLength; + RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); + printf("***PACKET (Size %d)***\r\n", PacketLength); for (uint16_t i = 0; i < PacketLength; i++) printf("%02x ", PacketBuffer[i]); - printf("\r\n\r\n"); + printf("\r\n\r\n"); + + LEDs_SetAllLEDs(LEDMASK_USB_READY); } } diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h index 5f8498024..ea87648c0 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h @@ -63,6 +63,9 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ + #define LEDMASK_USB_BUSY (LEDS_LED2) + /* Function Prototypes: */ void SetupHardware(void); void PrintIncommingPackets(void); -- cgit v1.2.3