Skip to content

Commit bf6132f

Browse files
committed
usbd: Call _inst directly rather than singleton function.
Margin throughput improvement by removing one function call. Setting USBInterface.submit_xfer = USBDevice._submit_xfer would seem like the next natural step, but this didn't seem to change performance above the noise level. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent d6da573 commit bf6132f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

micropython/usbd/device.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def xfer_pending(self, ep_addr):
584584
# Return True if a transfer is already pending on ep_addr.
585585
#
586586
# Only one transfer can be submitted at a time.
587-
return bool(get_usbdevice()._ep_cbs[ep_addr])
587+
return bool(_inst._ep_cbs[ep_addr])
588588

589589
def submit_xfer(self, ep_addr, data, done_cb=None):
590590
# Submit a USB transfer (of any type except control)
@@ -623,17 +623,17 @@ def submit_xfer(self, ep_addr, data, done_cb=None):
623623
# function has returned to the caller.
624624
if not self._open:
625625
raise RuntimeError("Not open")
626-
get_usbdevice()._submit_xfer(ep_addr, data, done_cb)
626+
_inst._submit_xfer(ep_addr, data, done_cb)
627627

628628
def set_ep_stall(self, ep_addr, stall):
629629
# Set or clear endpoint STALL state, according to the bool "stall" parameter.
630630
#
631631
# Generally endpoint STALL is handled automatically by TinyUSB, but
632632
# there are some device classes that need to explicitly stall or unstall
633633
# an endpoint under certain conditions.
634-
if not self._open or ep_addr not in get_usbdevice()._eps:
634+
if not self._open or ep_addr not in _inst._eps:
635635
raise RuntimeError
636-
get_usbdevice()._usbd.set_ep_stall(ep_addr, stall)
636+
_inst._usbd.set_ep_stall(ep_addr, stall)
637637

638638
def get_ep_stall(self, ep_addr):
639639
# Get the current endpoint STALL state.
@@ -642,4 +642,4 @@ def get_ep_stall(self, ep_addr):
642642
# set_ep_stall().
643643
if not self._open or ep_addr not in get_usbdevice()._eps:
644644
raise RuntimeError
645-
return get_usbdevice()._usbd.get_ep_stall(ep_addr)
645+
return _inst._usbd.get_ep_stall(ep_addr)

0 commit comments

Comments
 (0)