29#if CFG_TUH_ENABLED || CFG_TUD_ENABLED
49#if CFG_TUSB_OS != OPT_OS_NONE
63 #if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
64 if (rh_init == NULL) {
65 #if CFG_TUD_ENABLED && defined(TUD_OPT_RHPORT)
68 .
role = TUSB_ROLE_DEVICE,
75 #if CFG_TUH_ENABLED && defined(TUH_OPT_RHPORT)
78 .
role = TUSB_ROLE_HOST,
90 TU_ASSERT(rhport < TUP_USBIP_CONTROLLER_NUM && rh_init->role != TUSB_ROLE_INVALID);
94 if (rh_init->
role == TUSB_ROLE_DEVICE) {
100 if (rh_init->
role == TUSB_ROLE_HOST) {
123 TU_VERIFY(rhport < TUP_USBIP_CONTROLLER_NUM,);
144 while (
desc + 1 < end) {
151uint8_t
const*
tu_desc_find2(uint8_t
const*
desc, uint8_t
const* end, uint8_t byte1, uint8_t byte2) {
152 while (
desc + 2 < end) {
159uint8_t
const*
tu_desc_find3(uint8_t
const*
desc, uint8_t
const* end, uint8_t byte1, uint8_t byte2, uint8_t byte3) {
160 while (
desc + 3 < end) {
175 TU_VERIFY((ep_state->
busy == 0) && (ep_state->
claimed == 0));
179 bool const available = (ep_state->
busy == 0) && (ep_state->
claimed == 0);
193 bool const ret = (ep_state->
claimed == 1) && (ep_state->
busy == 0);
204 TU_LOG2(
" Open EP %02X with Size = %u\r\n", desc_ep->
bEndpointAddress, max_packet_size);
209 TU_ASSERT(max_packet_size <= spec_size);
216 TU_ASSERT(max_packet_size == 512);
219 TU_ASSERT(max_packet_size <= 64);
225 TU_ASSERT(max_packet_size <= spec_size);
238 uint8_t
const* p_desc = (uint8_t
const*) desc_itf;
239 uint8_t
const* desc_end = p_desc + desc_len;
241 while (p_desc < desc_end) {
244 TU_LOG(2,
" Bind EP %02x to driver id %u\r\n", ep_addr, driver_id);
252 uint8_t
const* p_desc = (uint8_t
const*) desc_itf;
255 while (itf_count--) {
260 while (len < max_len) {
283 void* ff_buf, uint16_t ff_bufsize, uint8_t* ep_buf, uint16_t ep_bufsize) {
286 s->is_host = is_host;
289 #if OSAL_MUTEX_REQUIRED
290 if (ff_buf && ff_bufsize) {
304 #if OSAL_MUTEX_REQUIRED
356 TU_VERIFY(!
tu_fifo_count(&s->
ff) && last_xferred_bytes && (0 == (last_xferred_bytes & (mps - 1))));
390 TU_ASSERT(
stream_xfer(hwid, s, (uint16_t) xact_len), 0);
440 TU_VERIFY(available >= mps);
447 if (available >= mps) {
449 uint16_t count = (uint16_t) (available & ~(mps - 1));
474#if CFG_TUSB_DEBUG >= CFG_TUH_LOG_LEVEL || CFG_TUSB_DEBUG >= CFG_TUD_LOG_LEVEL
493 "OK",
"FAILED",
"STALLED",
"TIMEOUT"
500 for (uint16_t i = 0; i < count; i++) {
502 tu_printf(
"%c", isprint(ch) ? ch :
'.');
513 uint8_t
const size = 1;
514 if (!buf || !count) {
515 tu_printf(
"NULL\r\n");
519 uint8_t
const* buf8 = (uint8_t
const*) buf;
521 format[2] += (uint8_t) (2 * size);
522 const uint8_t item_per_line = 16 / size;
524 for (
unsigned int i = 0; i < count; i++) {
525 unsigned int value = 0;
527 if (i % item_per_line == 0) {
530 for (uint8_t s = 0; s < indent; s++) tu_printf(
" ");
532 tu_printf(
"%04X: ", 16 * i / item_per_line);
543 const uint32_t remain = count % 16;
544 uint8_t nback = (uint8_t) (remain ? remain : 16);
546 for (uint32_t i = 0; i < 16 - remain; i++) {
548 for (
int j = 0; j < 2 * size; j++) tu_printf(
" ");
void dcd_int_handler(uint8_t rhport)
static usb_descriptor_buffers_t desc
void hcd_int_handler(uint8_t rhport, bool in_isr)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_delete(osal_mutex_t mutex_hdl)
SemaphoreHandle_t osal_mutex_t
static TU_ATTR_ALWAYS_INLINE osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef)
TU_ATTR_WEAK void osal_task_delay(uint32_t msec)
static void * memcpy(void *dst, const void *src, size_t n)
AUDIO Channel Cluster Descriptor (4.1)
uint8_t bmAttributes
See: audio_clock_source_attribute_t.
uint8_t const * tu_desc_find(uint8_t const *desc, uint8_t const *end, uint8_t byte1)
tusb_role_t _tusb_rhport_role[TUP_USBIP_CONTROLLER_NUM]
bool tu_edpt_validate(tusb_desc_endpoint_t const *desc_ep, tusb_speed_t speed)
uint8_t const * tu_desc_find2(uint8_t const *desc, uint8_t const *end, uint8_t byte1, uint8_t byte2)
uint8_t const * tu_desc_find3(uint8_t const *desc, uint8_t const *end, uint8_t byte1, uint8_t byte2, uint8_t byte3)
bool tu_edpt_stream_write_zlp_if_needed(uint8_t hwid, tu_edpt_stream_t *s, uint32_t last_xferred_bytes)
bool tu_edpt_claim(tu_edpt_state_t *ep_state, osal_mutex_t mutex)
void tu_edpt_bind_driver(uint8_t ep2drv[][2], tusb_desc_interface_t const *desc_itf, uint16_t desc_len, uint8_t driver_id)
static void dump_str_line(uint8_t const *buf, uint16_t count)
char const *const tu_str_speed[]
static TU_ATTR_ALWAYS_INLINE bool stream_xfer(uint8_t hwid, tu_edpt_stream_t *s, uint16_t count)
void tusb_int_handler(uint8_t rhport, bool in_isr)
uint32_t tu_edpt_stream_read_xfer(uint8_t hwid, tu_edpt_stream_t *s)
static TU_ATTR_ALWAYS_INLINE bool stream_claim(uint8_t hwid, tu_edpt_stream_t *s)
char const *const tu_str_std_request[]
uint32_t tu_edpt_stream_read(uint8_t hwid, tu_edpt_stream_t *s, void *buffer, uint32_t bufsize)
uint32_t tu_edpt_stream_write_available(uint8_t hwid, tu_edpt_stream_t *s)
uint32_t tu_edpt_stream_write_xfer(uint8_t hwid, tu_edpt_stream_t *s)
uint32_t tu_edpt_stream_write(uint8_t hwid, tu_edpt_stream_t *s, void const *buffer, uint32_t bufsize)
void tu_print_mem(void const *buf, uint32_t count, uint8_t indent)
char const *const tu_str_xfer_result[]
bool tu_edpt_release(tu_edpt_state_t *ep_state, osal_mutex_t mutex)
uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const *desc_itf, uint8_t itf_count, uint16_t max_len)
bool tu_edpt_stream_init(tu_edpt_stream_t *s, bool is_host, bool is_tx, bool overwritable, void *ff_buf, uint16_t ff_bufsize, uint8_t *ep_buf, uint16_t ep_bufsize)
static TU_ATTR_ALWAYS_INLINE bool stream_release(uint8_t hwid, tu_edpt_stream_t *s)
bool tu_edpt_stream_deinit(tu_edpt_stream_t *s)
bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t *rh_init)
TU_ATTR_WEAK void tusb_time_delay_ms_api(uint32_t ms)
uint32_t tusb_time_millis_api(void)
static TU_ATTR_ALWAYS_INLINE uint16_t tu_min16(uint16_t x, uint16_t y)
static TU_ATTR_ALWAYS_INLINE uint32_t tu_min32(uint32_t x, uint32_t y)
static TU_ATTR_ALWAYS_INLINE int tu_memcpy_s(void *dest, size_t destsz, const void *src, size_t count)
uint16_t tu_fifo_count(tu_fifo_t *f)
Get number of items in FIFO.
bool tu_fifo_config(tu_fifo_t *f, void *buffer, uint16_t depth, uint16_t item_size, bool overwritable)
uint16_t tu_fifo_write_n(tu_fifo_t *f, const void *data, uint16_t n)
This function will write n elements into the array index specified by the write pointer and increment...
uint16_t tu_fifo_read_n(tu_fifo_t *f, void *buffer, uint16_t n)
This function will read n elements from the array index specified by the read pointer and increment t...
uint16_t tu_fifo_remaining(tu_fifo_t *f)
Get remaining space in FIFO.
static TU_ATTR_ALWAYS_INLINE uint16_t tu_fifo_depth(tu_fifo_t *f)
static TU_ATTR_ALWAYS_INLINE void tu_fifo_config_mutex(tu_fifo_t *f, osal_mutex_t wr_mutex, osal_mutex_t rd_mutex)
tusb_speed_t
defined base on EHCI specs value for Endpoint Speed
static TU_ATTR_ALWAYS_INLINE uint8_t tu_edpt_number(uint8_t addr)
static TU_ATTR_ALWAYS_INLINE uint8_t tu_desc_len(void const *desc)
static TU_ATTR_ALWAYS_INLINE uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const *desc_ep)
TU_ATTR_PACKED_END TU_ATTR_BIT_FIELD_ORDER_END static TU_ATTR_ALWAYS_INLINE tusb_dir_t tu_edpt_dir(uint8_t addr)
static TU_ATTR_ALWAYS_INLINE uint8_t tu_desc_type(void const *desc)
static TU_ATTR_ALWAYS_INLINE uint8_t const * tu_desc_next(void const *desc)
@ TUSB_DESC_INTERFACE_ASSOCIATION
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)
bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr)
bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t *rh_init)
bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr)
bool usbh_edpt_release(uint8_t dev_addr, uint8_t ep_addr)
bool tuh_rhport_init(uint8_t rhport, const tusb_rhport_init_t *rh_init)
bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr)
bool usbh_edpt_busy(uint8_t dev_addr, uint8_t ep_addr)
static TU_ATTR_ALWAYS_INLINE bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t *buffer, uint16_t total_bytes)