@@ -56,9 +56,7 @@ class _USBDevice:
56
56
def __init__ (self ):
57
57
self ._eps = {} # Mapping from endpoint address to interface object
58
58
self ._ep_cbs = {} # Mapping from endpoint address to Optional[xfer callback]
59
- self ._itfs = (
60
- []
61
- ) # List of USBInterfaces (NOTE: each of these may contain >1 USB Interface descriptor)
59
+ self ._itfs = [] # List of USBInterfaces (NOTE: each of these may contain >1 USB Interface descriptor)
62
60
self ._desc = Descriptor ()
63
61
self .include_static = True # Include static devices when enumerating?
64
62
@@ -404,15 +402,13 @@ def _control_xfer_cb(self, stage, request):
404
402
print (f"Unexpected control request type { request [0 ]:#x} " )
405
403
return False
406
404
407
- # Accept the following possible replies from handle_NNN_control_xfer():
405
+ # Expecting any of the following possible replies from
406
+ # handle_NNN_control_xfer():
408
407
#
409
408
# True - Continue transfer, no data
410
409
# False - STALL transfer
411
410
# Object with buffer interface - submit this data for the control transfer
412
- if isinstance (result , bool ):
413
- return result
414
-
415
- return self ._usbd .control_xfer (request , result )
411
+ return result
416
412
417
413
418
414
class USBInterface :
@@ -609,21 +605,16 @@ def submit_xfer(self, ep_addr, data, done_cb=None):
609
605
raise RuntimeError ("Not open" )
610
606
_inst ._submit_xfer (ep_addr , data , done_cb )
611
607
612
- def set_ep_stall (self , ep_addr , stall ):
613
- # Set or clear endpoint STALL state, according to the bool "stall" parameter .
608
+ def stall (self , ep_addr , * args ):
609
+ # Set or get the endpoint STALL state.
614
610
#
615
- # Generally endpoint STALL is handled automatically by TinyUSB, but
616
- # there are some device classes that need to explicitly stall or unstall
617
- # an endpoint under certain conditions.
618
- if not self ._open or ep_addr not in _inst ._eps :
619
- raise RuntimeError
620
- _inst ._usbd .set_ep_stall (ep_addr , stall )
621
-
622
- def get_ep_stall (self , ep_addr ):
623
- # Get the current endpoint STALL state.
611
+ # To get endpoint stall stage, call with a single argument.
612
+ # To set endpoint stall state, call with an additional boolean
613
+ # argument to set or clear.
624
614
#
625
- # Endpoint can be stalled/unstalled by host, TinyUSB stack, or calls to
626
- # set_ep_stall().
627
- if not self ._open or ep_addr not in get_usbdevice ()._eps :
615
+ # Generally endpoint STALL is handled automatically, but there are some
616
+ # device classes that need to explicitly stall or unstall an endpoint
617
+ # under certain conditions.
618
+ if not self ._open or ep_addr not in _inst ._eps :
628
619
raise RuntimeError
629
- return _inst ._usbd .get_ep_stall (ep_addr )
620
+ _inst ._usbd .stall (ep_addr , * args )
0 commit comments