mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 01:20:19 +00:00
static assert to check OSAL_QUEUE_DEF's queue_depth parameter < 256
enable HOST_HCD_XFER_INTERRUPT by default (previously only enabled with HID), as it is widely used implement tusbh_cdc_is_busy add compilation switch in usbh enumeration for hub rewrite CDC serial application to address usb-serial race condition
This commit is contained in:
parent
0d9e1163df
commit
318a058d3c
File diff suppressed because it is too large
Load Diff
@ -1,125 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>host_freertos</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/host/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>bsp</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/bsp</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>fatfs</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/fatfs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>freertos</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/freertos</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>lwip</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/lwip</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/src</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>tinyusb</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/tinyusb</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1366799906386</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-startup_keil</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>host_freertos</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/host/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>bsp</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/bsp</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>fatfs</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/fatfs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>freertos</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/freertos</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>lwip</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/lwip</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>src</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/src</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>tinyusb</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/tinyusb</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1382869902141</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-startup_keil</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
<filter>
|
||||
<id>1382869902149</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.ui.ide.multiFilter</id>
|
||||
<arguments>1.0-name-matches-false-false-startup_iar</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -53,24 +53,22 @@ OSAL_TASK_DEF(cdc_serial_app_task, 128, CDC_SERIAL_APP_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(queue_def, QUEUE_SERIAL_DEPTH, uint8_t);
|
||||
|
||||
static osal_queue_handle_t queue_hdl;
|
||||
static uint8_t buffer_in[64] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
static uint8_t serial_in_buffer[32] TUSB_CFG_ATTR_USBRAM;
|
||||
static uint8_t serial_out_buffer[32] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// tinyusb Callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
void tusbh_cdc_mounted_cb(uint8_t dev_addr)
|
||||
{
|
||||
// application set-up
|
||||
|
||||
{ // application set-up
|
||||
printf("\na CDC device is mounted\n");
|
||||
|
||||
osal_queue_flush(queue_hdl);
|
||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // first report
|
||||
}
|
||||
|
||||
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||
{
|
||||
// application tear-down
|
||||
{ // application tear-down
|
||||
printf("\na CDC device is unmounted\n");
|
||||
}
|
||||
|
||||
@ -83,27 +81,20 @@ void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_
|
||||
case TUSB_EVENT_XFER_COMPLETE:
|
||||
for(uint32_t i=0; i<xferred_bytes; i++)
|
||||
{
|
||||
osal_queue_send(queue_hdl, buffer_in+i);
|
||||
osal_queue_send(queue_hdl, serial_in_buffer+i);
|
||||
}
|
||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true);
|
||||
break;
|
||||
break;
|
||||
|
||||
case TUSB_EVENT_XFER_ERROR:
|
||||
tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // ignore & continue
|
||||
break;
|
||||
case TUSB_EVENT_XFER_ERROR: break; // ignore
|
||||
|
||||
case TUSB_EVENT_XFER_STALLED:
|
||||
default :
|
||||
ASSERT(false, VOID_RETURN); // error
|
||||
break;
|
||||
ASSERT(false, VOID_RETURN);
|
||||
break;
|
||||
}
|
||||
}else if (pipe_id == CDC_PIPE_DATA_OUT)
|
||||
{
|
||||
|
||||
}else if (pipe_id == CDC_PIPE_NOTIFICATION)
|
||||
{
|
||||
|
||||
}
|
||||
else if (pipe_id == CDC_PIPE_DATA_OUT) { }
|
||||
else if (pipe_id == CDC_PIPE_NOTIFICATION) { }
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@ -111,7 +102,7 @@ void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_
|
||||
//--------------------------------------------------------------------+
|
||||
void cdc_serial_app_init(void)
|
||||
{
|
||||
memclr_(buffer_in, sizeof(buffer_in));
|
||||
memclr_(serial_in_buffer, sizeof(serial_in_buffer));
|
||||
|
||||
queue_hdl = osal_queue_create( OSAL_QUEUE_REF(queue_def) );
|
||||
ASSERT_PTR( queue_hdl, VOID_RETURN);
|
||||
@ -122,16 +113,39 @@ void cdc_serial_app_init(void)
|
||||
//------------- main task -------------//
|
||||
OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
|
||||
{
|
||||
tusb_error_t error;
|
||||
uint8_t c = 0;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
osal_queue_receive(queue_hdl, &c, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
|
||||
if (c)
|
||||
for(uint8_t dev_addr=0; dev_addr< TUSB_CFG_HOST_DEVICE_MAX; dev_addr++)
|
||||
{
|
||||
printf("%c", c);
|
||||
if ( tusbh_cdc_serial_is_mounted(dev_addr) )
|
||||
{
|
||||
//------------- send characters got from uart terminal -------------//
|
||||
int ch_tx = getchar();
|
||||
if ( ch_tx > 0 )
|
||||
{ // USB is much faster than serial, here we assume usb is always complete. There could be some characters missing
|
||||
serial_out_buffer[0] = (uint8_t) ch_tx;
|
||||
|
||||
if ( !tusbh_cdc_is_busy(dev_addr, CDC_PIPE_DATA_OUT) )
|
||||
{
|
||||
tusbh_cdc_send(dev_addr, serial_out_buffer, 1, false); // no need for interrupt on serial out pipe
|
||||
}
|
||||
}
|
||||
|
||||
//------------- print out received characters -------------//
|
||||
tusb_error_t error;
|
||||
do{
|
||||
uint8_t ch_rx = 0;
|
||||
osal_queue_receive(queue_hdl, &ch_rx, OSAL_TIMEOUT_NOTIMEOUT, &error); // instant return
|
||||
if (error == TUSB_ERROR_NONE && ch_rx) printf("%c", ch_rx);
|
||||
}while (error == TUSB_ERROR_NONE);
|
||||
|
||||
if ( !tusbh_cdc_is_busy(dev_addr, CDC_PIPE_DATA_IN) )
|
||||
{
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true);
|
||||
}
|
||||
|
||||
break; // demo app only communicate with the first CDC-capable device
|
||||
}
|
||||
}
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
|
@ -170,7 +170,7 @@ void test_task_with_semaphore(void)
|
||||
TEST_ASSERT_EQUAL(1, statements[3]);
|
||||
|
||||
// timeout
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 ; i++) // not enough time
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 - 1 ; i++) // not enough time
|
||||
osal_tick_tock();
|
||||
sample_task_semaphore();
|
||||
TEST_ASSERT_EQUAL(0, statements[4]);
|
||||
@ -241,7 +241,7 @@ void test_task_with_mutex(void)
|
||||
TEST_ASSERT_EQUAL(0, statements[5]);
|
||||
|
||||
// timeout
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 ; i++){ // one tick less
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 - 1 ; i++){ // one tick less
|
||||
osal_tick_tock();
|
||||
}
|
||||
mutex_sample_task2();
|
||||
@ -311,7 +311,7 @@ void test_task_with_queue(void)
|
||||
TEST_ASSERT_EQUAL(1, statements[3]);
|
||||
|
||||
// timeout
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 ; i++) // not enough time
|
||||
for(uint32_t i=0; i<(OSAL_TIMEOUT_NORMAL*TUSB_CFG_OS_TICKS_PER_SECOND)/1000 - 1 ; i++) // not enough time
|
||||
osal_tick_tock();
|
||||
sample_task_with_queue();
|
||||
TEST_ASSERT_EQUAL(0, statements[4]);
|
||||
|
@ -58,6 +58,17 @@
|
||||
//--------------------------------------------------------------------+
|
||||
/*STATIC_*/ cdch_data_t cdch_data[TUSB_CFG_HOST_DEVICE_MAX]; // TODO to be static
|
||||
|
||||
static inline cdc_pipeid_t get_app_pipeid(pipe_handle_t pipe_hdl) ATTR_PURE ATTR_ALWAYS_INLINE;
|
||||
static inline cdc_pipeid_t get_app_pipeid(pipe_handle_t pipe_hdl)
|
||||
{
|
||||
cdch_data_t const * p_cdc = &cdch_data[pipe_hdl.dev_addr-1];
|
||||
|
||||
return pipehandle_is_equal( pipe_hdl, p_cdc->pipe_notification ) ? CDC_PIPE_NOTIFICATION :
|
||||
pipehandle_is_equal( pipe_hdl, p_cdc->pipe_in ) ? CDC_PIPE_DATA_IN :
|
||||
pipehandle_is_equal( pipe_hdl, p_cdc->pipe_out ) ? CDC_PIPE_DATA_OUT : CDC_PIPE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
STATIC_ INLINE_ bool tusbh_cdc_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
|
||||
STATIC_ INLINE_ bool tusbh_cdc_is_mounted(uint8_t dev_addr)
|
||||
{
|
||||
@ -70,16 +81,29 @@ STATIC_ INLINE_ bool tusbh_cdc_is_mounted(uint8_t dev_addr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline cdc_pipeid_t get_app_pipeid(pipe_handle_t pipe_hdl) ATTR_PURE ATTR_ALWAYS_INLINE;
|
||||
static inline cdc_pipeid_t get_app_pipeid(pipe_handle_t pipe_hdl)
|
||||
bool tusbh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid)
|
||||
{
|
||||
cdch_data_t const * p_cdc = &cdch_data[pipe_hdl.dev_addr-1];
|
||||
if ( !tusbh_cdc_is_mounted(dev_addr) ) return false;
|
||||
|
||||
return pipehandle_is_equal( pipe_hdl, p_cdc->pipe_notification ) ? CDC_PIPE_NOTIFICATION :
|
||||
pipehandle_is_equal( pipe_hdl, p_cdc->pipe_in ) ? CDC_PIPE_DATA_IN :
|
||||
pipehandle_is_equal( pipe_hdl, p_cdc->pipe_out ) ? CDC_PIPE_DATA_OUT : CDC_PIPE_ERROR;
|
||||
cdch_data_t const * p_cdc = &cdch_data[dev_addr-1];
|
||||
|
||||
switch (pipeid)
|
||||
{
|
||||
case CDC_PIPE_NOTIFICATION:
|
||||
return hcd_pipe_is_busy( p_cdc->pipe_notification );
|
||||
|
||||
case CDC_PIPE_DATA_IN:
|
||||
return hcd_pipe_is_busy( p_cdc->pipe_in );
|
||||
|
||||
case CDC_PIPE_DATA_OUT:
|
||||
return hcd_pipe_is_busy( p_cdc->pipe_out );
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API (parameter validation needed)
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -64,6 +64,8 @@ typedef enum {
|
||||
* @{ */
|
||||
|
||||
bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
bool tusbh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
|
||||
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
|
||||
|
||||
|
@ -69,6 +69,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// EHCI CONFIGURATION & CONSTANTS
|
||||
//--------------------------------------------------------------------+
|
||||
#define HOST_HCD_XFER_INTERRUPT // TODO interrupt is used widely, should always be enalbed
|
||||
#define EHCI_PERIODIC_LIST (defined HOST_HCD_XFER_INTERRUPT || defined HOST_HCD_XFER_ISOCHRONOUS)
|
||||
|
||||
// TODO allow user to configure
|
||||
|
@ -392,6 +392,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
SUBTASK_EXIT(TUSB_ERROR_NONE); // restart task
|
||||
}
|
||||
}
|
||||
#if TUSB_CFG_HOST_HUB
|
||||
else
|
||||
{ // connected/disconnected via hub
|
||||
//------------- Get Port Status -------------//
|
||||
@ -428,6 +429,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_RESET_CHANGE), error );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SUBTASK_ASSERT_STATUS( usbh_pipe_control_open(0, 8) );
|
||||
usbh_devices[0].state = TUSB_DEVICE_STATE_ADDRESSED;
|
||||
@ -446,7 +448,9 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
SUBTASK_ASSERT_STATUS(error); // TODO some slow device is observed to fail the very fist controller xfer, can try more times
|
||||
hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor
|
||||
// osal_task_delay(50); // TODO reset is recommended to last 50 ms (NXP EHCI passes this)
|
||||
}else
|
||||
}
|
||||
#if TUSB_CFG_HOST_HUB
|
||||
else
|
||||
{ // connected via a hub
|
||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
||||
@ -458,6 +462,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
|
||||
(void) hub_status_pipe_queue( usbh_devices[0].hub_addr ); // done with hub, waiting for next data on status pipe
|
||||
}
|
||||
#endif
|
||||
|
||||
//------------- Set new address -------------//
|
||||
new_addr = get_new_address();
|
||||
|
@ -263,6 +263,7 @@ typedef osal_queue_t * osal_queue_handle_t;
|
||||
|
||||
// use to declare a queue, within the scope of tinyusb, should only use primitive type only
|
||||
#define OSAL_QUEUE_DEF(name, queue_depth, type)\
|
||||
STATIC_ASSERT(queue_depth < 256, "OSAL Queue only support up to 255 depth");\
|
||||
type name##_buffer[queue_depth];\
|
||||
osal_queue_t name = {\
|
||||
.buffer = (uint8_t*) name##_buffer,\
|
||||
|
@ -147,9 +147,9 @@
|
||||
|
||||
//------------- HID CLASS -------------//
|
||||
#define HOST_CLASS_HID ( TUSB_CFG_HOST_HID_KEYBOARD + TUSB_CFG_HOST_HID_MOUSE + TUSB_CFG_HOST_HID_GENERIC )
|
||||
#if HOST_CLASS_HID
|
||||
#define HOST_HCD_XFER_INTERRUPT
|
||||
#endif
|
||||
// #if HOST_CLASS_HID
|
||||
// #define HOST_HCD_XFER_INTERRUPT
|
||||
// #endif
|
||||
|
||||
#ifndef TUSB_CFG_HOST_ENUM_BUFFER_SIZE
|
||||
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
|
||||
|
Loading…
x
Reference in New Issue
Block a user