remove unused variable in hw endpoint

last_buf, buf_sel, transfer_size
This commit is contained in:
hathach 2021-06-11 18:26:41 +07:00
parent 93cb2ff4cf
commit 66c8a13f13
3 changed files with 20 additions and 32 deletions

View File

@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Double Buffered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -220,6 +221,14 @@ static void hcd_rp2040_irq(void)
usb_hw_clear->sie_status = USB_SIE_STATUS_SPEED_BITS;
}
if (status & USB_INTS_BUFF_STATUS_BITS)
{
handled |= USB_INTS_BUFF_STATUS_BITS;
TU_LOG(2, "Buffer complete\n");
// print_bufctrl32(*epx.buffer_control);
hw_handle_buff_status();
}
if (status & USB_INTS_TRANS_COMPLETE_BITS)
{
handled |= USB_INTS_TRANS_COMPLETE_BITS;
@ -228,14 +237,6 @@ static void hcd_rp2040_irq(void)
hw_trans_complete();
}
if (status & USB_INTS_BUFF_STATUS_BITS)
{
handled |= USB_INTS_BUFF_STATUS_BITS;
TU_LOG(2, "Buffer complete\n");
print_bufctrl32(*epx.buffer_control);
hw_handle_buff_status();
}
if (status & USB_INTS_STALL_BITS)
{
// We have rx'd a stall from the device
@ -543,7 +544,6 @@ bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet
assert(ep->configured);
ep->remaining_len = 8;
ep->transfer_size = 8;
ep->active = true;
ep->sent_setup = true;

View File

@ -2,6 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
* Copyright (c) 2021 Ha Thach (tinyusb.org) for Double Buffered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -43,8 +44,8 @@ static inline void _hw_endpoint_lock_update(struct hw_endpoint *ep, int delta) {
// sense to have worker and IRQ on same core, however I think using critsec is about equivalent.
}
void _hw_endpoint_xfer_sync(struct hw_endpoint *ep);
void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep);
static void _hw_endpoint_xfer_sync(struct hw_endpoint *ep);
static void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep);
//--------------------------------------------------------------------+
//
@ -77,7 +78,6 @@ void hw_endpoint_reset_transfer(struct hw_endpoint *ep)
#endif
ep->remaining_len = 0;
ep->xferred_len = 0;
ep->transfer_size = 0;
ep->user_buf = 0;
}
@ -111,7 +111,7 @@ void _hw_endpoint_buffer_control_update32(struct hw_endpoint *ep, uint32_t and_m
*ep->buffer_control = value;
}
static uint32_t compute_ep_buf(struct hw_endpoint *ep, uint8_t buf_id)
static uint32_t compute_buffer_control(struct hw_endpoint *ep, uint8_t buf_id)
{
uint16_t const buflen = tu_min16(ep->remaining_len, ep->wMaxPacketSize);
ep->remaining_len -= buflen;
@ -148,19 +148,19 @@ static uint32_t compute_ep_buf(struct hw_endpoint *ep, uint8_t buf_id)
}
// Prepare buffer control register value
void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
static void _hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
{
uint32_t ep_ctrl = *ep->endpoint_control;
// always compute buffer 0
uint32_t buf_ctrl = compute_ep_buf(ep, 0);
uint32_t buf_ctrl = compute_buffer_control(ep, 0);
if(ep->remaining_len)
{
// Use buffer 1 (double buffered) if there is still data
// TODO: Isochronous for buffer1 bit-field is different than CBI (control bulk, interrupt)
buf_ctrl |= compute_ep_buf(ep, 1);
buf_ctrl |= compute_buffer_control(ep, 1);
// Set endpoint control double buffered bit if needed
ep_ctrl &= ~EP_CTRL_INTERRUPT_PER_BUFFER;
@ -205,7 +205,7 @@ void hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t to
_hw_endpoint_lock_update(ep, -1);
}
static void sync_ep_buf(struct hw_endpoint *ep, uint8_t buf_id)
static void sync_ep_buffer(struct hw_endpoint *ep, uint8_t buf_id)
{
uint32_t buf_ctrl = _hw_endpoint_buffer_control_get_value32(ep);
if (buf_id) buf_ctrl = buf_ctrl >> 16;
@ -241,18 +241,18 @@ static void sync_ep_buf(struct hw_endpoint *ep, uint8_t buf_id)
}
}
void _hw_endpoint_xfer_sync (struct hw_endpoint *ep)
static void _hw_endpoint_xfer_sync (struct hw_endpoint *ep)
{
// Update hw endpoint struct with info from hardware
// after a buff status interrupt
// always sync buffer 0
sync_ep_buf(ep, 0);
sync_ep_buffer(ep, 0);
// sync buffer 1 if double buffered
if ( (*ep->endpoint_control) & EP_CTRL_DOUBLE_BUFFERED_BITS )
{
sync_ep_buf(ep, 1);
sync_ep_buffer(ep, 1);
}
}

View File

@ -65,12 +65,6 @@ struct hw_endpoint
uint16_t remaining_len;
uint16_t xferred_len;
// Amount of data with the hardware
uint16_t buflen[2];
uint16_t transfer_size; // buf0_len;
uint16_t buf_1_len;
// User buffer in main memory
uint8_t *user_buf;
@ -80,12 +74,6 @@ struct hw_endpoint
uint8_t transfer_type;
#if TUSB_OPT_HOST_ENABLED
// Only needed for host mode
bool last_buf;
// RP2040-E4: HOST BUG. Host will incorrect write status to top half of buffer
// control register when doing transfers > 1 packet
uint8_t buf_sel;
// Only needed for host
uint8_t dev_addr;
bool sent_setup;