LPC1347 send large data to Endpoint in a single transaction

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC1347 send large data to Endpoint in a single transaction

502 Views
szlittle
Contributor II

Hi all,

I am using a LPC1347 usbd_rom_composite example codes(lpcopen_2_05_keil_iar_nxp_lpcxpresso_1347). 

I am trying to send data with size of over 10240 bytes to endpoint 0x82(device to host). And these 10240 bytes of data must be in one transfer. Data rate is not important.

My device is Full Speed and the endpoint 2's wMaxPacketSize is 0x40(64).

My problem is, when I was calling the USBD_API->hw->WriteEP() and set the data length larger than 64, my device sent unpredictable data length(not the one I set).

I have also tried to devide data into 160 chunks(every chunk is 64bytes)  and call the VCOM_Write() 160 times, but it gives me seperate transactions with 64bytes each. What I need is a single transfer with 10240 bytes of data. Is there anyway to achieve it?

Thank you in advance!

Li Yong

0 Kudos
1 Reply

209 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Li yong,

Please notice that for US2.0 the max packet size for control transfer is 64B. If you want to implement a specifc control transfer, following is the operation you should follow:

First, the user call-back function should be defined as the same format as the function pointer in USB_CTRL_TYPE.

USB_PARAM_CB_T USB_ReqVendor, then this call-back function should be assigned to this pointer of the USB_Handle during initialization.

 

For the call-back function USB_ReqVendor:

typedef ErrorCode_t (*USB_PARAM_CB_T) (USBD_HANDLE_T hUsb, uint32_t param1);

The first parameter is the USB_Handler, the second one is the USB_EVENT defined as below.

enum USBD_EVENT_T {
USB_EVT_SETUP =1, /**< 1 Setup Packet received */
USB_EVT_OUT, /**< 2 OUT Packet received */
USB_EVT_IN, /**< 3 IN Packet sent */
USB_EVT_OUT_NAK, /**< 4 OUT Packet - Not Acknowledged */
USB_EVT_IN_NAK, /**< 5 IN Packet - Not Acknowledged */
USB_EVT_OUT_STALL, /**< 6 OUT Packet - Stalled */
USB_EVT_IN_STALL, /**< 7 IN Packet - Stalled */
USB_EVT_OUT_DMA_EOT, /**< 8 DMA OUT EP - End of Transfer */
USB_EVT_IN_DMA_EOT, /**< 9 DMA IN EP - End of Transfer */
USB_EVT_OUT_DMA_NDR, /**< 10 DMA OUT EP - New Descriptor Request */
USB_EVT_IN_DMA_NDR, /**< 11 DMA IN EP - New Descriptor Request */
USB_EVT_OUT_DMA_ERR, /**< 12 DMA OUT EP - Error */
USB_EVT_IN_DMA_ERR, /**< 13 DMA IN EP - Error */
USB_EVT_RESET, /**< 14 Reset event recieved */
USB_EVT_SOF, /**< 15 Start of Frame event */
USB_EVT_DEV_STATE, /**< 16 Device status events */
USB_EVT_DEV_ERROR /**< 17 Device error events */
};

 

During setup stage of the USB control transfer, setup package data will be stored in the SetupPacket of hUsb.

During the data stage, the data will be stored in the EP0Data of hUsb for OUT_EVENT transfer, and user also should copy data in the EP0Data of hUsb for IN_EVENT transfer.


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos