mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
usbd: fix control transfer issue for chipidea hs when previous status and new setup complete in the same isr frame
change usbd edpt busy/stalled/claimed value to 0/1 instead of (true/false) since they are 1-bit field.
This commit is contained in:
parent
2c48050993
commit
1e998ce3bd
10
.idea/runConfigurations/rt1010.xml
generated
10
.idea/runConfigurations/rt1010.xml
generated
@ -1,10 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="rt1010" type="com.jetbrains.cidr.embedded.customgdbserver.type" factoryName="com.jetbrains.cidr.embedded.customgdbserver.factory" PROGRAM_PARAMS="gdbserver -p 55503 -t mimxrt1010" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="cdc_msc" TARGET_NAME="cdc_msc" CONFIG_NAME="rt1060 evk" version="1" RUN_TARGET_PROJECT_NAME="cdc_msc" RUN_TARGET_NAME="cdc_msc">
|
||||
<custom-gdb-server version="1" gdb-connect="tcp::55503" executable="$USER_HOME$/.local/bin/pyocd" warmup-ms="0" download-type="UPDATED_ONLY" reset-cmd="monitor reset" reset-type="AFTER_DOWNLOAD">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
</custom-gdb-server>
|
||||
<method v="2">
|
||||
<option name="CLION.COMPOUND.BUILD" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
10
.idea/runConfigurations/rt1010_nxplink.xml
generated
Normal file
10
.idea/runConfigurations/rt1010_nxplink.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="rt1010 nxplink" type="com.jetbrains.cidr.embedded.customgdbserver.type" factoryName="com.jetbrains.cidr.embedded.customgdbserver.factory" PROGRAM_PARAMS="gdbserver --gdb-port 55503 --semihost-port -1 MIMXRT1011xxxxx:EVK-MIMXRT1010" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="host_hid_to_device_cdc" TARGET_NAME="host_hid_to_device_cdc" CONFIG_NAME="rt1060 evk" version="1" RUN_TARGET_PROJECT_NAME="host_hid_to_device_cdc" RUN_TARGET_NAME="host_hid_to_device_cdc">
|
||||
<custom-gdb-server version="1" gdb-connect="tcp::55503" executable="/usr/local/LinkServer/LinkServer" warmup-ms="0" download-type="ALWAYS" reset-cmd="monitor reset" reset-type="AFTER_DOWNLOAD">
|
||||
<debugger kind="GDB" isBundled="true" />
|
||||
</custom-gdb-server>
|
||||
<method v="2">
|
||||
<option name="CLION.COMPOUND.BUILD" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -516,9 +516,9 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
|
||||
_usbd_dev.connected = 1;
|
||||
|
||||
// mark both in & out control as free
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_OUT].busy = false;
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_OUT].busy = 0;
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_OUT].claimed = 0;
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_IN ].busy = false;
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_IN ].busy = 0;
|
||||
_usbd_dev.ep_status[0][TUSB_DIR_IN ].claimed = 0;
|
||||
|
||||
// Process control request
|
||||
@ -540,12 +540,13 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
|
||||
|
||||
TU_LOG(USBD_DBG, "on EP %02X with %u bytes\r\n", ep_addr, (unsigned int) event.xfer_complete.len);
|
||||
|
||||
_usbd_dev.ep_status[epnum][ep_dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][ep_dir].busy = 0;
|
||||
_usbd_dev.ep_status[epnum][ep_dir].claimed = 0;
|
||||
|
||||
if ( 0 == epnum )
|
||||
{
|
||||
usbd_control_xfer_cb(event.rhport, ep_addr, (xfer_result_t)event.xfer_complete.result, event.xfer_complete.len);
|
||||
usbd_control_xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result, event.xfer_complete
|
||||
.len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -553,7 +554,7 @@ void tud_task_ext(uint32_t timeout_ms, bool in_isr)
|
||||
TU_ASSERT(driver, );
|
||||
|
||||
TU_LOG(USBD_DBG, " %s xfer callback\r\n", driver->name);
|
||||
driver->xfer_cb(event.rhport, ep_addr, (xfer_result_t)event.xfer_complete.result, event.xfer_complete.len);
|
||||
driver->xfer_cb(event.rhport, ep_addr, (xfer_result_t) event.xfer_complete.result, event.xfer_complete.len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1244,7 +1245,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
|
||||
// Set busy first since the actual transfer can be complete before dcd_edpt_xfer()
|
||||
// could return and USBD task can preempt and clear the busy
|
||||
_usbd_dev.ep_status[epnum][dir].busy = true;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 1;
|
||||
|
||||
if ( dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes) )
|
||||
{
|
||||
@ -1252,7 +1253,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
}else
|
||||
{
|
||||
// DCD error, mark endpoint as ready to allow next transfer
|
||||
_usbd_dev.ep_status[epnum][dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = 0;
|
||||
TU_LOG(USBD_DBG, "FAILED\r\n");
|
||||
TU_BREAKPOINT();
|
||||
@ -1278,7 +1279,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
// Set busy first since the actual transfer can be complete before dcd_edpt_xfer() could return
|
||||
// and usbd task can preempt and clear the busy
|
||||
_usbd_dev.ep_status[epnum][dir].busy = true;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 1;
|
||||
|
||||
if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes))
|
||||
{
|
||||
@ -1287,7 +1288,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
}else
|
||||
{
|
||||
// DCD error, mark endpoint as ready to allow next transfer
|
||||
_usbd_dev.ep_status[epnum][dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = 0;
|
||||
TU_LOG(USBD_DBG, "failed\r\n");
|
||||
TU_BREAKPOINT();
|
||||
@ -1317,8 +1318,8 @@ void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
TU_LOG(USBD_DBG, " Stall EP %02X\r\n", ep_addr);
|
||||
dcd_edpt_stall(rhport, ep_addr);
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = true;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = true;
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = 1;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1334,8 +1335,8 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
TU_LOG(USBD_DBG, " Clear Stall EP %02X\r\n", ep_addr);
|
||||
dcd_edpt_clear_stall(rhport, ep_addr);
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = false;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1366,9 +1367,9 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
|
||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||
|
||||
dcd_edpt_close(rhport, ep_addr);
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = false;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = false;
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1403,9 +1404,9 @@ bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep
|
||||
TU_ASSERT(epnum < CFG_TUD_ENDPPOINT_MAX);
|
||||
TU_ASSERT(tu_edpt_validate(desc_ep, (tusb_speed_t) _usbd_dev.speed));
|
||||
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = false;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = false;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = false;
|
||||
_usbd_dev.ep_status[epnum][dir].stalled = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].busy = 0;
|
||||
_usbd_dev.ep_status[epnum][dir].claimed = 0;
|
||||
return dcd_edpt_iso_activate(rhport, desc_ep);
|
||||
}
|
||||
|
||||
|
@ -616,15 +616,6 @@ void dcd_int_handler(uint8_t rhport)
|
||||
uint32_t const edpt_complete = dcd_reg->ENDPTCOMPLETE;
|
||||
dcd_reg->ENDPTCOMPLETE = edpt_complete; // acknowledge
|
||||
|
||||
if (dcd_reg->ENDPTSETUPSTAT)
|
||||
{
|
||||
//------------- Set up Received -------------//
|
||||
// 23.10.10.2 Operational model for setup transfers
|
||||
dcd_reg->ENDPTSETUPSTAT = dcd_reg->ENDPTSETUPSTAT;
|
||||
|
||||
dcd_event_setup_received(rhport, (uint8_t*)(uintptr_t) &_dcd_data.qhd[0][0].setup_request, true);
|
||||
}
|
||||
|
||||
// 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set
|
||||
// nothing to do, we will submit xfer as error to usbd
|
||||
// if (int_status & INTR_ERROR) { }
|
||||
@ -637,6 +628,15 @@ void dcd_int_handler(uint8_t rhport)
|
||||
if ( tu_bit_test(edpt_complete, epnum+16) ) process_edpt_complete_isr(rhport, epnum, TUSB_DIR_IN);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up Received
|
||||
// 23.10.10.2 Operational model for setup transfers
|
||||
// Must be after normal transfer complete since it is possible to have both previous control status + new setup
|
||||
// in the same frame and we should handle previous status first.
|
||||
if (dcd_reg->ENDPTSETUPSTAT) {
|
||||
dcd_reg->ENDPTSETUPSTAT = dcd_reg->ENDPTSETUPSTAT;
|
||||
dcd_event_setup_received(rhport, (uint8_t *) (uintptr_t) &_dcd_data.qhd[0][0].setup_request, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (int_status & INTR_SOF)
|
||||
|
Loading…
x
Reference in New Issue
Block a user