30#if CFG_TUSB_MCU == OPT_MCU_RP2040
40#if TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX
44 #define e15_is_bulkin_ep(x) (false)
45 #define e15_is_critical_frame_period(x) (false)
50 return (usb_hw->main_ctrl & USB_MAIN_CTRL_HOST_NDEVICE_BITS) ? true :
false;
58 uint8_t *dst_byte = (uint8_t*)dst;
59 const uint8_t *src_byte = (
const uint8_t*)src;
61 *dst_byte++ = *src_byte++;
67 reset_block(RESETS_RESET_USBCTRL_BITS);
68 unreset_block_wait(RESETS_RESET_USBCTRL_BITS);
72#pragma GCC diagnostic push
73#pragma GCC diagnostic ignored "-Warray-bounds"
75#pragma GCC diagnostic ignored "-Wstringop-overflow"
78 memset(usb_dpram, 0,
sizeof(*usb_dpram));
80#pragma GCC diagnostic pop
84 usb_hw->muxing = USB_USB_MUXING_TO_PHY_BITS | USB_USB_MUXING_SOFTCON_BITS;
91 ep->remaining_len = 0;
106 if (or_mask & USB_BUF_CTRL_AVAIL) {
108 panic(
"ep %02X was already available", ep->
ep_addr);
114 busy_wait_at_least_cycles(12);
127 uint32_t buf_ctrl = buflen | USB_BUF_CTRL_AVAIL;
130 buf_ctrl |= ep->
next_pid ? USB_BUF_CTRL_DATA1_PID : USB_BUF_CTRL_DATA0_PID;
139 buf_ctrl |= USB_BUF_CTRL_FULL;
146 buf_ctrl |= USB_BUF_CTRL_LAST;
149 if (buf_id) buf_ctrl = buf_ctrl << 16;
177 ep_ctrl &= ~EP_CTRL_INTERRUPT_PER_BUFFER;
178 ep_ctrl |= EP_CTRL_DOUBLE_BUFFERED_BITS | EP_CTRL_INTERRUPT_PER_DOUBLE_BUFFER;
181 ep_ctrl &= ~(EP_CTRL_DOUBLE_BUFFERED_BITS | EP_CTRL_INTERRUPT_PER_DOUBLE_BUFFER);
182 ep_ctrl |= EP_CTRL_INTERRUPT_PER_BUFFER;
199 TU_LOG(1,
"WARN: starting new transfer on already active ep %02X\r\n", ep->
ep_addr);
210 usb_hw_set->inte = USB_INTS_DEV_SOF_BITS;
225 if (buf_id) buf_ctrl = buf_ctrl >> 16;
227 uint16_t xferred_bytes = buf_ctrl & USB_BUF_CTRL_LEN_MASK;
232 assert(!(buf_ctrl & USB_BUF_CTRL_FULL));
238 assert(buf_ctrl & USB_BUF_CTRL_FULL);
247 pico_trace(
" Short packet on buffer %d with %u bytes\r\n", buf_id, xferred_bytes);
252 return xferred_bytes;
279 uint8_t
const ep_id = 2*ep_num + (dir ? 0 : 1);
282 usb_hw->abort |= TU_BIT(ep_id);
284 while ( !(usb_hw->abort_done & TU_BIT(ep_id)) ) {}
287 ep_ctrl &= ~(EP_CTRL_DOUBLE_BUFFERED_BITS | EP_CTRL_INTERRUPT_PER_DOUBLE_BUFFER);
288 ep_ctrl |= EP_CTRL_INTERRUPT_PER_BUFFER;
292 usb_hw->abort &= ~TU_BIT(ep_id);
294 TU_LOG(3,
"----SHORT PACKET buffer0 on EP %02X:\r\n", ep->
ep_addr);
307 panic(
"Can't continue xfer on inactive ep %02X", ep->
ep_addr);
316 pico_trace(
"Completed transfer of %d bytes on ep %02X\r\n", ep->
xferred_len, ep->
ep_addr);
337#if TUD_OPT_RP2040_USB_DEVICE_UFRAME_FIX
373 if (delta < 800 || delta > 998) {
376 TU_LOG(3,
"Avoiding sof %lu now %lu last %lu\r\n", (usb_hw->sof_rd + 1) & USB_SOF_RD_BITS, time_us_32(),
static uint32_t __tusb_irq_path_func() prepare_ep_buffer(struct hw_endpoint *ep, uint8_t buf_id)
static TU_ATTR_ALWAYS_INLINE bool is_host_mode(void)
static bool e15_is_bulkin_ep(struct hw_endpoint *ep)
void __tusb_irq_path_func() hw_endpoint_reset_transfer(struct hw_endpoint *ep)
void __tusb_irq_path_func() _hw_endpoint_buffer_control_update32(struct hw_endpoint *ep, uint32_t and_mask, uint32_t or_mask)
static uint16_t __tusb_irq_path_func() sync_ep_buffer(struct hw_endpoint *ep, uint8_t buf_id)
static void _hw_endpoint_xfer_sync(struct hw_endpoint *ep)
void __tusb_irq_path_func() hw_endpoint_start_next_buffer(struct hw_endpoint *ep)
static void unaligned_memcpy(void *dst, const void *src, size_t n)
volatile uint32_t e15_last_sof
void rp2040_usb_init(void)
bool __tusb_irq_path_func() hw_endpoint_xfer_continue(struct hw_endpoint *ep)
void hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, uint16_t total_len)
static bool e15_is_critical_frame_period(struct hw_endpoint *ep)
static TU_ATTR_ALWAYS_INLINE uint32_t _hw_endpoint_buffer_control_get_value32(struct hw_endpoint *ep)
static TU_ATTR_ALWAYS_INLINE void _hw_endpoint_buffer_control_set_value32(struct hw_endpoint *ep, uint32_t value)
static TU_ATTR_ALWAYS_INLINE void hw_endpoint_lock_update(__unused struct hw_endpoint *ep, __unused int delta)
AUDIO Channel Cluster Descriptor (4.1)
io_rw_32 * endpoint_control
io_rw_32 * buffer_control
static TU_ATTR_ALWAYS_INLINE uint16_t tu_min16(uint16_t x, uint16_t y)
static TU_ATTR_ALWAYS_INLINE uint16_t tu_u32_low16(uint32_t ui32)
static TU_ATTR_ALWAYS_INLINE uint16_t tu_u32_high16(uint32_t ui32)
static TU_ATTR_ALWAYS_INLINE uint8_t tu_edpt_number(uint8_t addr)
TU_ATTR_PACKED_END TU_ATTR_BIT_FIELD_ORDER_END static TU_ATTR_ALWAYS_INLINE tusb_dir_t tu_edpt_dir(uint8_t addr)