Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc61ca51

Browse files
committed
usb: Tidy up the description of TinyUSB callbacks.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent01f45c1 commitc61ca51

File tree

1 file changed

+12
-8
lines changed
  • micropython/usb/usb-device/usb/device

1 file changed

+12
-8
lines changed

‎micropython/usb/usb-device/usb/device/core.py‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def active(self, *optional_value):
252252
returnself._usbd.active(*optional_value)
253253

254254
def_open_itf_cb(self,desc):
255-
#Singleton callbackfrom TinyUSBcustom class driver, when USB host does
256-
#SetConfiguration. Called once per interface or IAD.
255+
#Callbackfrom TinyUSBlower layer, when USB host does Set
256+
# Configuration. Called once per interface or IAD.
257257

258258
# Note that even if the configuration descriptor contains an IAD, 'desc'
259259
# starts from the first interface descriptor in the IAD and not the IAD
@@ -291,7 +291,7 @@ def _open_itf_cb(self, desc):
291291
itf.on_open()
292292

293293
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
295295

296296
# Allow interfaces to respond to the reset
297297
foritfinself._itfs.values():
@@ -302,7 +302,7 @@ def _reset_cb(self):
302302
self._ep_cbs= {}
303303

304304
def_submit_xfer(self,ep_addr,data,done_cb=None):
305-
#Singleton function to submita USB transfer (of any type except control).
305+
#Submita USB transfer (of any type except control) to TinyUSB lower layer.
306306
#
307307
# Generally, drivers should call Interface.submit_xfer() instead. See
308308
# that function for documentation about the possible parameter values.
@@ -319,27 +319,31 @@ def _submit_xfer(self, ep_addr, data, done_cb=None):
319319
returnself._usbd.submit_xfer(ep_addr,data)
320320

321321
def_xfer_pending(self,ep_addr):
322-
#Singleton function to returnTrue if transfer is pending on this endpoint.
322+
#ReturnsTrue if a transfer is pending on this endpoint.
323323
#
324324
# Generally, drivers should call Interface.xfer_pending() instead. See that
325325
# function for more documentation.
326326
returnself._ep_cbs[ep_addr]or (self._cb_ep==ep_addrandself._cb_thread!=get_ident())
327327

328328
def_xfer_cb(self,ep_addr,result,xferred_bytes):
329-
#Singleton callbackfrom TinyUSBcustom class driver when a transfer completes.
329+
#Callbackfrom TinyUSBlower layer when a transfer completes.
330330
cb=self._ep_cbs.get(ep_addr,None)
331331
self._cb_thread=get_ident()
332332
self._cb_ep=ep_addr# Track while callback is running
333333
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.)
334339
try:
335-
# For a pending xfer, 'cb' should either a callback function or True (if no callback)
336340
ifcallable(cb):
337341
cb(ep_addr,result,xferred_bytes)
338342
finally:
339343
self._cb_ep=None
340344

341345
def_control_xfer_cb(self,stage,request):
342-
#Singleton callbackfrom TinyUSBcustom class driver when a control
346+
#Callbackfrom TinyUSBlower layer when a control
343347
# transfer is in progress.
344348
#
345349
# stage determines appropriate responses (possible values

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp