Problem with IN and OUT endpoints

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with IN and OUT endpoints

660 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Hansi on Sat Aug 04 13:37:50 MST 2012
Hi!

I'm evaluating nxpUSBlib for a small project. This should not use any USB device class but implement a fully custom protocol.

My first problem was that in the .zip file there are no examples for this use case. I had to dive into the USB class .c files and distill how to transfer data through endpoints by hand. Could you please implement such an example? If desired, I gladly offer my current "training" example. :-)

The second problem is IMHO a real bug in the endpoint handling. In nxpUSBlib/Drivers/USB/Core/LPC/DCD/EndpointCommon.h and in nxpUSBlib/Drivers/USB/Core/LPC/Endpoint_LPC.c the variable <code>endpointhandle</code> is defined. This maps logical endpoint numbers (as array index) to physical endpoint numbers (the values are set by <code>Endpoint_ConfigureEndpoint()</code>).

This leads to the problem, that for every logical endpoint, only either the IN or the OUT endpoint can be used. So if you want to transmit data in both directions, you can not use e.g. EP2IN and EP2OUT, but you have to use EP2IN and EP3OUT.

The USB specification does not create this restriction, and neither does the LPC11Uxx USB hardware. Indeed, I used the setup using EP2IN and EP2OUT before with multiple projects involving an EZ-USB AN2131 chip.

Why didn't come up anybody with this problem before? Why didn't it show up with the USB class examples?

Bye
  Hansi
Labels (1)
0 Kudos
1 Reply

602 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by peplin on Thu Aug 30 10:06:20 MST 2012
I just encountered the problem with both IN and OUT direction on one endpoint number (which as you say is totally valid). I think it can be simply illustrated:

<code>
/** Selects the given endpoint number. If the address from the device descriptors is used, the
*  value should be masked with the \ref ENDPOINT_EPNUM_MASK constant to extract only the endpoint
*  number (and discarding the endpoint direction bit).                         
* ...            
*/                                                                             
static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)
</code>

So, if I have EP1 configured for both IN and OUT, I have to just pass this function EP1 - no direction indicated.

<code>
/** Determines the currently selected endpoint's direction.                     
*                                                            ...                  
*/                                                                             
static inline uint8_t Endpoint_GetEndpointDirection(void) 
</code>

Err, but if I only told you "EP1", how do you know the direction?
0 Kudos