remove sent_setup from hw endpoint

This commit is contained in:
hathach 2021-06-13 15:27:20 +07:00
parent 289ccf3c93
commit 1af64f9729
3 changed files with 20 additions and 20 deletions

View File

@ -161,19 +161,19 @@ static void hw_handle_buff_status(void)
static void hw_trans_complete(void) static void hw_trans_complete(void)
{ {
struct hw_endpoint *ep = &epx; struct hw_endpoint *ep = &epx;
assert(ep->active); assert(ep->active);
if (ep->sent_setup) if (usb_hw->sie_ctrl & USB_SIE_CTRL_SEND_SETUP_BITS)
{ {
pico_trace("Sent setup packet\n"); pico_trace("Sent setup packet\n");
hw_xfer_complete(ep, XFER_RESULT_SUCCESS); hw_xfer_complete(ep, XFER_RESULT_SUCCESS);
} }
else else
{ {
// Don't care. Will handle this in buff status // Don't care. Will handle this in buff status
return; return;
} }
} }
static void hcd_rp2040_irq(void) static void hcd_rp2040_irq(void)
@ -473,10 +473,13 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *
struct hw_endpoint *ep = get_dev_ep(dev_addr, ep_addr); struct hw_endpoint *ep = get_dev_ep(dev_addr, ep_addr);
assert(ep); assert(ep);
if (ep_addr != ep->ep_addr) // Control endpoint can change direction 0x00 <-> 0x80
if ( ep_addr != ep->ep_addr )
{ {
// Direction has flipped on endpoint control so re init it but with same properties assert(ep_num == 0);
_hw_endpoint_init(ep, dev_addr, ep_addr, ep->wMaxPacketSize, ep->transfer_type, 0);
// Direction has flipped on endpoint control so re init it but with same properties
_hw_endpoint_init(ep, dev_addr, ep_addr, ep->wMaxPacketSize, ep->transfer_type, 0);
} }
// If a normal transfer (non-interrupt) then initiate using // If a normal transfer (non-interrupt) then initiate using
@ -519,7 +522,6 @@ bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet
ep->remaining_len = 8; ep->remaining_len = 8;
ep->active = true; ep->active = true;
ep->sent_setup = true;
// Set device address // Set device address
usb_hw->dev_addr_ctrl = dev_addr; usb_hw->dev_addr_ctrl = dev_addr;

View File

@ -73,9 +73,6 @@ void hw_endpoint_reset_transfer(struct hw_endpoint *ep)
{ {
ep->stalled = false; ep->stalled = false;
ep->active = false; ep->active = false;
#if TUSB_OPT_HOST_ENABLED
ep->sent_setup = false;
#endif
ep->remaining_len = 0; ep->remaining_len = 0;
ep->xferred_len = 0; ep->xferred_len = 0;
ep->user_buf = 0; ep->user_buf = 0;

View File

@ -55,13 +55,14 @@ struct hw_endpoint
// Data needed from EP descriptor // Data needed from EP descriptor
uint16_t wMaxPacketSize; uint16_t wMaxPacketSize;
// Interrupt, bulk, etc // Interrupt, bulk, etc
uint8_t transfer_type; uint8_t transfer_type;
#if TUSB_OPT_HOST_ENABLED #if TUSB_OPT_HOST_ENABLED
// Only needed for host // Only needed for host
uint8_t dev_addr; uint8_t dev_addr;
bool sent_setup;
// If interrupt endpoint // If interrupt endpoint
uint8_t interrupt_num; uint8_t interrupt_num;
#endif #endif