X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/071e02c6b6b4837fa9cf0b6d4c749994e02638d7..3a03da970558de9211fc1a43b12bf69e38854d09:/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c?ds=inline diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c index d11829dd6..8a8d2142a 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c @@ -98,30 +98,18 @@ void EVENT_USB_Device_Disconnect(void) */ void EVENT_USB_Device_ConfigurationChanged(void) { - /* Indicate USB connected and ready */ - LEDs_SetAllLEDs(LEDMASK_USB_READY); - - /* Setup CDC Notification, Rx and Tx Endpoints */ - if (!(Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_IN, CDC_TXRX_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } - - if (!(Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_OUT, CDC_TXRX_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } - - if (!(Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, - ENDPOINT_DIR_IN, CDC_NOTIFICATION_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } + bool ConfigSuccess = true; + + /* Setup RNDIS Data Endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_TX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN, + CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE); + ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_RX_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_OUT, + CDC_TXRX_EPSIZE, ENDPOINT_BANK_SINGLE); + ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE); + + /* Indicate endpoint configuration success or failure */ + LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); } /** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific @@ -136,13 +124,10 @@ void EVENT_USB_Device_UnhandledControlRequest(void) case REQ_SendEncapsulatedCommand: if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { - /* Clear the SETUP packet, ready for data transfer */ Endpoint_ClearSETUP(); /* Read in the RNDIS message into the message buffer */ Endpoint_Read_Control_Stream_LE(RNDISMessageBuffer, USB_ControlRequest.wLength); - - /* Finalize the stream transfer to clear the last packet from the host */ Endpoint_ClearIN(); /* Process the RNDIS message */ @@ -153,9 +138,6 @@ void EVENT_USB_Device_UnhandledControlRequest(void) case REQ_GetEncapsulatedResponse: if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) { - /* Clear the SETUP packet, ready for data transfer */ - Endpoint_ClearSETUP(); - /* Check if a response to the last message is ready */ if (!(MessageHeader->MessageLength)) { @@ -164,10 +146,10 @@ void EVENT_USB_Device_UnhandledControlRequest(void) MessageHeader->MessageLength = 1; } + Endpoint_ClearSETUP(); + /* Write the message response data to the endpoint */ Endpoint_Write_Control_Stream_LE(RNDISMessageBuffer, MessageHeader->MessageLength); - - /* Finalize the stream transfer to send the last packet or clear the host abort */ Endpoint_ClearOUT(); /* Reset the message header once again after transmission */