summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-01-16 15:03:09 +0700
committerhathach <[email protected]>2026-01-16 15:03:09 +0700
commit292f334bd9b9d76524bbd6b76aea3cf9e6fd24c4 (patch)
treea68dc983fa7a7f32a874a3d0aaa64bdf6ef2357a
parent0c9a170dca9b0a0982b4b0462508ee4bda7a06da (diff)
rename
-rw-r--r--src/portable/raspberrypi/rp2040/dcd_rp2040.c14
-rw-r--r--src/portable/raspberrypi/rp2040/hcd_rp2040.c23
-rw-r--r--src/portable/raspberrypi/rp2040/rp2040_usb.c15
-rw-r--r--src/portable/raspberrypi/rp2040/rp2040_usb.h9
4 files changed, 30 insertions, 31 deletions
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
index 8c7dc83b8..7af6cdb43 100644
--- a/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
@@ -89,7 +89,7 @@ TU_ATTR_ALWAYS_INLINE static inline io_rw_32 *hwbuf_ctrl_reg_device(struct hw_en
static void hw_endpoint_init(hw_endpoint_t *ep, uint8_t ep_addr, uint16_t wMaxPacketSize, uint8_t transfer_type) {
ep->ep_addr = ep_addr;
ep->next_pid = 0u;
- ep->wMaxPacketSize = wMaxPacketSize;
+ ep->max_packet_size = wMaxPacketSize;
// Clear existing buffer control state
io_rw_32 *buf_ctrl_reg = hwbuf_ctrl_reg_device(ep);
@@ -99,7 +99,7 @@ static void hw_endpoint_init(hw_endpoint_t *ep, uint8_t ep_addr, uint16_t wMaxPa
const uint8_t epnum = tu_edpt_number(ep_addr);
if (epnum == 0) {
// Buffer offset is fixed (also double buffered)
- ep->hw_data_buf = (uint8_t*) &usb_dpram->ep0_buf_a[0];
+ ep->dpram_buf = (uint8_t *)&usb_dpram->ep0_buf_a[0];
} else {
// round up size to multiple of 64
uint16_t size = (uint16_t)tu_round_up(wMaxPacketSize, 64);
@@ -116,11 +116,11 @@ static void hw_endpoint_init(hw_endpoint_t *ep, uint8_t ep_addr, uint16_t wMaxPa
}
// assign buffer
- ep->hw_data_buf = hw_buffer_ptr;
+ ep->dpram_buf = hw_buffer_ptr;
hw_buffer_ptr += size;
hard_assert(hw_buffer_ptr < usb_dpram->epx_data + sizeof(usb_dpram->epx_data));
- pico_info(" Allocated %d bytes (0x%p)\r\n", size, ep->hw_data_buf);
+ pico_info(" Allocated %d bytes (0x%p)\r\n", size, ep->dpram_buf);
}
}
@@ -129,7 +129,7 @@ static void hw_endpoint_enable(hw_endpoint_t *ep, uint8_t transfer_type) {
// Set endpoint control register to enable (EP0 has no endpoint control register)
if (ctrl_reg != NULL) {
const uint32_t ctrl_value =
- EP_CTRL_ENABLE_BITS | ((uint32_t)transfer_type << EP_CTRL_BUFFER_TYPE_LSB) | hw_data_offset(ep->hw_data_buf);
+ EP_CTRL_ENABLE_BITS | ((uint32_t)transfer_type << EP_CTRL_BUFFER_TYPE_LSB) | hw_data_offset(ep->dpram_buf);
*ctrl_reg = ctrl_value;
}
}
@@ -501,12 +501,12 @@ bool dcd_edpt_iso_activate(uint8_t rhport, const tusb_desc_endpoint_t *ep_desc)
const uint8_t epnum = tu_edpt_number(ep_desc->bEndpointAddress);
const tusb_dir_t dir = tu_edpt_dir(ep_desc->bEndpointAddress);
struct hw_endpoint *ep = hw_endpoint_get(epnum, dir);
- TU_ASSERT(ep->hw_data_buf != NULL); // must be inited and allocated previously
+ TU_ASSERT(ep->dpram_buf != NULL); // must be inited and allocated previously
if (ep->active) {
hw_endpoint_abort_xfer(ep); // abort any pending transfer
}
- ep->wMaxPacketSize = ep_desc->wMaxPacketSize;
+ ep->max_packet_size = ep_desc->wMaxPacketSize;
hw_endpoint_enable(ep, TUSB_XFER_ISOCHRONOUS);
return true;
diff --git a/src/portable/raspberrypi/rp2040/hcd_rp2040.c b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
index 8a891c49a..6377a5d75 100644
--- a/src/portable/raspberrypi/rp2040/hcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/hcd_rp2040.c
@@ -71,7 +71,7 @@ enum {
static hcd_endpoint_t *edpt_alloc(void) {
for (uint i = 0; i < TU_ARRAY_SIZE(ep_pool); i++) {
hcd_endpoint_t *ep = &ep_pool[i];
- if (ep->hwep.wMaxPacketSize == 0) {
+ if (ep->hwep.max_packet_size == 0) {
return ep;
}
}
@@ -81,7 +81,7 @@ static hcd_endpoint_t *edpt_alloc(void) {
static hcd_endpoint_t *edpt_find(uint8_t daddr, uint8_t ep_addr) {
for (uint32_t i = 0; i < TU_ARRAY_SIZE(ep_pool); i++) {
hcd_endpoint_t *ep = &ep_pool[i];
- if ((ep->dev_addr == daddr) && (ep->hwep.wMaxPacketSize > 0) &&
+ if ((ep->dev_addr == daddr) && (ep->hwep.max_packet_size > 0) &&
(ep->hwep.ep_addr == ep_addr || (tu_edpt_number(ep_addr) == 0 && tu_edpt_number(ep->hwep.ep_addr) == 0))) {
return ep;
}
@@ -184,6 +184,7 @@ static void __tusb_irq_path_func(handle_hwbuf_status)(void) {
}
}
+//
// static void edpt_scheduler(void) {
// }
@@ -252,7 +253,7 @@ static void hw_endpoint_init(hcd_endpoint_t *ep, uint8_t dev_addr, const tusb_de
const uint8_t transfer_type = ep_desc->bmAttributes.xfer;
// const uint8_t bmInterval = ep_desc->bInterval;
- ep->hwep.wMaxPacketSize = wMaxPacketSize;
+ ep->hwep.max_packet_size = wMaxPacketSize;
ep->hwep.ep_addr = ep_addr;
ep->dev_addr = dev_addr;
ep->transfer_type = transfer_type;
@@ -260,7 +261,7 @@ static void hw_endpoint_init(hcd_endpoint_t *ep, uint8_t dev_addr, const tusb_de
ep->hwep.next_pid = 0u;
if (transfer_type != TUSB_XFER_INTERRUPT) {
- ep->hwep.hw_data_buf = usbh_dpram->epx_data;
+ ep->hwep.dpram_buf = usbh_dpram->epx_data;
} else {
// from 15 interrupt endpoints pool
uint8_t int_idx;
@@ -275,9 +276,9 @@ static void hw_endpoint_init(hcd_endpoint_t *ep, uint8_t dev_addr, const tusb_de
//------------- dpram buf -------------//
// 15x64 last bytes of DPRAM for interrupt endpoint buffers
- ep->hwep.hw_data_buf = (uint8_t *)(USBCTRL_DPRAM_BASE + USB_DPRAM_MAX - (int_idx + 1u) * 64u);
+ ep->hwep.dpram_buf = (uint8_t *)(USBCTRL_DPRAM_BASE + USB_DPRAM_MAX - (int_idx + 1u) * 64u);
uint32_t ep_ctrl = EP_CTRL_ENABLE_BITS | EP_CTRL_INTERRUPT_PER_BUFFER |
- (TUSB_XFER_INTERRUPT << EP_CTRL_BUFFER_TYPE_LSB) | hw_data_offset(ep->hwep.hw_data_buf) |
+ (TUSB_XFER_INTERRUPT << EP_CTRL_BUFFER_TYPE_LSB) | hw_data_offset(ep->hwep.dpram_buf) |
(uint32_t)((ep_desc->bInterval - 1) << EP_CTRL_HOST_INTERRUPT_INTERVAL_LSB);
usbh_dpram->int_ep_ctrl[int_idx].ctrl = ep_ctrl;
@@ -374,16 +375,16 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr) {
(void)dev_addr;
// reset epx if it is currently active with unplugged device
- if (epx->hwep.wMaxPacketSize > 0 && epx->dev_addr == dev_addr) {
+ if (epx->hwep.max_packet_size > 0 && epx->dev_addr == dev_addr) {
// if (epx->hwep.active) {
// // need to abort transfer
// }
- epx->hwep.wMaxPacketSize = 0;
+ epx->hwep.max_packet_size = 0;
}
for (size_t i = 0; i < TU_ARRAY_SIZE(ep_pool); i++) {
hcd_endpoint_t *ep = &ep_pool[i];
- if (ep->dev_addr == dev_addr && ep->hwep.wMaxPacketSize > 0) {
+ if (ep->dev_addr == dev_addr && ep->hwep.max_packet_size > 0) {
if (ep->interrupt_num) {
// disable interrupt endpoint
usb_hw_clear->int_ep_ctrl = 1u << ep->interrupt_num;
@@ -393,7 +394,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr) {
usbh_dpram->int_ep_ctrl[ep->interrupt_num - 1].ctrl = 0;
}
- ep->hwep.wMaxPacketSize = 0; // mark as unused
+ ep->hwep.max_packet_size = 0; // mark as unused
}
}
}
@@ -458,7 +459,7 @@ static void edpt_xfer(hcd_endpoint_t *ep, uint8_t *buffer, tu_fifo_t *ff, uint16
const tusb_dir_t ep_dir = tu_edpt_dir(ep->hwep.ep_addr);
// ep control
- const uint32_t dpram_offset = hw_data_offset(ep->hwep.hw_data_buf);
+ const uint32_t dpram_offset = hw_data_offset(ep->hwep.dpram_buf);
const uint32_t ep_ctrl = EP_CTRL_ENABLE_BITS | EP_CTRL_INTERRUPT_PER_BUFFER |
((uint32_t)ep->transfer_type << EP_CTRL_BUFFER_TYPE_LSB) | dpram_offset;
usbh_dpram->epx_ctrl = ep_ctrl;
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.c b/src/portable/raspberrypi/rp2040/rp2040_usb.c
index 74c6bf655..477e50a6a 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.c
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.c
@@ -125,8 +125,8 @@ void __tusb_irq_path_func(hwbuf_ctrl_update)(io_rw_32 *buf_ctrl_reg, uint32_t an
}
// prepare buffer, move data if tx, return buffer control
-uint32_t __tusb_irq_path_func(hwbuf_prepare)(struct hw_endpoint *ep, uint8_t buf_id, bool is_rx) {
- const uint16_t buflen = tu_min16(ep->remaining_len, ep->wMaxPacketSize);
+static uint32_t __tusb_irq_path_func(hwbuf_prepare)(struct hw_endpoint *ep, uint8_t buf_id, bool is_rx) {
+ const uint16_t buflen = tu_min16(ep->remaining_len, ep->max_packet_size);
ep->remaining_len = (uint16_t) (ep->remaining_len - buflen);
uint32_t buf_ctrl = buflen | USB_BUF_CTRL_AVAIL;
@@ -138,7 +138,7 @@ uint32_t __tusb_irq_path_func(hwbuf_prepare)(struct hw_endpoint *ep, uint8_t buf
if (!is_rx) {
if (buflen) {
// Copy data from user buffer/fifo to hw buffer
- uint8_t *hw_buf = ep->hw_data_buf + buf_id * 64;
+ uint8_t *hw_buf = ep->dpram_buf + buf_id * 64;
if (ep->is_xfer_fifo) {
// not in sram, may mess up timing with E15 workaround
tu_hwfifo_write_from_fifo(hw_buf, ep->user_fifo, buflen, NULL);
@@ -257,7 +257,8 @@ void hw_endpoint_xfer_start(struct hw_endpoint *ep, io_rw_32 *ep_reg, io_rw_32 *
}
// sync endpoint buffer and return transferred bytes
-uint16_t __tusb_irq_path_func(hwbuf_sync)(hw_endpoint_t *ep, io_rw_32 *buf_ctrl_reg, uint8_t buf_id, bool is_rx) {
+static uint16_t __tusb_irq_path_func(hwbuf_sync)(hw_endpoint_t *ep, io_rw_32 *buf_ctrl_reg, uint8_t buf_id,
+ bool is_rx) {
uint32_t buf_ctrl = *buf_ctrl_reg;
if (buf_id) {
buf_ctrl = buf_ctrl >> 16;
@@ -274,7 +275,7 @@ uint16_t __tusb_irq_path_func(hwbuf_sync)(hw_endpoint_t *ep, io_rw_32 *buf_ctrl_
// we have received AFTER we have copied it to the user buffer at the appropriate offset
assert(buf_ctrl & USB_BUF_CTRL_FULL);
- uint8_t *hw_buf = ep->hw_data_buf + buf_id * 64;
+ uint8_t *hw_buf = ep->dpram_buf + buf_id * 64;
if (ep->is_xfer_fifo) {
// not in sram, may mess up timing with E15 workaround
tu_hwfifo_read_to_fifo(hw_buf, ep->user_fifo, xferred_bytes, NULL);
@@ -286,7 +287,7 @@ uint16_t __tusb_irq_path_func(hwbuf_sync)(hw_endpoint_t *ep, io_rw_32 *buf_ctrl_
ep->xferred_len += xferred_bytes;
// Short packet
- if (xferred_bytes < ep->wMaxPacketSize) {
+ if (xferred_bytes < ep->max_packet_size) {
// Reduce total length as this is last packet
ep->remaining_len = 0;
}
@@ -312,7 +313,7 @@ static void __tusb_irq_path_func(sync_xfer)(hw_endpoint_t *ep, io_rw_32 *ep_reg,
// sync buffer 1 if double buffered
if (ep_reg != NULL && (*ep_reg) & EP_CTRL_DOUBLE_BUFFERED_BITS) {
- if (buf0_bytes == ep->wMaxPacketSize) {
+ if (buf0_bytes == ep->max_packet_size) {
// sync buffer 1 if not short packet
hwbuf_sync(ep, buf_reg, 1, is_rx);
} else {
diff --git a/src/portable/raspberrypi/rp2040/rp2040_usb.h b/src/portable/raspberrypi/rp2040/rp2040_usb.h
index ac1d8610a..cbb2290c1 100644
--- a/src/portable/raspberrypi/rp2040/rp2040_usb.h
+++ b/src/portable/raspberrypi/rp2040/rp2040_usb.h
@@ -72,8 +72,8 @@ typedef struct hw_endpoint {
uint8_t pending; // Transfer scheduled but not active
#endif
- uint16_t wMaxPacketSize; // max packet size also indicates configured
- uint8_t *hw_data_buf; // Buffer pointer in usb dpram
+ uint16_t max_packet_size; // max packet size also indicates configured
+ uint8_t *dpram_buf; // Buffer pointer in usb dpram
// transfer info
union {
@@ -111,8 +111,8 @@ TU_ATTR_ALWAYS_INLINE static inline bool rp2usb_is_host_mode(void) {
void hw_endpoint_xfer_start(struct hw_endpoint *ep, io_rw_32 *ep_reg, io_rw_32 *buf_reg, uint8_t *buffer, tu_fifo_t *ff,
uint16_t total_len);
bool hw_endpoint_xfer_continue(struct hw_endpoint *ep, io_rw_32 *ep_reg, io_rw_32 *buf_reg);
-void hw_endpoint_reset_transfer(struct hw_endpoint *ep);
void hw_endpoint_start_next_buffer(struct hw_endpoint *ep, io_rw_32 *ep_reg, io_rw_32 *buf_reg);
+void hw_endpoint_reset_transfer(struct hw_endpoint *ep);
TU_ATTR_ALWAYS_INLINE static inline void hw_endpoint_lock_update(__unused struct hw_endpoint * ep, __unused int delta) {
// todo add critsec as necessary to prevent issues between worker and IRQ...
@@ -123,9 +123,6 @@ TU_ATTR_ALWAYS_INLINE static inline void hw_endpoint_lock_update(__unused struct
//--------------------------------------------------------------------+
// Hardware Buffer
//--------------------------------------------------------------------+
-uint32_t hwbuf_prepare(struct hw_endpoint *ep, uint8_t buf_id, bool is_rx);
-uint16_t hwbuf_sync(hw_endpoint_t *ep, io_rw_32 *buf_ctrl_reg, uint8_t buf_id, bool is_rx);
-
void hwbuf_ctrl_update(io_rw_32 *buf_ctrl_reg, uint32_t and_mask, uint32_t or_mask);
TU_ATTR_ALWAYS_INLINE static inline void hwbuf_ctrl_set(io_rw_32 *buf_ctrl_reg, uint32_t value) {