usb: short control IN might need a ZLP

Control transfers can transfer less than was requested by the host in the
wLength field.  if this short transfer is a multiple of the endpoint's packet
size, a zero length packet must be sent.

Adds tests for a range of control transfer IN requests, and properly supports
this in the core.  Based heavily on work by Kuldeep Dhaka.

See https://github.com/libopencm3/libopencm3/pull/505
and https://github.com/libopencm3/libopencm3/pull/194 for original discussion.

Tested with stm32f4, stm32f103 and stm32l053.
This commit is contained in:
Karl Palsson
2015-10-11 01:17:24 +00:00
parent 5270c11a09
commit 3ed12b6fd9
4 changed files with 146 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ struct _usbd_device {
uint8_t *ctrl_buf;
uint16_t ctrl_len;
usbd_control_complete_callback complete;
bool needs_zlp;
} control_state;
struct user_control_callback {