From b06cd3b807696000769fb34457a1eb70b102dd34 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 4 Mar 2019 15:46:59 +0800 Subject: [PATCH] usb-epfifo: something is actually responding now Making good progress. Still not reliable, but there's something to work on now. Signed-off-by: Sean Cross --- src/usb-epfifo.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/usb-epfifo.c b/src/usb-epfifo.c index abd22c1..eb4c73b 100644 --- a/src/usb-epfifo.c +++ b/src/usb-epfifo.c @@ -120,9 +120,9 @@ void usb_connect(void) { usb_ep_0_out_respond_write(EPF_ACK); usb_ep_0_in_respond_write(EPF_NAK); - usb_ep_0_out_ev_pending_write(usb_ep_0_out_ev_enable_read()); - usb_ep_0_in_ev_pending_write(usb_ep_0_in_ev_pending_read()); - usb_ep_0_out_ev_enable_write(USB_EV_PACKET | USB_EV_ERROR); + usb_ep_0_out_ev_pending_write(usb_ep_0_out_ev_enable_read()); + usb_ep_0_in_ev_pending_write(usb_ep_0_in_ev_pending_read()); + usb_ep_0_out_ev_enable_write(USB_EV_PACKET | USB_EV_ERROR); usb_ep_0_in_ev_enable_write(USB_EV_PACKET | USB_EV_ERROR); irq_setmask(irq_getmask() | (1 << USB_INTERRUPT)); @@ -151,8 +151,6 @@ static int maybe_send_more_data(int epnum) { // Don't allow requeueing if (usb_ep_0_in_respond_read() != EPF_NAK) return -1; - // if (!usb_ep_0_in_ibuf_empty_read()) - // return -2; int this_offset; current_to_send = current_length - current_offset; @@ -163,6 +161,7 @@ static int maybe_send_more_data(int epnum) { usb_ep_0_in_ibuf_head_write(current_data[this_offset]); } usb_ep_0_in_respond_write(EPF_ACK); + usb_ep_0_out_respond_write(EPF_ACK); return 0; } @@ -228,6 +227,9 @@ void usb_isr(void) { current_offset += current_to_send; maybe_send_more_data(0); usb_ep_0_in_ev_pending_write(ep0i_pending); + + // Get ready to respond to the empty data byte + usb_ep_0_out_respond_write(EPF_ACK); } return;