USB Control transfer Stall PID error with LPC4357

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

USB Control transfer Stall PID error with LPC4357

1,800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by srinivasR on Thu Nov 26 08:07:54 MST 2015
Hi,

I am trying to implement vendor specific control commands for my product.  I have a specific command to set/get from Device.
Mywindows host PC application is sending a control transfer ( libusbK ) and I could see the data in USBlzer, but transaction is NOT successful. Error is -" Unsuccessful ( Stall PID)"

// code snippet at windows
setupPacket.BmRequest.Dir       = BMREQUEST_DIR_HOST_TO_DEVICE;
setupPacket.BmRequest.Type      = BMREQUEST_TYPE_VENDOR;
setupPacket.BmRequest.Recipient =  BMREQUEST_RECIPIENT_DEVICE;
setupPacket.Request             = BM_COMMAND_START_CAN;
setupPacket.Length= 8;
success = Usb.ControlTransfer(usbHandle, *((WINUSB_SETUP_PACKET*)&setupPacket), vendorBuffer, sizeof(vendorBuffer)-1, NULL, NULL);

At device side, VCOM USB API is used . and in the cdc_ep0_handler , it is not clear as how to handle the control request.
Breakpoint is hitting the if block of BM_COMMAND_START_CAN in the below method, but guess device is not responding proper ACK. Please advice..

/* CDC EP0_patch part of WORKAROUND for artf42016. */
static ErrorCode_t CDC_ep0_override_hdlr(USBD_HANDLE_T hUsb, void *data, uint32_t event)
{

if ( (event == USB_EVT_OUT) &&
(pCtrl->SetupPacket.bmRequestType.BM.Type == REQUEST_CLASS) &&
(pCtrl->SetupPacket.bmRequestType.BM.Recipient == REQUEST_TO_INTERFACE) ) {

if ((pCdcCtrl->epin_num & 0x80) == 0) {
cif_num = pCdc0Ctrl->cif_num;
dif_num = pCdc0Ctrl->dif_num;
setReq = pCdc0Ctrl->CIC_SetRequest;
}
else {
cif_num = pCdcCtrl->cif_num;
dif_num = pCdcCtrl->dif_num;
setReq = pCdcCtrl->CIC_SetRequest;
}
/* is the request target is our interfaces */
if (((pCtrl->SetupPacket.wIndex.WB.L == cif_num)  ||
(pCtrl->SetupPacket.wIndex.WB.L == dif_num)) ) {

pCtrl->EP0Data.pData -= pCtrl->SetupPacket.wLength;
ret = setReq(pCdcCtrl, &pCtrl->SetupPacket, &pCtrl->EP0Data.pData,
pCtrl->SetupPacket.wLength);
if ( ret == LPC_OK) {
/* send Acknowledge */
USBD_API->core->StatusInStage(pCtrl);
}
}

}
else if(event == USB_EVT_SETUP && pCtrl->SetupPacket.bRequest ==BM_COMMAND_START_CAN )
{
bDataSend=!bDataSend;
ret = LPC_OK;
//USBD_API->core->StatusInStage(pCtrl);

}
else {
ret = g_defaultCdcHdlr(hUsb, data, event);
}
return ret;
0 Kudos
Reply
1 Reply

1,292 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by srinivasR on Fri Nov 27 05:11:49 MST 2015
Hi,

Now I am able to read Control transfers from DEVICE TO HOST., but not yet successful with HOST - TO - DEVICE.

.....
else if(event == USB_EVT_SETUP && pCtrl->SetupPacket.bRequest ==BM_COMMAND_STATUS_CONTROLLER )
{
pCtrl->EP0Data.Count=8; // send response to HOST of 8 bytes
memset(buff,'3',8);
pCtrl->EP0Data.pData=(uint8_t *) buff;
USBD_API->core->DataInStage(pCtrl); // initiate the data transfer stage
ret = LPC_OK;
}
else if(event == USB_EVT_SETUP && pCtrl->SetupPacket.bRequest ==BM_COMMAND_START_CAN )
{
USBD_API->core->DataOutStage(pCtrl); //??????????
USBD_API->core->StatusInStage(pCtrl);
}

I am struggling with documentation of USBD API. Not understood as how to implement the Control commands from Host to device . DataOutStage is not giving any data sent from HOST as I expected from the documentation.
I am not clear as how to read the data from host to device?
0 Kudos
Reply