add tuh_task_event_ready(), better implement blocking control transfer for rtos
This commit is contained in:
@@ -360,6 +360,14 @@ bool tuh_init(uint8_t controller_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tuh_task_event_ready(void)
|
||||||
|
{
|
||||||
|
// Skip if stack is not initialized
|
||||||
|
if ( !tuh_inited() ) return false;
|
||||||
|
|
||||||
|
return !osal_queue_empty(_usbh_q);
|
||||||
|
}
|
||||||
|
|
||||||
/* USB Host Driver task
|
/* USB Host Driver task
|
||||||
* This top level thread manages all host controller event and delegates events to class-specific drivers.
|
* This top level thread manages all host controller event and delegates events to class-specific drivers.
|
||||||
* This should be called periodically within the mainloop or rtos thread.
|
* This should be called periodically within the mainloop or rtos thread.
|
||||||
@@ -383,7 +391,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr)
|
|||||||
(void) in_isr; // not implemented yet
|
(void) in_isr; // not implemented yet
|
||||||
|
|
||||||
// Skip if stack is not initialized
|
// Skip if stack is not initialized
|
||||||
if ( !tusb_inited() ) return;
|
if ( !tuh_inited() ) return;
|
||||||
|
|
||||||
// Loop until there is no more events in the queue
|
// Loop until there is no more events in the queue
|
||||||
while (1)
|
while (1)
|
||||||
@@ -565,12 +573,12 @@ bool tuh_control_xfer (tuh_xfer_t* xfer)
|
|||||||
|
|
||||||
while (result == XFER_RESULT_INVALID)
|
while (result == XFER_RESULT_INVALID)
|
||||||
{
|
{
|
||||||
// only need to call task if not preempted RTOS
|
// Note: this can be called within an callback ie. part of tuh_task()
|
||||||
#if CFG_TUSB_OS == OPT_OS_NONE || CFG_TUSB_OS == OPT_OS_PICO
|
// therefore event with RTOS tuh_task() still need to be invoked
|
||||||
|
if (tuh_task_event_ready())
|
||||||
|
{
|
||||||
tuh_task();
|
tuh_task();
|
||||||
#else
|
}
|
||||||
osal_task_delay(1); // TODO maybe yield()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO probably some timeout to prevent hanged
|
// TODO probably some timeout to prevent hanged
|
||||||
}
|
}
|
||||||
|
@@ -69,6 +69,13 @@ struct tuh_xfer_s
|
|||||||
// uint32_t timeout_ms; // place holder, not supported yet
|
// uint32_t timeout_ms; // place holder, not supported yet
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Subject to change
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint8_t daddr;
|
||||||
|
tusb_desc_interface_t desc;
|
||||||
|
} tuh_itf_info_t;
|
||||||
|
|
||||||
// ConfigID for tuh_config()
|
// ConfigID for tuh_config()
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -118,6 +125,9 @@ void tuh_task(void)
|
|||||||
tuh_task_ext(UINT32_MAX, false);
|
tuh_task_ext(UINT32_MAX, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if there is pending events need processing by tuh_task()
|
||||||
|
bool tuh_task_event_ready(void);
|
||||||
|
|
||||||
#ifndef _TUSB_HCD_H_
|
#ifndef _TUSB_HCD_H_
|
||||||
extern void hcd_int_handler(uint8_t rhport);
|
extern void hcd_int_handler(uint8_t rhport);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user