@@ -252,8 +252,8 @@ def active(self, *optional_value):
252
252
return self ._usbd .active (* optional_value )
253
253
254
254
def _open_itf_cb (self , desc ):
255
- # Singleton callback from TinyUSB custom class driver , when USB host does
256
- # Set Configuration. Called once per interface or IAD.
255
+ # Callback from TinyUSB lower layer , when USB host does Set
256
+ # Configuration. Called once per interface or IAD.
257
257
258
258
# Note that even if the configuration descriptor contains an IAD, 'desc'
259
259
# starts from the first interface descriptor in the IAD and not the IAD
@@ -291,7 +291,7 @@ def _open_itf_cb(self, desc):
291
291
itf .on_open ()
292
292
293
293
def _reset_cb (self ):
294
- # Callback when the USB device is reset by the host
294
+ # TinyUSB lower layer callback when the USB device is reset by the host
295
295
296
296
# Allow interfaces to respond to the reset
297
297
for itf in self ._itfs .values ():
@@ -302,7 +302,7 @@ def _reset_cb(self):
302
302
self ._ep_cbs = {}
303
303
304
304
def _submit_xfer (self , ep_addr , data , done_cb = None ):
305
- # Singleton function to submit a USB transfer (of any type except control).
305
+ # Submit a USB transfer (of any type except control) to TinyUSB lower layer .
306
306
#
307
307
# Generally, drivers should call Interface.submit_xfer() instead. See
308
308
# that function for documentation about the possible parameter values.
@@ -319,27 +319,31 @@ def _submit_xfer(self, ep_addr, data, done_cb=None):
319
319
return self ._usbd .submit_xfer (ep_addr , data )
320
320
321
321
def _xfer_pending (self , ep_addr ):
322
- # Singleton function to return True if transfer is pending on this endpoint.
322
+ # Returns True if a transfer is pending on this endpoint.
323
323
#
324
324
# Generally, drivers should call Interface.xfer_pending() instead. See that
325
325
# function for more documentation.
326
326
return self ._ep_cbs [ep_addr ] or (self ._cb_ep == ep_addr and self ._cb_thread != get_ident ())
327
327
328
328
def _xfer_cb (self , ep_addr , result , xferred_bytes ):
329
- # Singleton callback from TinyUSB custom class driver when a transfer completes.
329
+ # Callback from TinyUSB lower layer when a transfer completes.
330
330
cb = self ._ep_cbs .get (ep_addr , None )
331
331
self ._cb_thread = get_ident ()
332
332
self ._cb_ep = ep_addr # Track while callback is running
333
333
self ._ep_cbs [ep_addr ] = None
334
+
335
+ # In most cases, 'cb' is a callback function for the transfer. Can also be:
336
+ # - True (for a transfer with no callback)
337
+ # - None (TinyUSB callback arrived for invalid endpoint, or no transfer.
338
+ # Generally unlikely, but may happen in transient states.)
334
339
try :
335
- # For a pending xfer, 'cb' should either a callback function or True (if no callback)
336
340
if callable (cb ):
337
341
cb (ep_addr , result , xferred_bytes )
338
342
finally :
339
343
self ._cb_ep = None
340
344
341
345
def _control_xfer_cb (self , stage , request ):
342
- # Singleton callback from TinyUSB custom class driver when a control
346
+ # Callback from TinyUSB lower layer when a control
343
347
# transfer is in progress.
344
348
#
345
349
# stage determines appropriate responses (possible values
0 commit comments