mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-22 06:40:58 +00:00
minor clean up
This commit is contained in:
parent
0d2078d295
commit
0cce42fcc6
@ -246,32 +246,37 @@ static void __tusb_irq_path_func(dcd_rp2040_irq)(void)
|
||||
{
|
||||
uint32_t const status = usb_hw->ints;
|
||||
uint32_t handled = 0;
|
||||
bool keep_sof_alive = false;
|
||||
|
||||
if (status & USB_INTF_DEV_SOF_BITS)
|
||||
{
|
||||
bool keep_sof_alive = false;
|
||||
|
||||
handled |= USB_INTF_DEV_SOF_BITS;
|
||||
|
||||
#if TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX
|
||||
last_sof = time_us_32();
|
||||
|
||||
for (uint8_t i = 0; i < USB_MAX_ENDPOINTS; i++) {
|
||||
for (uint8_t i = 0; i < USB_MAX_ENDPOINTS; i++)
|
||||
{
|
||||
struct hw_endpoint *ep = hw_endpoint_get_by_num(i, TUSB_DIR_IN);
|
||||
hw_endpoint_lock_update(ep, 1);
|
||||
|
||||
// Bulk IN endpoint in a transfer?
|
||||
if (rp2040_ep_needs_sof(ep) && ep->active)
|
||||
keep_sof_alive = true;
|
||||
if (rp2040_ep_needs_sof(ep) && ep->active) keep_sof_alive = true;
|
||||
|
||||
// Deferred enable?
|
||||
if (ep->pending) {
|
||||
if (ep->pending)
|
||||
{
|
||||
hw_endpoint_start_next_buffer(ep);
|
||||
ep->pending = 0;
|
||||
}
|
||||
|
||||
hw_endpoint_lock_update(ep, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
// disable SOF interrupt if it is used for RESUME in remote wakeup
|
||||
if (!keep_sof_alive && !_sof_enable)
|
||||
usb_hw_clear->inte = USB_INTS_DEV_SOF_BITS;
|
||||
if (!keep_sof_alive && !_sof_enable) usb_hw_clear->inte = USB_INTS_DEV_SOF_BITS;
|
||||
|
||||
dcd_event_sof(0, usb_hw->sof_rd & USB_SOF_RD_BITS, true);
|
||||
}
|
||||
|
@ -57,13 +57,14 @@ bool rp2040_critical_frame_period(struct hw_endpoint *ep)
|
||||
{
|
||||
uint32_t delta;
|
||||
|
||||
if (usb_hw->main_ctrl & USB_MAIN_CTRL_HOST_NDEVICE_BITS)
|
||||
return false;
|
||||
if (usb_hw->main_ctrl & USB_MAIN_CTRL_HOST_NDEVICE_BITS) return false;
|
||||
|
||||
if (tu_edpt_dir(ep->ep_addr) == TUSB_DIR_OUT ||
|
||||
ep->transfer_type == TUSB_XFER_INTERRUPT ||
|
||||
ep->transfer_type == TUSB_XFER_ISOCHRONOUS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Avoid the last 200us (uframe 6.5-7) of a frame, up to the EOF2 point.
|
||||
* The device state machine cannot recover from receiving an incorrect PID
|
||||
@ -78,10 +79,8 @@ bool rp2040_critical_frame_period(struct hw_endpoint *ep)
|
||||
}
|
||||
|
||||
bool rp2040_ep_needs_sof(struct hw_endpoint *ep) {
|
||||
if (tu_edpt_dir(ep->ep_addr) == TUSB_DIR_IN &&
|
||||
ep->transfer_type == TUSB_XFER_BULK)
|
||||
return true;
|
||||
return false;
|
||||
return (tu_edpt_dir(ep->ep_addr) == TUSB_DIR_IN &&
|
||||
ep->transfer_type == TUSB_XFER_BULK);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -115,12 +114,15 @@ void __tusb_irq_path_func(hw_endpoint_reset_transfer)(struct hw_endpoint *ep)
|
||||
ep->user_buf = 0;
|
||||
}
|
||||
|
||||
void __tusb_irq_path_func(_hw_endpoint_buffer_control_update32)(struct hw_endpoint *ep, uint32_t and_mask, uint32_t or_mask) {
|
||||
void __tusb_irq_path_func(_hw_endpoint_buffer_control_update32)(struct hw_endpoint *ep, uint32_t and_mask, uint32_t or_mask)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
|
||||
if ( and_mask )
|
||||
{
|
||||
value = *ep->buffer_control & and_mask;
|
||||
}
|
||||
|
||||
if ( or_mask )
|
||||
{
|
||||
value |= or_mask;
|
||||
@ -146,6 +148,7 @@ void __tusb_irq_path_func(_hw_endpoint_buffer_control_update32)(struct hw_endpoi
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
*ep->buffer_control = value;
|
||||
}
|
||||
|
||||
@ -247,13 +250,18 @@ void hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t to
|
||||
ep->user_buf = buffer;
|
||||
|
||||
if (rp2040_ep_needs_sof(ep))
|
||||
{
|
||||
usb_hw_set->inte = USB_INTS_DEV_SOF_BITS;
|
||||
}
|
||||
|
||||
if(!rp2040_critical_frame_period(ep)) {
|
||||
if(!rp2040_critical_frame_period(ep))
|
||||
{
|
||||
hw_endpoint_start_next_buffer(ep);
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
ep->pending = 1;
|
||||
}
|
||||
|
||||
hw_endpoint_lock_update(ep, -1);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ typedef struct hw_endpoint
|
||||
|
||||
// Transfer scheduled but not active
|
||||
uint8_t pending;
|
||||
|
||||
#if CFG_TUH_ENABLED
|
||||
// Only needed for host
|
||||
uint8_t dev_addr;
|
||||
@ -89,6 +90,7 @@ typedef struct hw_endpoint
|
||||
// If interrupt endpoint
|
||||
uint8_t interrupt_num;
|
||||
#endif
|
||||
|
||||
} hw_endpoint_t;
|
||||
|
||||
#if !TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX
|
||||
|
Loading…
x
Reference in New Issue
Block a user