Always check the host expected size before sending device, interface or
endpoint status and properly set zero-packet flag when the size of the
packet to transmit is less than the host expected size.
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4265
38d2e660-2303-0410-9eaa-
f027e97ec537
/* Get device status */
static int UsbDevStatus(uint16_t index)
{
/* Get device status */
static int UsbDevStatus(uint16_t index)
{
if (index)
return -USB_NODEV_ERROR;
InData = ((uint32_t)udc.feature) & 0xff;
if (index)
return -USB_NODEV_ERROR;
InData = ((uint32_t)udc.feature) & 0xff;
+ size = usb_size(sizeof(InData), usb_le16_to_cpu(setup_packet.wLength));
__usb_ep_write(CTRL_ENP_IN,
__usb_ep_write(CTRL_ENP_IN,
- (uint8_t *)&InData, sizeof(InData), USB_StatusHandler);
+ (uint8_t *)&InData, size, USB_StatusHandler);
/* Get interface status */
static int UsbInterfaceStatus(UNUSED_ARG(uint16_t, index))
{
/* Get interface status */
static int UsbInterfaceStatus(UNUSED_ARG(uint16_t, index))
{
+ size = usb_size(sizeof(InData), usb_le16_to_cpu(setup_packet.wLength));
__usb_ep_write(CTRL_ENP_IN,
__usb_ep_write(CTRL_ENP_IN,
- (uint8_t *)&InData, sizeof(InData), USB_StatusHandler);
+ (uint8_t *)&InData, size, USB_StatusHandler);
/* Get endpoint status */
static int UsbEpStatus(uint16_t index)
{
/* Get endpoint status */
static int UsbEpStatus(uint16_t index)
{
if ((index & 0x7F) > 16)
return -USB_NODEV_ERROR;
InData = 0;
USB_GetStallEP(USB_EpLogToPhysAdd(index), (bool *)&InData);
if ((index & 0x7F) > 16)
return -USB_NODEV_ERROR;
InData = 0;
USB_GetStallEP(USB_EpLogToPhysAdd(index), (bool *)&InData);
+ size = usb_size(sizeof(InData), usb_le16_to_cpu(setup_packet.wLength));
__usb_ep_write(CTRL_ENP_IN,
__usb_ep_write(CTRL_ENP_IN,
- (uint8_t *)&InData, sizeof(InData), USB_StatusHandler);
+ (uint8_t *)&InData, size, USB_StatusHandler);