Endpoints (USB) in the LPC 214x

I have been through the USB sample code downloaded from the keil website and i have a few questions regarding how the endpoints are used

1) they have used a macro in the code to convert from logical endpoint number to endpoint address

#define IDX2EP(idx) ((((idx)<<7)&0x80)|(((idx)>>1)&0xF))

on working this out , i got a pattern of 0x00,0x80,0x01,0x81...0x0f,0x8f. How was this macro derived? There is nothing in the user manual about the actual addresses of endpoints.

2) Each of these addresses correspond to a memory location of 1 byte . Where do the incoming and outgoing packets go? there are variable packet sizes possible so i was under the assumption that the individual buffers for endpoints are of variable size . Where are these individual buffers located?

3) The code enables endpoints at 0x05 and 0x82 which correspond to logical endpoints 5 and 10. Why not 4 and 5 both of which correspond to logical endpoint 3 (4 is out and 5 is in) ? Does it make a difference which endpoint is enabled as long as it if of the required type (bulk/interrupt etc)?

4) I came across this macro

#define LE_WORD(x) ((x)&0xFF),((x)>>8)

I am not able to understand what it does. what does the comma mean? It was used at multiple locations. to get product and vendor ids, to get max packet size for an endpoint and also to get bcd USB value in device descriptor

thanks for your time.

Parents Reply
  • www.beyondlogic.org/.../usb5.shtml

    USB Descriptors

    Endpoint Descriptors

    Endpoint descriptors are used to describe endpoints other than endpoint zero. Endpoint zero is always assumed to be a control endpoint and is configured before any descriptors are even requested. The host will use the information returned from these descriptors to determine the bandwidth requirements of the bus.

    Field: bEndpointAddress
    Description:
    Endpoint Address
    Bits 0..3b Endpoint Number.
    Bits 4..6b Reserved. Set to Zero
    Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints)

Children
More questions in this forum