Merge pull request #8242 from tannewt/check_host_init

Two small changes
This commit is contained in:
Jeff Epler 2023-08-03 14:38:44 -05:00 committed by GitHub
commit d57f3c888d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -1536,6 +1536,10 @@ msgstr ""
msgid "No timer available"
msgstr ""
#: shared-module/usb/core/Device.c
msgid "No usb host port initialized"
msgstr ""
#: ports/nrf/common-hal/_bleio/__init__.c
msgid "Nordic system firmware out of memory"
msgstr ""

View File

@ -211,7 +211,7 @@ SECTIONS
_ld_dtcm_data_flash_copy = LOADADDR(.dtcm_data);
_ld_dtcm_data_size = SIZEOF(.dtcm_data);
.dtcm_bss :
.dtcm_bss (NOLOAD) :
{
. = ALIGN(4);

View File

@ -51,6 +51,10 @@ void tuh_umount_cb(uint8_t dev_addr) {
STATIC xfer_result_t _xfer_result;
STATIC size_t _actual_len;
bool common_hal_usb_core_device_construct(usb_core_device_obj_t *self, uint8_t device_number) {
if (!tuh_inited()) {
mp_raise_RuntimeError(translate("No usb host port initialized"));
}
if (device_number == 0 || device_number > CFG_TUH_DEVICE_MAX + CFG_TUH_HUB) {
return false;
}