lpcware

USB Control transfer Stall PID error with LPC4357

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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;

Outcomes