stm32l4xx_hal_pcd incorrect setup request handling
Hi,
It tooke me several days to found that there is wrong handling of setup packet with data in HAL driver.
On windows I'm sending setup packet like this:
uint32_t data = 0xAABBCCDD;
libusb_control_transfer(mDeviceHandle, LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, 0xAA, 0, 0, &data, 4, 0);
Later in hal driver in PCD_EP_ISR_Handler function there is check for status bits:
wEPVal = PCD_GET_ENDPOINT(hpcd->Instance, PCD_ENDP0);
if ((wEPVal & USB_EP_SETUP) != 0U) {
...
} else
if ((wEPVal & USB_EP_CTR_RX) != 0U)
{
...
}
Which leads to:
- receiving setup packet without data
- receving data without setup fields
Additionally in stm32l4xx_ll_usb.c driver in USB_EPStartXfer function
There is handling for IN endpoint (call to USB_WritePMA) but there is no handling for OUT endpoint - no call to
USB_ReadPMA
