diff options
author | Keith Packard <keithp@keithp.com> | 2013-12-19 00:08:50 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-12-19 00:08:50 -0800 |
commit | a04c1dd5df76c9127615bc797a9d9f764eec1234 (patch) | |
tree | 29facfb7670030758744fb81e467c47688593f83 /src | |
parent | 1ab12861c3e70d7c22b27d988546a925616a0adc (diff) |
altos/lpc: Stop sending SETUP IN when the requested size is reached
The host won't keep asking for SETUP IN packets once it has received
the amount of data requested, so check to see if we've sent that much
and flip back to IDLE state if so.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lpc/ao_usb_lpc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lpc/ao_usb_lpc.c b/src/lpc/ao_usb_lpc.c index 713fbc53..686dc3a4 100644 --- a/src/lpc/ao_usb_lpc.c +++ b/src/lpc/ao_usb_lpc.c @@ -58,6 +58,7 @@ static uint8_t ao_usb_ep0_state; /* Pending EP0 IN data */ static const uint8_t *ao_usb_ep0_in_data; /* Remaining data */ static uint8_t ao_usb_ep0_in_len; /* Remaining amount */ +static uint16_t ao_usb_ep0_in_max; /* Requested amount from host */ /* Temp buffer for smaller EP0 in data */ static uint8_t ao_usb_ep0_in_buf[2]; @@ -380,10 +381,11 @@ ao_usb_ep0_flush(void) if (this_len > AO_USB_CONTROL_SIZE) this_len = AO_USB_CONTROL_SIZE; - if (this_len < AO_USB_CONTROL_SIZE) - ao_usb_ep0_state = AO_USB_EP0_IDLE; - ao_usb_ep0_in_len -= this_len; + ao_usb_ep0_in_max -= this_len; + + if (this_len < AO_USB_CONTROL_SIZE || ao_usb_ep0_in_max == 0) + ao_usb_ep0_state = AO_USB_EP0_IDLE; debug_data ("Flush EP0 len %d:", this_len); memcpy(ao_usb_ep0_tx_buffer, ao_usb_ep0_in_data, this_len); @@ -456,6 +458,7 @@ ao_usb_ep0_out_set(uint8_t *data, uint8_t len) static void ao_usb_ep0_in_start(uint16_t max) { + ao_usb_ep0_in_max = max; /* Don't send more than asked for */ if (ao_usb_ep0_in_len > max) ao_usb_ep0_in_len = max; |