This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3a76917058b0d22b2130827dfb723851166c4a70 Author: yangsong8 <[email protected]> AuthorDate: Mon May 19 10:38:16 2025 +0800 sim/usbdev: Process all pending data at once After processing a packet of data, do not exit interrupt, but continues to check whether there is data to be processed. If there is, continue processing. Signed-off-by: yangsong8 <[email protected]> --- arch/sim/src/sim/sim_usbdev.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/arch/sim/src/sim/sim_usbdev.c b/arch/sim/src/sim/sim_usbdev.c index ea1c2057e65..2e9684d1b76 100644 --- a/arch/sim/src/sim/sim_usbdev.c +++ b/arch/sim/src/sim/sim_usbdev.c @@ -1173,32 +1173,40 @@ int sim_usbdev_loop(void) uint8_t *recv_data; uint16_t data_len; uint8_t epcnt; + bool do_loop; /* Loop ep0 */ - ctrlreq = host_usbdev_ep0read(); - if (ctrlreq) + do { - sim_usbdev_ep0read(ctrlreq); - host_usbdev_epread_end(0); - } + do_loop = false; + ctrlreq = host_usbdev_ep0read(); + if (ctrlreq) + { + sim_usbdev_ep0read(ctrlreq); + host_usbdev_epread_end(0); + do_loop = true; + } - /* Loop other eps */ + /* Loop other eps */ - for (epcnt = 1; epcnt < SIM_USB_EPNUM; epcnt++) - { - privep = &priv->eps[epcnt]; - if (privep->epstate == SIM_EPSTATE_IDLE && - !USB_ISEPIN(privep->ep.eplog)) + for (epcnt = 1; epcnt < SIM_USB_EPNUM; epcnt++) { - recv_data = host_usbdev_epread(epcnt, &data_len); - if (recv_data) + privep = &priv->eps[epcnt]; + if (privep->epstate == SIM_EPSTATE_IDLE && + !USB_ISEPIN(privep->ep.eplog)) { - sim_usbdev_epread(privep->ep.eplog, recv_data, data_len); - host_usbdev_epread_end(epcnt); + recv_data = host_usbdev_epread(epcnt, &data_len); + if (recv_data) + { + sim_usbdev_epread(privep->ep.eplog, recv_data, data_len); + host_usbdev_epread_end(epcnt); + do_loop = true; + } } } } + while (do_loop); return OK; }
