AnsweredAssumed Answered

MxCube USB library, how to send ACK trough Endpoint0 OUT

Question asked by Bursic.Marko on Jan 26, 2017


I am struggling to make a vendor device, that sends request on control pipe endpoint 0 out (EP0_OUT), I can receive the request correctly, but I can't send an ACK back (zero length packet). I have tried USBD_CtlSendData(), USBD_CtlSendStatus(),...the response doesn't seem to be sent anyway, neither on EP0_IN. 
I have other requests coming on EP0_IN and everything works correct.
I have been looking the library and had noticed, that any transmit request is parsed to be sent on EP0_IN


HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len)
PCD_EPTypeDef *ep = NULL;

ep = &hpcd->IN_ep[ep_addr & 0x7F];

/*setup and start the Xfer */
ep->xfer_buff = pBuf;
ep->xfer_len = len;
ep->xfer_count = 0;
ep->is_in = 1;
ep->num = ep_addr & 0x7F;

HAL_PCD_EP_Transmit() calls USB_EPStartXfer, but before it sets ep->is_in=1, indicating to EP0_IN always.
USB_EPStartXfer then checks if it has to send to IN or OUT endpoint. 

HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx , USB_EPTypeDef *ep)
uint16_t pmabuffer = 0;
uint32_t len = ep->xfer_len;

/* IN endpoint */
if (ep->is_in == 1)
/*Multi packet transfer*/
if (ep->xfer_len > ep->maxpacket)

So, how could I send to EP0_OUT?