Skip to content

Commit 5f639f3

Browse files
committed
count in/out endpoints; allow more usb modules on low-endpoint boards
1 parent 0651ef1 commit 5f639f3

35 files changed

+198
-123
lines changed

locale/ID.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4538,7 +4538,7 @@ msgstr ""
45384538
#~ msgstr "Berjalan di mode aman(safe mode)! Auto-reload tidak aktif.\n"
45394539

45404540
#~ msgid "Running in safe mode! Not running saved code.\n"
4541-
#~ msgstr ""
4541+
#~ msgstr "Berjalan di mode aman(safe mode)! Tidak menjalankan kode yang disimpan.\n"
45424542
#~ "Berjalan di mode aman(safe mode)! tidak menjalankan kode yang tersimpan.\n"
45434543

45444544
#~ msgid "'async for' or 'async with' outside async function"

locale/de_DE.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ msgstr ""
732732
"zu verlassen.\n"
733733

734734
#: supervisor/shared/safe_mode.c
735-
msgid "CircuitPython was unable to allocate the heap.\n"
736-
msgstr "CircuitPython war es nicht möglich heap-Speicher zu allozieren.\n"
735+
msgid "CircuitPython was unable to allocate the heap."
736+
msgstr "CircuitPython war es nicht möglich heap-Speicher zu allozieren."
737737

738738
#: shared-module/bitbangio/SPI.c
739739
msgid "Clock pin init failed."

locale/en_GB.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,8 @@ msgstr ""
729729
"boot. Press again to exit safe mode.\n"
730730

731731
#: supervisor/shared/safe_mode.c
732-
msgid "CircuitPython was unable to allocate the heap.\n"
733-
msgstr "CircuitPython was unable to allocate the heap.\n"
732+
msgid "CircuitPython was unable to allocate the heap."
733+
msgstr "CircuitPython was unable to allocate the heap."
734734

735735
#: shared-module/bitbangio/SPI.c
736736
msgid "Clock pin init failed."

locale/es.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ msgstr ""
738738
"durante el arranque. Presione nuevamente para salir del modo seguro.\n"
739739

740740
#: supervisor/shared/safe_mode.c
741-
msgid "CircuitPython was unable to allocate the heap.\n"
742-
msgstr "CircuitPython no puedo encontrar el montículo.\n"
741+
msgid "CircuitPython was unable to allocate the heap."
742+
msgstr "CircuitPython no puedo encontrar el montículo."
743743

744744
#: shared-module/bitbangio/SPI.c
745745
msgid "Clock pin init failed."
@@ -4777,7 +4777,7 @@ msgstr "zi debe ser una forma (n_section,2)"
47774777
#~ msgstr "Ejecutando en modo seguro! La auto-recarga esta deshabilitada.\n"
47784778

47794779
#~ msgid "Running in safe mode! Not running saved code.\n"
4780-
#~ msgstr ""
4780+
#~ msgstr "Ejecutando en modo seguro! No ejecutando el código almacenado.\n"
47814781
#~ "Ejecutando en modo seguro! No se esta ejecutando el código guardado.\n"
47824782

47834783
#~ msgid "__init__() should return None, not '%s'"

locale/fr.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,8 +745,8 @@ msgstr ""
745745
"mode sans échec.\n"
746746

747747
#: supervisor/shared/safe_mode.c
748-
msgid "CircuitPython was unable to allocate the heap.\n"
749-
msgstr "CircuitPython n'as pu faire l'allocation de la pile.\n"
748+
msgid "CircuitPython was unable to allocate the heap."
749+
msgstr "CircuitPython n'as pu faire l'allocation de la pile."
750750

751751
#: shared-module/bitbangio/SPI.c
752752
msgid "Clock pin init failed."

locale/hi.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ msgid ""
716716
msgstr ""
717717

718718
#: supervisor/shared/safe_mode.c
719-
msgid "CircuitPython was unable to allocate the heap.\n"
719+
msgid "CircuitPython was unable to allocate the heap."
720720
msgstr ""
721721

722722
#: shared-module/bitbangio/SPI.c

locale/ja.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ msgstr ""
727727
"度押すとセーフモードを終了します。\n"
728728

729729
#: supervisor/shared/safe_mode.c
730-
msgid "CircuitPython was unable to allocate the heap.\n"
731-
msgstr "CircuitPythonはヒープを確保できませんでした\n"
730+
msgid "CircuitPython was unable to allocate the heap."
731+
msgstr "CircuitPythonはヒープを確保できませんでした"
732732

733733
#: shared-module/bitbangio/SPI.c
734734
msgid "Clock pin init failed."
@@ -1966,8 +1966,8 @@ msgid "Row entry must be digitalio.DigitalInOut"
19661966
msgstr "Rowの各要素は digitalio.DigitalInOut でなければなりません"
19671967

19681968
#: main.c
1969-
msgid "Running in safe mode! "
1970-
msgstr "セーフモードで実行中! "
1969+
msgid "Running in safe mode! Not running saved code.\n"
1970+
msgstr "セーフモードで実行中! 保存されたコードは実行していません。\n"
19711971

19721972
#: shared-module/sdcardio/SDCard.c
19731973
msgid "SD card CSD format not supported"

locale/nl.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ msgstr ""
725725
"het opstarten. Druk nogmaals om veilige modus te verlaten\n"
726726

727727
#: supervisor/shared/safe_mode.c
728-
msgid "CircuitPython was unable to allocate the heap.\n"
729-
msgstr "CircuitPython kon het heap geheugen niet toewijzen.\n"
728+
msgid "CircuitPython was unable to allocate the heap."
729+
msgstr "CircuitPython kon het heap geheugen niet toewijzen."
730730

731731
#: shared-module/bitbangio/SPI.c
732732
msgid "Clock pin init failed."

locale/pl.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ msgstr ""
725725
"przycisk resetowania. Naciśnij ponownie, aby wyjść z trybu awaryjnego.\n"
726726

727727
#: supervisor/shared/safe_mode.c
728-
msgid "CircuitPython was unable to allocate the heap.\n"
729-
msgstr "CircuitPython nie mógł przydzielić sterty.\n"
728+
msgid "CircuitPython was unable to allocate the heap."
729+
msgstr "CircuitPython nie mógł przydzielić sterty."
730730

731731
#: shared-module/bitbangio/SPI.c
732732
msgid "Clock pin init failed."

locale/pt_BR.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ msgstr ""
743743
"de segurança.\n"
744744

745745
#: supervisor/shared/safe_mode.c
746-
msgid "CircuitPython was unable to allocate the heap.\n"
747-
msgstr "O CircuitPython não conseguiu alocar o heap.\n"
746+
msgid "CircuitPython was unable to allocate the heap."
747+
msgstr "O CircuitPython não conseguiu alocar o heap."
748748

749749
#: shared-module/bitbangio/SPI.c
750750
msgid "Clock pin init failed."
@@ -4818,7 +4818,7 @@ msgstr "zi deve estar na forma (n_section, 2)"
48184818
#~ msgstr "Rodando em modo seguro! Atualização automática está desligada.\n"
48194819

48204820
#~ msgid "Running in safe mode! Not running saved code.\n"
4821-
#~ msgstr "Rodando em modo seguro! Não está executando o código salvo.\n"
4821+
#~ msgstr "Rodando em modo seguro! O código salvo não está em execução.\n"
48224822

48234823
#~ msgid "__init__() should return None, not '%s'"
48244824
#~ msgstr "O __init__() deve retornar Nenhum, não '%s'"

locale/sv.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,8 @@ msgstr ""
731731
"under start. Tryck igen för att lämna säkert läge.\n"
732732

733733
#: supervisor/shared/safe_mode.c
734-
msgid "CircuitPython was unable to allocate the heap.\n"
735-
msgstr "CircuitPython kunde inte allokera heap.\n"
734+
msgid "CircuitPython was unable to allocate the heap."
735+
msgstr "CircuitPython kunde inte allokera heap."
736736

737737
#: shared-module/bitbangio/SPI.c
738738
msgid "Clock pin init failed."

locale/zh_Latn_pinyin.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ msgstr ""
732732
"chóng zhì ànniǔ. Zài àn yīcì tuìchū ānquán móshì.\n"
733733

734734
#: supervisor/shared/safe_mode.c
735-
msgid "CircuitPython was unable to allocate the heap.\n"
736-
msgstr "CircuitPython wúfǎ fēnpèi duī.\n"
735+
msgid "CircuitPython was unable to allocate the heap."
736+
msgstr "CircuitPython wúfǎ fēnpèi duī."
737737

738738
#: shared-module/bitbangio/SPI.c
739739
msgid "Clock pin init failed."

ports/atmel-samd/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ endif
2121
INTERNAL_LIBM = 1
2222

2323
# Number of USB endpoint pairs.
24-
USB_NUM_EP = 8
24+
USB_NUM_ENDPOINT_PAIRS = 8
2525

2626
CIRCUITPY_ROTARYIO_SOFTENCODER = 1
2727

ports/cxd56/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
USB_HIGHSPEED = 1
22

33
# Number of USB endpoint pairs.
4-
USB_NUM_EP = 6
4+
USB_NUM_ENDPOINT_PAIRS = 6
55

66
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
77
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.

ports/esp32s2/mpconfigport.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,21 @@ CIRCUITPY_ROTARYIO = 1
2727
CIRCUITPY_NVM = 1
2828
CIRCUITPY_PS2IO ?= 1
2929
CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
30-
# We don't have enough endpoints to include MIDI.
31-
CIRCUITPY_USB_MIDI ?= 0
32-
CIRCUITPY_USB_HID ?= 1
33-
# We have borrowed the VENDOR nomenclature from tinyusb. VENDOR AKA WEBUSB
34-
CIRCUITPY_USB_VENDOR ?= 0
3530
CIRCUITPY_WIFI = 1
3631
CIRCUITPY_WATCHDOG ?= 1
3732

3833
CIRCUITPY_ESPIDF = 1
3934

4035
CIRCUITPY_MODULE ?= none
4136

42-
USB_NUM_EP = 5
37+
# From the ESP32-S2 datasheet:
38+
#
39+
# Endpoint number 0 always present (bi-directional, consisting of EP0 IN and EP0 OUT)
40+
# Six additional endpoints (endpoint numbers 1 to 6), configurable as IN or OUT
41+
# Maximum of five IN endpoints concurrently active at any time (including EP0 IN)
42+
#
43+
# Due to the limited number of endpoints, some USB devices will be off by default.
44+
# For instance MIDI is available, but the device is turned off. It can be turned on
45+
# only if something else is turned off, such as HID.
46+
USB_NUM_ENDPOINT_PAIRS = 7
47+
USB_NUM_IN_ENDPOINTS = 5

ports/litex/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
77
INTERNAL_LIBM = 1
88

99
# Number of USB endpoint pairs.
10-
USB_NUM_EP = 16
10+
USB_NUM_ENDPOINT_PAIRS = 16
1111

1212
# Longints can be implemented as mpz, as longlong, or not
1313
LONGINT_IMPL = MPZ

ports/mimxrt10xx/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ INTERNAL_LIBM = 1
1717
USB_HIGHSPEED = 1
1818

1919
# Number of USB endpoint pairs.
20-
USB_NUM_EP = 8
20+
USB_NUM_ENDPOINT_PAIRS = 8
2121

2222
INTERNAL_FLASH_FILESYSTEM = 1
2323

ports/nrf/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
1010
INTERNAL_LIBM = 1
1111

1212
# Number of USB endpoint pairs.
13-
USB_NUM_EP = 8
13+
USB_NUM_ENDPOINT_PAIRS = 8
1414

1515
# All nRF ports have longints.
1616
LONGINT_IMPL = MPZ

ports/raspberrypi/mpconfigport.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ CIRCUITPY_AUDIOMIXER = 1
4949
INTERNAL_LIBM = 1
5050

5151
# Number of USB endpoint pairs.
52-
USB_NUM_EP = 8
52+
USB_NUM_ENDPOINT_PAIRS = 8
5353

5454
INTERNAL_FLASH_FILESYSTEM = 1

ports/stm/mpconfigport.mk

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F405xx STM32F407xx))
77
CIRCUITPY_FRAMEBUFFERIO ?= 1
88
CIRCUITPY_SDIOIO ?= 1
99
# Number of USB endpoint pairs.
10-
USB_NUM_EP = 4
10+
USB_NUM_ENDPOINT_PAIRS = 4
1111
endif
1212

1313
ifeq ($(MCU_SERIES),F4)
@@ -24,10 +24,7 @@ ifeq ($(MCU_SERIES),F4)
2424
CIRCUITPY_NVM ?= 0
2525
CIRCUITPY_ROTARYIO ?= 0
2626
CIRCUITPY_RTC ?= 0
27-
CIRCUITPY_USB_MIDI ?= 0
28-
CIRCUITPY_USB_HID ?= 0
29-
30-
USB_NUM_EP = 4
27+
USB_NUM_ENDPOINT_PAIRS = 4
3128
endif
3229

3330
ifeq ($(MCU_SERIES),H7)
@@ -44,10 +41,8 @@ ifeq ($(MCU_SERIES),H7)
4441
CIRCUITPY_PWMIO ?= 0
4542
CIRCUITPY_ROTARYIO ?= 0
4643
CIRCUITPY_RTC ?= 0
47-
CIRCUITPY_USB_HID ?= 0
48-
CIRCUITPY_USB_MIDI ?= 0
4944

50-
USB_NUM_EP = 9
45+
USB_NUM_ENDPOINT_PAIRS = 9
5146
endif
5247

5348
ifeq ($(MCU_SERIES),F7)
@@ -62,8 +57,6 @@ ifeq ($(MCU_SERIES),F7)
6257
CIRCUITPY_NVM ?= 0
6358
CIRCUITPY_ROTARYIO ?= 0
6459
CIRCUITPY_RTC ?= 0
65-
CIRCUITPY_USB_HID ?= 0
66-
CIRCUITPY_USB_MIDI ?= 0
6760

68-
USB_NUM_EP = 6
61+
USB_NUM_ENDPOINT_PAIRS = 6
6962
endif

py/circuitpy_mpconfig.mk

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,18 @@ CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP)
338338
CIRCUITPY_USB ?= 1
339339
CFLAGS += -DCIRCUITPY_USB=$(CIRCUITPY_USB)
340340

341-
# Compute this value once, so the shell command is not reinvoked many times.
342-
USB_NUM_EP_8_OR_GREATER := $(shell expr $(USB_NUM_EP) '>=' 8)
341+
# Compute these value once, so the shell command is not reinvoked many times.
342+
USB_NUM_ENDPOINT_PAIRS_5_OR_GREATER := $(shell expr $(USB_NUM_ENDPOINT_PAIRS) '>=' 5)
343+
USB_NUM_ENDPOINT_PAIRS_8_OR_GREATER := $(shell expr $(USB_NUM_ENDPOINT_PAIRS) '>=' 8)
344+
345+
# Some chips may not support the same number of IN or OUT endpoints as pairs.
346+
# For instance, the ESP32-S2 only supports 5 IN endpoints at once, even though
347+
# it has 7 endpoint pairs.
348+
USB_NUM_IN_ENDPOINTS ?= $(USB_NUM_ENDPOINT_PAIRS)
349+
CFLAGS += -DUSB_NUM_IN_ENDPOINTS=$(USB_NUM_IN_ENDPOINTS)
350+
351+
USB_NUM_OUT_ENDPOINTS ?= $(USB_NUM_ENDPOINT_PAIRS)
352+
CFLAGS += -DUSB_NUM_OUT_ENDPOINTS=$(USB_NUM_OUT_ENDPOINTS)
343353

344354
CIRCUITPY_USB_CDC ?= 1
345355
CFLAGS += -DCIRCUITPY_USB_CDC=$(CIRCUITPY_USB_CDC)
@@ -348,15 +358,16 @@ CFLAGS += -DCIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT=$(CIRCUITPY_USB_CDC_CONSOL
348358
CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT ?= 0
349359
CFLAGS += -DCIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT=$(CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT)
350360

361+
# HID is available by default, but is not turned on if there are fewer than 5 endpoints.
351362
CIRCUITPY_USB_HID ?= 1
352363
CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID)
353-
CIRCUITPY_USB_HID_ENABLED_DEFAULT ?= $(CIRCUITPY_USB_HID)
364+
CIRCUITPY_USB_HID_ENABLED_DEFAULT ?= $(USB_NUM_ENDPOINT_PAIRS_5_OR_GREATER)
354365
CFLAGS += -DCIRCUITPY_USB_HID_ENABLED_DEFAULT=$(CIRCUITPY_USB_HID_ENABLED_DEFAULT)
355366

356-
# MIDI is usually available if there are at least 8 endpoints.
357-
CIRCUITPY_USB_MIDI ?= $(USB_NUM_EP_8_OR_GREATER)
367+
# MIDI is available by default, but is not turned on if there are fewer than 8 endpoints.
368+
CIRCUITPY_USB_MIDI ?= 1
358369
CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI)
359-
CIRCUITPY_USB_MIDI_ENABLED_DEFAULT ?= $(CIRCUITPY_USB_MIDI)
370+
CIRCUITPY_USB_MIDI_ENABLED_DEFAULT ?= $(USB_NUM_ENDPOINT_PAIRS_8_OR_GREATER)
360371
CFLAGS += -DCIRCUITPY_USB_MIDI_ENABLED_DEFAULT=$(CIRCUITPY_USB_MIDI_ENABLED_DEFAULT)
361372

362373
CIRCUITPY_USB_MSC ?= 1
@@ -370,10 +381,10 @@ CFLAGS += -DCIRCUITPY_USB_MSC_ENABLED_DEFAULT=$(CIRCUITPY_USB_MSC_ENABLED_DEFAUL
370381
CIRCUITPY_USB_VENDOR ?= 0
371382
CFLAGS += -DCIRCUITPY_USB_VENDOR=$(CIRCUITPY_USB_VENDOR)
372383

373-
ifndef USB_NUM_EP
374-
$(error "USB_NUM_EP (number of USB endpoint pairs)must be defined")
384+
ifndef USB_NUM_ENDPOINT_PAIRS
385+
$(error "USB_NUM_ENDPOINT_PAIRS (number of USB endpoint pairs)must be defined")
375386
endif
376-
CFLAGS += -DUSB_NUM_EP=$(USB_NUM_EP)
387+
CFLAGS += -DUSB_NUM_ENDPOINT_PAIRS=$(USB_NUM_ENDPOINT_PAIRS)
377388

378389
# For debugging.
379390
CIRCUITPY_USTACK ?= 0

shared-bindings/storage/__init__.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,13 @@ MP_DEFINE_CONST_FUN_OBJ_0(storage_disable_usb_drive_obj, storage_disable_usb_dri
176176
//| """Enabled presenting ``CIRCUITPY`` as a USB mass storage device.
177177
//| By default, the device is enabled and ``CIRCUITPY`` is visible,
178178
//| so you do not normally need to call this function.
179-
//| Can be called in ``boot.py``, before USB is connected."""
179+
//| Can be called in ``boot.py``, before USB is connected.
180+
//|
181+
//| If you enable too many devices at once, you will run out of USB endpoints.
182+
//| The number of available endpoints varies by microcontroller.
183+
//| CircuitPython will go into safe mode after running boot.py to inform you if
184+
//| not enough endpoints are available.
185+
//| """
180186
//| ...
181187
//|
182188
STATIC mp_obj_t storage_enable_usb_drive(void) {

shared-bindings/usb_cdc/__init__.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_cdc_disable_obj, usb_cdc_disable);
8383
//| True to enable; False to disable. Enabled by default.
8484
//| :param data bool: Enable or disable the `data` USB serial device.
8585
//| True to enable; False to disable. *Disabled* by default."""
86+
//|
87+
//| If you enable too many devices at once, you will run out of USB endpoints.
88+
//| The number of available endpoints varies by microcontroller.
89+
//| CircuitPython will go into safe mode after running boot.py to inform you if
90+
//| not enough endpoints are available.
91+
//| """
8692
//| ...
8793
//|
8894
STATIC mp_obj_t usb_cdc_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {

shared-bindings/usb_hid/__init__.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@
3737
//|
3838

3939
//| devices: Tuple[Device, ...]
40-
//| """Tuple of all active HID device interfaces."""
40+
//| """Tuple of all active HID device interfaces.
41+
//| The default set of devices is ``Device.KEYBOARD, Device.MOUSE, Device.CONSUMER_CONTROL``,
42+
//| On boards where `usb_hid` is disabled by default, `devices` is an empty tuple.
43+
//| """
4144
//|
4245

4346
//| def disable() -> None:
4447
//| """Do not present any USB HID devices to the host computer.
4548
//| Can be called in ``boot.py``, before USB is connected."""
49+
//| The HID composite device is normally enabled by default,
50+
//| but on some boards with limited endpoints, including STM32F4,
51+
//| it is disabled by default. You must turn off another USB device such
52+
//| as `usb_cdc` or `storage` to free up endpoints for use by `usb_hid`.
53+
//|
4654
STATIC mp_obj_t usb_hid_disable(void) {
4755
if (!common_hal_usb_hid_disable()) {
4856
mp_raise_RuntimeError(translate("Cannot change USB devices now"));
@@ -59,6 +67,11 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable);
5967
//| If `devices` is empty, HID is disabled. The order of the ``Devices``
6068
//| may matter to the host. For instance, for MacOS, put the mouse device
6169
//| before any Gamepad or Digitizer HID device or else it will not work.
70+
//|
71+
//| If you enable too many devices at once, you will run out of USB endpoints.
72+
//| The number of available endpoints varies by microcontroller.
73+
//| CircuitPython will go into safe mode after running boot.py to inform you if
74+
//| not enough endpoints are available.
6275
//| """
6376
//| ...
6477
//|

0 commit comments

Comments
 (0)