diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 626e5f381b..d0ca92b945 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -245,7 +245,6 @@ jobs: - "feather_mimxrt1011" - "feather_mimxrt1062" - "feather_nrf52840_express" - - "feather_radiofruit_zigbee" - "feather_stm32f405_express" - "fluff_m0" - "gemma_m0" diff --git a/WEBUSB_README.md b/WEBUSB_README.md index a257d5259c..8250941eb0 100644 --- a/WEBUSB_README.md +++ b/WEBUSB_README.md @@ -62,33 +62,4 @@ The tinyusb examples already include a "WebUSB serial" example. Basically, this feature was ported into CircuitPython by pulling code snippets out of the tinyusb example, and putting them where they best belonged in the CircuitPython codebase. -There was one complication: - -tinyusb uses C preprocessor macros to define things like USB descriptors. - -CircuitPython uses a Python program (tools/gen_usb_descriptor.py) to create USB descriptors (etc.) -using "helper objects" from another repo (adafruit_usb_descriptor). This means some of the example -code had to be adapted to the new programing model, and gen_usb_descriptor gained new command-line -options to control the generated code. - -The generated files go into the "build" directory, look for autogen_usb_descriptor.c and -genhdr/autogen_usb_descriptor.h. - - -Also worth pointing out - the re-use of the CDC connect/disconnect mechanism is not actually part -of the WebUSB standard, it's more of "common idiom". We make use of it here because we need to know -when we should be paying attention to the WebUSB serial interface, and when we should ignore it.. - -## Possible future work areas - -The current code uses the existing Python infrastructure to create the Interface descriptor, but -simply outputs the code snippets from the original tinyusb demo code to create the WEBUSB_URL, -BOS, and MS_OS_20 descriptors. I suppose additional work could be done to add these to the -adafruit_usb_descriptor project, and then gen_usb_descriptor.py could be modified to make use -of them. - -Program gen_usb_descriptor.py creates objects for most interface types, regardless of whether or -not they are actually enabled. This increases the size of a generated string table. I made the -new vendor-interface-related code not do this (because some of the ARM platforms would no longer -build), but I did not go back and do this for the other interface types (CDC, MIDI, HID, etc.) -Some FLASH savings are probably possible if this is done. +### TODO: This needs to be reworked for dynamic USB descriptors. diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py index e87769f06c..0590647e39 100644 --- a/docs/shared_bindings_matrix.py +++ b/docs/shared_bindings_matrix.py @@ -155,7 +155,8 @@ def get_settings_from_makefile(port_dir, board_name): settings = {} for line in contents.stdout.split('\n'): - m = re.match(r'^([A-Z][A-Z0-9_]*) = (.*)$', line) + # Handle both = and := definitions. + m = re.match(r'^([A-Z][A-Z0-9_]*) :?= (.*)$', line) if m: settings[m.group(1)] = m.group(2) diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 829ba0f0a2..de68b7d457 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 829ba0f0a2d8a63f7d0215c6c9fc821e14e52a93 +Subproject commit de68b7d4575151c1648c734559e59c2932965939 diff --git a/frozen/Adafruit_CircuitPython_SimpleMath b/frozen/Adafruit_CircuitPython_SimpleMath index cdf9944730..5f382650e6 160000 --- a/frozen/Adafruit_CircuitPython_SimpleMath +++ b/frozen/Adafruit_CircuitPython_SimpleMath @@ -1 +1 @@ -Subproject commit cdf99447307473080b2f2e95e7c3667247095ac0 +Subproject commit 5f382650e62e05cc72a67dbedce13d706d699621 diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 8d466f2f0f..9fbd425c0b 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -87,6 +87,10 @@ msgstr "" msgid "%q list must be a list" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be 1-255" +msgstr "" + #: shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" msgstr "" @@ -99,6 +103,10 @@ msgstr "" msgid "%q must be >= 1" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q must be None or 1-255" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" msgstr "" @@ -604,6 +612,11 @@ msgstr "" msgid "Can't set CCCD on local Characteristic" msgstr "" +#: shared-bindings/storage/__init__.c shared-bindings/usb_cdc/__init__.c +#: shared-bindings/usb_hid/__init__.c shared-bindings/usb_midi/__init__.c +msgid "Cannot change USB devices now" +msgstr "" + #: shared-bindings/_bleio/Adapter.c msgid "Cannot create a new Adapter; use _bleio.adapter;" msgstr "" @@ -646,7 +659,7 @@ msgid "Cannot record to a file" msgstr "" #: shared-module/storage/__init__.c -msgid "Cannot remount '/' when USB is active." +msgid "Cannot remount '/' when visible via USB." msgstr "" #: ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -1576,6 +1589,11 @@ msgstr "" msgid "No long integer support" msgstr "" +#: shared-module/usb_hid/__init__.c +#, c-format +msgid "No more than %d HID devices allowed" +msgstr "" + #: shared-bindings/wifi/Radio.c msgid "No network with that ssid" msgstr "" @@ -2184,6 +2202,14 @@ msgstr "" msgid "USB Error" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "USB devices need more endpoints than are available." +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "USB devices specify too many interface names." +msgstr "" + #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" msgstr "" @@ -3497,6 +3523,10 @@ msgstr "" msgid "no such attribute" msgstr "" +#: shared-bindings/usb_hid/__init__.c +msgid "non-Device in %q" +msgstr "" + #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" diff --git a/main.c b/main.c index 8b2458785d..c377dcf4f8 100755 --- a/main.c +++ b/main.c @@ -95,8 +95,8 @@ #include "shared-module/network/__init__.h" #endif -#if CIRCUITPY_USB_CDC -#include "shared-module/usb_cdc/__init__.h" +#if CIRCUITPY_USB_HID +#include "shared-module/usb_hid/__init__.h" #endif #if CIRCUITPY_WIFI @@ -299,6 +299,10 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { supervisor_allocation* heap = allocate_remaining_memory(); start_mp(heap); + #if CIRCUITPY_USB + usb_setup_with_vm(); + #endif + found_main = maybe_run_list(supported_filenames, &result); #if CIRCUITPY_FULL_BUILD if (!found_main){ @@ -500,11 +504,15 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { } #endif - // TODO(tannewt): Allocate temporary space to hold custom usb descriptors. filesystem_flush(); supervisor_allocation* heap = allocate_remaining_memory(); start_mp(heap); + #if CIRCUITPY_USB + // Set up default USB values after boot.py VM starts but before running boot.py. + usb_set_defaults(); + #endif + // TODO(tannewt): Re-add support for flashing boot error output. bool found_boot = maybe_run_list(boot_py_filenames, NULL); (void) found_boot; @@ -517,7 +525,27 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { boot_output_file = NULL; #endif + + #if CIRCUITPY_USB + + // Some data needs to be carried over from the USB settings in boot.py + // to the next VM, while the heap is still available. + // Its size can vary, so save it temporarily on the stack, + // and then when the heap goes away, copy it in into a + // storage_allocation. + + size_t size = usb_boot_py_data_size(); + uint8_t usb_boot_py_data[size]; + usb_get_boot_py_data(usb_boot_py_data, size); + #endif + cleanup_after_vm(heap); + + #if CIRCUITPY_USB + // Now give back the data we saved from the heap going away. + usb_return_boot_py_data(usb_boot_py_data, size); + #endif + } } @@ -527,6 +555,11 @@ STATIC int run_repl(void) { filesystem_flush(); supervisor_allocation* heap = allocate_remaining_memory(); start_mp(heap); + + #if CIRCUITPY_USB + usb_setup_with_vm(); + #endif + autoreload_suspend(); new_status_color(REPL_RUNNING); if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) { @@ -586,7 +619,14 @@ int __attribute__((used)) main(void) { run_boot_py(safe_mode); - // Start serial and HID after giving boot.py a chance to tweak behavior. + // Start USB after giving boot.py a chance to tweak behavior. + #if CIRCUITPY_USB + // Setup USB connection after heap is available. + // It needs the heap to build descriptors. + usb_init(); + #endif + + // Set up any other serial connection. serial_init(); #if CIRCUITPY_BLEIO @@ -640,6 +680,10 @@ void gc_collect(void) { common_hal_bleio_gc_collect(); #endif + #if CIRCUITPY_USB_HID + usb_hid_gc_collect(); + #endif + #if CIRCUITPY_WIFI common_hal_wifi_gc_collect(); #endif diff --git a/ports/atmel-samd/asf4_conf/samd21/hpl_usb_config.h b/ports/atmel-samd/asf4_conf/samd21/hpl_usb_config.h deleted file mode 100644 index d1bb42fe45..0000000000 --- a/ports/atmel-samd/asf4_conf/samd21/hpl_usb_config.h +++ /dev/null @@ -1,413 +0,0 @@ -/* Auto-generated config file hpl_usb_config.h */ -#ifndef HPL_USB_CONFIG_H -#define HPL_USB_CONFIG_H - -// CIRCUITPY: - -// Use 64-byte USB buffers for endpoint directions that are in use. They're set to 0 below otherwise. - -#include "genhdr/autogen_usb_descriptor.h" - -#if defined(USB_ENDPOINT_1_OUT_USED) && USB_ENDPOINT_1_OUT_USED -#define CONF_USB_EP1_CACHE 64 -#endif -#if defined(USB_ENDPOINT_1_IN_USED) && USB_ENDPOINT_1_IN_USED -#define CONF_USB_EP1_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_2_OUT_USED) && USB_ENDPOINT_2_OUT_USED -#define CONF_USB_EP2_CACHE 64 -#endif -#if defined(USB_ENDPOINT_2_IN_USED) && USB_ENDPOINT_2_IN_USED -#define CONF_USB_EP2_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_3_OUT_USED) && USB_ENDPOINT_3_OUT_USED -#define CONF_USB_EP3_CACHE 64 -#endif -#if defined(USB_ENDPOINT_3_IN_USED) && USB_ENDPOINT_3_IN_USED -#define CONF_USB_EP3_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_4_OUT_USED) && USB_ENDPOINT_4_OUT_USED -#define CONF_USB_EP4_CACHE 64 -#endif -#if defined(USB_ENDPOINT_4_IN_USED) && USB_ENDPOINT_4_IN_USED -#define CONF_USB_EP4_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_5_OUT_USED) && USB_ENDPOINT_5_OUT_USED -#define CONF_USB_EP5_CACHE 64 -#endif -#if defined(USB_ENDPOINT_5_IN_USED) && USB_ENDPOINT_5_IN_USED -#define CONF_USB_EP5_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_6_OUT_USED) && USB_ENDPOINT_6_OUT_USED -#define CONF_USB_EP6_CACHE 64 -#endif -#if defined(USB_ENDPOINT_6_IN_USED) && USB_ENDPOINT_6_IN_USED -#define CONF_USB_EP6_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_7_OUT_USED) && USB_ENDPOINT_7_OUT_USED -#define CONF_USB_EP7_CACHE 64 -#endif -#if defined(USB_ENDPOINT_7_IN_USED) && USB_ENDPOINT_7_IN_USED -#define CONF_USB_EP7_I_CACHE 64 -#endif - - -// <<< Use Configuration Wizard in Context Menu >>> - -#define CONF_USB_N_0 0 -#define CONF_USB_N_1 1 -#define CONF_USB_N_2 2 -#define CONF_USB_N_3 3 -#define CONF_USB_N_4 4 -#define CONF_USB_N_5 5 -#define CONF_USB_N_6 6 -#define CONF_USB_N_7 7 -#define CONF_USB_N_8 8 -#define CONF_USB_N_9 9 -#define CONF_USB_N_10 10 -#define CONF_USB_N_11 11 -#define CONF_USB_N_12 12 -#define CONF_USB_N_13 13 -#define CONF_USB_N_14 14 -#define CONF_USB_N_15 15 - -#define CONF_USB_D_EP_N_MAX (USB_EPT_NUM - 1) -#define CONF_USB_D_N_EP_MAX (CONF_USB_D_EP_N_MAX * 2 - 1) - -// USB Device HAL Configuration - -// Max number of endpoints supported -// Limits the number of endpoints (described by EP address) can be used in app. -// NOTE(tannewt): This not only limits the number of endpoints but also the -// addresses. In other words, even if you use endpoint 6 you need to set this to 11. -// 1 (EP0 only) -// 2 (EP0 + 1 endpoint) -// 3 (EP0 + 2 endpoints) -// 4 (EP0 + 3 endpoints) -// 5 (EP0 + 4 endpoints) -// 6 (EP0 + 5 endpoints) -// 7 (EP0 + 6 endpoints) -// 8 (EP0 + 7 endpoints) -// Max possible (by "Max Endpoint Number" config) -// usbd_num_ep_sp -#ifndef CONF_USB_D_NUM_EP_SP -#define CONF_USB_D_NUM_EP_SP CONF_USB_D_N_EP_MAX -#endif - -// - -// Max Endpoint Number supported -// Limits the max endpoint number. -// USB endpoint address is constructed by direction and endpoint number. Bit 8 of address set indicates the direction is IN. E.g., EP0x81 and EP0x01 have the same endpoint number, 1. -// Reduce the value according to specific device design, to cut-off memory usage. -// 0 (only EP0) -// 1 (EP 0x81 or 0x01) -// 2 (EP 0x82 or 0x02) -// 3 (EP 0x83 or 0x03) -// 4 (EP 0x84 or 0x04) -// 5 (EP 0x85 or 0x05) -// 6 (EP 0x86 or 0x06) -// 7 (EP 0x87 or 0x07) -// Max possible (by HW) -// The number of physical endpoints - 1 -// usbd_arch_max_ep_n -#ifndef CONF_USB_D_MAX_EP_N -#define CONF_USB_D_MAX_EP_N CONF_USB_D_EP_N_MAX -#endif - -// USB Speed Limit -// Limits the working speed of the device. -// Full speed -// Low Speed -// usbd_arch_speed -#ifndef CONF_USB_D_SPEED -#define CONF_USB_D_SPEED USB_SPEED_FS -#endif - -// Cache buffer size for EP0 -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// EP0 is default control endpoint, so cache must be used to be able to receive SETUP packet at any time. -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// usb_arch_ep0_cache -#ifndef CONF_USB_EP0_CACHE -#define CONF_USB_EP0_CACHE 64 -#endif - -// Cache configuration EP1 -// Cache buffer size for EP1 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep1_cache -#ifndef CONF_USB_EP1_CACHE -#define CONF_USB_EP1_CACHE 0 -#endif - -// Cache buffer size for EP1 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep1_I_CACHE -#ifndef CONF_USB_EP1_I_CACHE -#define CONF_USB_EP1_I_CACHE 0 -#endif -// - -// Cache configuration EP2 -// Cache buffer size for EP2 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep2_cache -#ifndef CONF_USB_EP2_CACHE -#define CONF_USB_EP2_CACHE 0 -#endif - -// Cache buffer size for EP2 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep2_I_CACHE -#ifndef CONF_USB_EP2_I_CACHE -#define CONF_USB_EP2_I_CACHE 0 -#endif -// - -// Cache configuration EP3 -// Cache buffer size for EP3 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep3_cache -#ifndef CONF_USB_EP3_CACHE -#define CONF_USB_EP3_CACHE 0 -#endif - -// Cache buffer size for EP3 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep3_I_CACHE -#ifndef CONF_USB_EP3_I_CACHE -#define CONF_USB_EP3_I_CACHE 0 -#endif -// - -// Cache configuration EP4 -// Cache buffer size for EP4 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep4_cache -#ifndef CONF_USB_EP4_CACHE -#define CONF_USB_EP4_CACHE 0 -#endif - -// Cache buffer size for EP4 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep4_I_CACHE -#ifndef CONF_USB_EP4_I_CACHE -#define CONF_USB_EP4_I_CACHE 0 -#endif -// - -// Cache configuration EP5 -// Cache buffer size for EP5 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep5_cache -#ifndef CONF_USB_EP5_CACHE -#define CONF_USB_EP5_CACHE 0 -#endif - -// Cache buffer size for EP5 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep5_I_CACHE -#ifndef CONF_USB_EP5_I_CACHE -#define CONF_USB_EP5_I_CACHE 0 -#endif -// - -// Cache configuration EP6 -// Cache buffer size for EP6 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep6_cache -#ifndef CONF_USB_EP6_CACHE -#define CONF_USB_EP6_CACHE 0 -#endif - -// Cache buffer size for EP6 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep6_I_CACHE -#ifndef CONF_USB_EP6_I_CACHE -#define CONF_USB_EP6_I_CACHE 0 -#endif -// - -// Cache configuration EP7 -// Cache buffer size for EP7 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep7_cache -#ifndef CONF_USB_EP7_CACHE -#define CONF_USB_EP7_CACHE 0 -#endif - -// Cache buffer size for EP7 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep7_I_CACHE -#ifndef CONF_USB_EP7_I_CACHE -#define CONF_USB_EP7_I_CACHE 0 -#endif -// - -// <<< end of configuration section >>> - -#endif // HPL_USB_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/samd21/usbd_config.h b/ports/atmel-samd/asf4_conf/samd21/usbd_config.h deleted file mode 100644 index b0f570b5e5..0000000000 --- a/ports/atmel-samd/asf4_conf/samd21/usbd_config.h +++ /dev/null @@ -1,850 +0,0 @@ -/* Auto-generated config file usbd_config.h */ -#ifndef USBD_CONFIG_H -#define USBD_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// ---- USB Device Stack Core Options ---- - -// High Speed Support -// Enable high speed specific descriptors support, e.g., DeviceQualifierDescriptor and OtherSpeedConfiguration Descriptor. -// High speed support require descriptors description array on start, for LS/FS and HS support in first and second place. -// usbd_hs_sp -#ifndef CONF_USBD_HS_SP -#define CONF_USBD_HS_SP 0 -#endif - -// ---- USB Device Stack Composite Options ---- - -// Enable String Descriptors -// usb_composite_str_en -#ifndef CONF_USB_COMPOSITE_STR_EN -#define CONF_USB_COMPOSITE_STR_EN 0 -#endif -// Language IDs -// Language IDs in c format, split by comma (E.g., 0x0409 ...) -// usb_composite_langid -#ifndef CONF_USB_COMPOSITE_LANGID -#define CONF_USB_COMPOSITE_LANGID "0x0409" -#endif - -#ifndef CONF_USB_COMPOSITE_LANGID_DESC -#define CONF_USB_COMPOSITE_LANGID_DESC -#endif -// - -// Composite Device Descriptor - -// bcdUSB -// <0x0200=> USB 2.0 version -// <0x0210=> USB 2.1 version -// usb_composite_bcdusb -#ifndef CONF_USB_COMPOSITE_BCDUSB -#define CONF_USB_COMPOSITE_BCDUSB 0x200 -#endif - -// bMaxPackeSize0 -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_bmaxpksz0 -#ifndef CONF_USB_COMPOSITE_BMAXPKSZ0 -#define CONF_USB_COMPOSITE_BMAXPKSZ0 0x40 -#endif - -// idVender <0x0000-0xFFFF> -// usb_composite_idvender -#ifndef CONF_USB_COMPOSITE_IDVENDER -#define CONF_USB_COMPOSITE_IDVENDER 0x3eb -#endif - -// idProduct <0x0000-0xFFFF> -// usb_composite_idproduct -#ifndef CONF_USB_COMPOSITE_IDPRODUCT -#define CONF_USB_COMPOSITE_IDPRODUCT 0x2421 -#endif - -// bcdDevice <0x0000-0xFFFF> -// usb_composite_bcddevice -#ifndef CONF_USB_COMPOSITE_BCDDEVICE -#define CONF_USB_COMPOSITE_BCDDEVICE 0x100 -#endif - -// Enable string descriptor of iManufact -// usb_composite_imanufact_en -#ifndef CONF_USB_COMPOSITE_IMANUFACT_EN -#define CONF_USB_COMPOSITE_IMANUFACT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT -#define CONF_USB_COMPOSITE_IMANUFACT (CONF_USB_COMPOSITE_IMANUFACT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN)) -#endif - -// Unicode string of iManufact -// usb_composite_imanufact_str -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR -#define CONF_USB_COMPOSITE_IMANUFACT_STR "Atmel" -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#define CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#endif - -// - -// Enable string descriptor of iProduct -// usb_composite_iproduct_en -#ifndef CONF_USB_COMPOSITE_IPRODUCT_EN -#define CONF_USB_COMPOSITE_IPRODUCT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT -#define CONF_USB_COMPOSITE_IPRODUCT \ - (CONF_USB_COMPOSITE_IPRODUCT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN)) -#endif - -// Unicode string of iProduct -// usb_composite_iproduct_str -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR -#define CONF_USB_COMPOSITE_IPRODUCT_STR "Composite Demo" -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#define CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#endif - -// - -// Enable string descriptor of iSerialNum -// usb_composite_iserialnum_en -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_EN -#define CONF_USB_COMPOSITE_ISERIALNUM_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM -#define CONF_USB_COMPOSITE_ISERIALNUM \ - (CONF_USB_COMPOSITE_ISERIALNUM_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN)) -#endif - -// Unicode string of iSerialNum -// usb_composite_iserialnum_str -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR -#define CONF_USB_COMPOSITE_ISERIALNUM_STR "123456789ABCDEF" -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#define CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#endif - -// - -// bNumConfigurations <0x01-0xFF> -// usb_composite_bnumconfig -#ifndef CONF_USB_COMPOSITE_BNUMCONFIG -#define CONF_USB_COMPOSITE_BNUMCONFIG 0x1 -#endif - -// - -// Composite Configuration Descriptor -// bConfigurationValue <0x01-0xFF> -// usb_composite_bconfigval -#ifndef CONF_USB_COMPOSITE_BCONFIGVAL -#define CONF_USB_COMPOSITE_BCONFIGVAL 0x1 -#endif -// Enable string descriptor of iConfig -// usb_composite_iconfig_en -#ifndef CONF_USB_COMPOSITE_ICONFIG_EN -#define CONF_USB_COMPOSITE_ICONFIG_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG -#define CONF_USB_COMPOSITE_ICONFIG \ - (CONF_USB_COMPOSITE_ICONFIG_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN \ - + CONF_USB_COMPOSITE_ICONFIG_EN)) -#endif - -// Unicode string of iConfig -// usb_composite_iconfig_str -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR -#define CONF_USB_COMPOSITE_ICONFIG_STR "" -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#define CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#endif - -// - -// bmAttributes -// <0x80=> Bus power supply, not support for remote wakeup -// <0xA0=> Bus power supply, support for remote wakeup -// <0xC0=> Self powered, not support for remote wakeup -// <0xE0=> Self powered, support for remote wakeup -// usb_composite_bmattri -#ifndef CONF_USB_COMPOSITE_BMATTRI -#define CONF_USB_COMPOSITE_BMATTRI 0x80 -#endif - -// bMaxPower <0x00-0xFF> -// usb_composite_bmaxpower -#ifndef CONF_USB_COMPOSITE_BMAXPOWER -#define CONF_USB_COMPOSITE_BMAXPOWER 0x32 -#endif -// - -// CDC ACM Support -// usb_composite_cdc_acm_support -#ifndef CONF_USB_COMPOSITE_CDC_ACM_EN -#define CONF_USB_COMPOSITE_CDC_ACM_EN 1 -#endif - -// CDC ACM Comm Interrupt IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR 0x82 -#endif - -// CDC ACM Comm Interrupt IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_comm_int_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_data_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR 0x81 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS 0x0200 -#endif - -// CDC ACM Data BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_cdc_acm_data_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR 0x1 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS 0x0200 -#endif - -// CDC ACM Echo Demo generation -// conf_usb_composite_cdc_echo_demo -// Invoke cdcdf_acm_demo_init(buf[wMaxPacketSize]) to enable the echo demo. -// Buf is packet buffer for data receive and echo back. -// The buffer is 4 byte aligned to support DMA. -#ifndef CONF_USB_COMPOSITE_CDC_ECHO_DEMO -#define CONF_USB_COMPOSITE_CDC_ECHO_DEMO 0 -#endif - -// - -// HID Mouse Support -// usb_composite_hid_mouse_support -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_EN -#define CONF_USB_COMPOSITE_HID_MOUSE_EN 0 -#endif - -// HID Mouse INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_mouse_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR 0x83 -#endif - -// HID Mouse INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_mouse_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ 0x8 -#endif - -// HID Mouse Move Demo generation -// conf_usb_composite_hid_mouse_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Button1 and button3 are the pins used for mouse moving left and right. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_DEMO -#define CONF_USB_COMPOSITE_HID_MOUSE_DEMO 0 -#endif - -// - -// HID Keyboard Support -// usb_composite_hid_keyboard_support -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_EN -#define CONF_USB_COMPOSITE_HID_KEYBOARD_EN 0 -#endif - -// HID Keyboard INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_keyboard_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR 0x84 -#endif - -// HID Keyboard INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ 0x8 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_keyboard_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR 0x2 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ 0x8 -#endif - -// HID Keyboard Caps Lock Demo generation -// conf_usb_composite_hid_keyboard_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Buffon2 is the pin used for keyboard CAPS LOCK simulation. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO -#define CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO 0 -#endif - -// - -// HID Generic Support -// usb_composite_hid_generic_support -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_EN -#define CONF_USB_COMPOSITE_HID_GENERIC_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN 53 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT \ - 0x06, 0xFF, 0xFF, 0x09, 0x01, 0xA1, 0x01, 0x09, 0x02, 0x09, 0x03, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, \ - 0x40, 0x81, 0x02, 0x09, 0x04, 0x09, 0x05, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x40, 0x91, 0x02, \ - 0x09, 0x06, 0x09, 0x07, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x04, 0xB1, 0x02, 0xC0 -#endif - -// HID Generic INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_generic_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR 0x85 -#endif - -// HID Generic INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_generic_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ 0x40 -#endif - -// HID Generic INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_generic_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR 0x3 -#endif - -// HID Generic INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_hid_generic_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ 0x40 -#endif - -// - -// MSC Support -// usb_composite_msc_support -#ifndef CONF_USB_COMPOSITE_MSC_EN -#define CONF_USB_COMPOSITE_MSC_EN 0 -#endif - -// MSC BULK Endpoints wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_msc_bulk_maxpksz -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ 0x0040 -#endif - -// MSC BULK Endpoints wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_msc_bulk_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS 0x0200 -#endif - -// MSC BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_msc_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR 0x86 -#endif - -// MSC BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_msc_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR 0x04 -#endif - -// Enable Demo code for Disk LUN handling -// usb_composite_msc_demo_en -#ifndef CONF_USB_COMPOSITE_MSC_LUN_DEMO -#define CONF_USB_COMPOSITE_MSC_LUN_DEMO 1 -#endif - -// Disk access cache/buffer of sectors if non-RAM disk (e.g., SD/MMC) enabled <1-64> -// conf_usb_msc_lun_buf_sectors -#ifndef CONF_USB_MSC_LUN_BUF_SECTORS -#define CONF_USB_MSC_LUN_BUF_SECTORS 4 -#endif - -// Enable Demo for RAM Disk -// conf_usb_msc_lun0_enable -#ifndef CONF_USB_MSC_LUN0_ENABLE -#define CONF_USB_MSC_LUN0_ENABLE 1 -#endif - -#ifndef CONF_USB_MSC_LUN0_TYPE -#define CONF_USB_MSC_LUN0_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun0_rmb -#ifndef CONF_USB_MSC_LUN0_RMB -#define CONF_USB_MSC_LUN0_RMB 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN0_ISO -#define CONF_USB_MSC_LUN0_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ECMA -#define CONF_USB_MSC_LUN0_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ANSI -#define CONF_USB_MSC_LUN0_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_REPO -#define CONF_USB_MSC_LUN0_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN0_FACTORY -#define CONF_USB_MSC_LUN0_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT -#define CONF_USB_MSC_LUN0_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT_VERSION -#define CONF_USB_MSC_LUN0_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// Windows will not show disk less than 20K, so 22K is used to reserve more RAM for APP -// conf_usb_msc_lun0_capacity - -#ifndef CONF_USB_MSC_LUN0_CAPACITY -#define CONF_USB_MSC_LUN0_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN0_BLOCK_SIZE -#define CONF_USB_MSC_LUN0_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN0_CAPACITY * 1024 / CONF_USB_MSC_LUN0_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for SD/MMC Disk -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_enable -#ifndef CONF_USB_MSC_LUN1_ENABLE -#define CONF_USB_MSC_LUN1_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN1_TYPE -#define CONF_USB_MSC_LUN1_TYPE 0x00 -#endif - -// The disk is removable -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_rmb -#ifndef CONF_USB_MSC_LUN1_RMB -#define CONF_USB_MSC_LUN1_RMB 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN1_ISO -#define CONF_USB_MSC_LUN1_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ECMA -#define CONF_USB_MSC_LUN1_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ANSI -#define CONF_USB_MSC_LUN1_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_REPO -#define CONF_USB_MSC_LUN1_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN1_FACTORY -#define CONF_USB_MSC_LUN1_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT -#define CONF_USB_MSC_LUN1_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT_VERSION -#define CONF_USB_MSC_LUN1_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_CAPACITY -#define CONF_USB_MSC_LUN1_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN1_BLOCK_SIZE -#define CONF_USB_MSC_LUN1_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN1_CAPACITY * 1024 / CONF_USB_MSC_LUN1_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 2 -// conf_usb_msc_lun2_enable -#ifndef CONF_USB_MSC_LUN2_ENABLE -#define CONF_USB_MSC_LUN2_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN2_TYPE -#define CONF_USB_MSC_LUN2_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun2_rmb -#ifndef CONF_USB_MSC_LUN2_RMB -#define CONF_USB_MSC_LUN2_RMB 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN2_ISO -#define CONF_USB_MSC_LUN2_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ECMA -#define CONF_USB_MSC_LUN2_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ANSI -#define CONF_USB_MSC_LUN2_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_REPO -#define CONF_USB_MSC_LUN2_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN2_FACTORY -#define CONF_USB_MSC_LUN2_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT -#define CONF_USB_MSC_LUN2_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT_VERSION -#define CONF_USB_MSC_LUN2_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun2_capacity - -#ifndef CONF_USB_MSC_LUN2_CAPACITY -#define CONF_USB_MSC_LUN2_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN2_BLOCK_SIZE -#define CONF_USB_MSC_LUN2_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN2_CAPACITY * 1024 / CONF_USB_MSC_LUN2_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 3 -// conf_usb_msc_lun3_enable -#ifndef CONF_USB_MSC_LUN3_ENABLE -#define CONF_USB_MSC_LUN3_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN3_TYPE -#define CONF_USB_MSC_LUN3_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun3_rmb -#ifndef CONF_USB_MSC_LUN3_RMB -#define CONF_USB_MSC_LUN3_RMB 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN3_ISO -#define CONF_USB_MSC_LUN3_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ECMA -#define CONF_USB_MSC_LUN3_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ANSI -#define CONF_USB_MSC_LUN3_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_REPO -#define CONF_USB_MSC_LUN3_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN3_FACTORY -#define CONF_USB_MSC_LUN3_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT -#define CONF_USB_MSC_LUN3_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT_VERSION -#define CONF_USB_MSC_LUN3_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun3_capacity - -#ifndef CONF_USB_MSC_LUN3_CAPACITY -#define CONF_USB_MSC_LUN3_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN3_BLOCK_SIZE -#define CONF_USB_MSC_LUN3_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN3_CAPACITY * 1024 / CONF_USB_MSC_LUN3_BLOCK_SIZE - 1) -#endif - -// - -// -// - -// <<< end of configuration section >>> - -#endif // USBD_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_usb_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_usb_config.h deleted file mode 100644 index d1bb42fe45..0000000000 --- a/ports/atmel-samd/asf4_conf/samd51/hpl_usb_config.h +++ /dev/null @@ -1,413 +0,0 @@ -/* Auto-generated config file hpl_usb_config.h */ -#ifndef HPL_USB_CONFIG_H -#define HPL_USB_CONFIG_H - -// CIRCUITPY: - -// Use 64-byte USB buffers for endpoint directions that are in use. They're set to 0 below otherwise. - -#include "genhdr/autogen_usb_descriptor.h" - -#if defined(USB_ENDPOINT_1_OUT_USED) && USB_ENDPOINT_1_OUT_USED -#define CONF_USB_EP1_CACHE 64 -#endif -#if defined(USB_ENDPOINT_1_IN_USED) && USB_ENDPOINT_1_IN_USED -#define CONF_USB_EP1_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_2_OUT_USED) && USB_ENDPOINT_2_OUT_USED -#define CONF_USB_EP2_CACHE 64 -#endif -#if defined(USB_ENDPOINT_2_IN_USED) && USB_ENDPOINT_2_IN_USED -#define CONF_USB_EP2_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_3_OUT_USED) && USB_ENDPOINT_3_OUT_USED -#define CONF_USB_EP3_CACHE 64 -#endif -#if defined(USB_ENDPOINT_3_IN_USED) && USB_ENDPOINT_3_IN_USED -#define CONF_USB_EP3_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_4_OUT_USED) && USB_ENDPOINT_4_OUT_USED -#define CONF_USB_EP4_CACHE 64 -#endif -#if defined(USB_ENDPOINT_4_IN_USED) && USB_ENDPOINT_4_IN_USED -#define CONF_USB_EP4_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_5_OUT_USED) && USB_ENDPOINT_5_OUT_USED -#define CONF_USB_EP5_CACHE 64 -#endif -#if defined(USB_ENDPOINT_5_IN_USED) && USB_ENDPOINT_5_IN_USED -#define CONF_USB_EP5_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_6_OUT_USED) && USB_ENDPOINT_6_OUT_USED -#define CONF_USB_EP6_CACHE 64 -#endif -#if defined(USB_ENDPOINT_6_IN_USED) && USB_ENDPOINT_6_IN_USED -#define CONF_USB_EP6_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_7_OUT_USED) && USB_ENDPOINT_7_OUT_USED -#define CONF_USB_EP7_CACHE 64 -#endif -#if defined(USB_ENDPOINT_7_IN_USED) && USB_ENDPOINT_7_IN_USED -#define CONF_USB_EP7_I_CACHE 64 -#endif - - -// <<< Use Configuration Wizard in Context Menu >>> - -#define CONF_USB_N_0 0 -#define CONF_USB_N_1 1 -#define CONF_USB_N_2 2 -#define CONF_USB_N_3 3 -#define CONF_USB_N_4 4 -#define CONF_USB_N_5 5 -#define CONF_USB_N_6 6 -#define CONF_USB_N_7 7 -#define CONF_USB_N_8 8 -#define CONF_USB_N_9 9 -#define CONF_USB_N_10 10 -#define CONF_USB_N_11 11 -#define CONF_USB_N_12 12 -#define CONF_USB_N_13 13 -#define CONF_USB_N_14 14 -#define CONF_USB_N_15 15 - -#define CONF_USB_D_EP_N_MAX (USB_EPT_NUM - 1) -#define CONF_USB_D_N_EP_MAX (CONF_USB_D_EP_N_MAX * 2 - 1) - -// USB Device HAL Configuration - -// Max number of endpoints supported -// Limits the number of endpoints (described by EP address) can be used in app. -// NOTE(tannewt): This not only limits the number of endpoints but also the -// addresses. In other words, even if you use endpoint 6 you need to set this to 11. -// 1 (EP0 only) -// 2 (EP0 + 1 endpoint) -// 3 (EP0 + 2 endpoints) -// 4 (EP0 + 3 endpoints) -// 5 (EP0 + 4 endpoints) -// 6 (EP0 + 5 endpoints) -// 7 (EP0 + 6 endpoints) -// 8 (EP0 + 7 endpoints) -// Max possible (by "Max Endpoint Number" config) -// usbd_num_ep_sp -#ifndef CONF_USB_D_NUM_EP_SP -#define CONF_USB_D_NUM_EP_SP CONF_USB_D_N_EP_MAX -#endif - -// - -// Max Endpoint Number supported -// Limits the max endpoint number. -// USB endpoint address is constructed by direction and endpoint number. Bit 8 of address set indicates the direction is IN. E.g., EP0x81 and EP0x01 have the same endpoint number, 1. -// Reduce the value according to specific device design, to cut-off memory usage. -// 0 (only EP0) -// 1 (EP 0x81 or 0x01) -// 2 (EP 0x82 or 0x02) -// 3 (EP 0x83 or 0x03) -// 4 (EP 0x84 or 0x04) -// 5 (EP 0x85 or 0x05) -// 6 (EP 0x86 or 0x06) -// 7 (EP 0x87 or 0x07) -// Max possible (by HW) -// The number of physical endpoints - 1 -// usbd_arch_max_ep_n -#ifndef CONF_USB_D_MAX_EP_N -#define CONF_USB_D_MAX_EP_N CONF_USB_D_EP_N_MAX -#endif - -// USB Speed Limit -// Limits the working speed of the device. -// Full speed -// Low Speed -// usbd_arch_speed -#ifndef CONF_USB_D_SPEED -#define CONF_USB_D_SPEED USB_SPEED_FS -#endif - -// Cache buffer size for EP0 -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// EP0 is default control endpoint, so cache must be used to be able to receive SETUP packet at any time. -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// usb_arch_ep0_cache -#ifndef CONF_USB_EP0_CACHE -#define CONF_USB_EP0_CACHE 64 -#endif - -// Cache configuration EP1 -// Cache buffer size for EP1 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep1_cache -#ifndef CONF_USB_EP1_CACHE -#define CONF_USB_EP1_CACHE 0 -#endif - -// Cache buffer size for EP1 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep1_I_CACHE -#ifndef CONF_USB_EP1_I_CACHE -#define CONF_USB_EP1_I_CACHE 0 -#endif -// - -// Cache configuration EP2 -// Cache buffer size for EP2 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep2_cache -#ifndef CONF_USB_EP2_CACHE -#define CONF_USB_EP2_CACHE 0 -#endif - -// Cache buffer size for EP2 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep2_I_CACHE -#ifndef CONF_USB_EP2_I_CACHE -#define CONF_USB_EP2_I_CACHE 0 -#endif -// - -// Cache configuration EP3 -// Cache buffer size for EP3 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep3_cache -#ifndef CONF_USB_EP3_CACHE -#define CONF_USB_EP3_CACHE 0 -#endif - -// Cache buffer size for EP3 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep3_I_CACHE -#ifndef CONF_USB_EP3_I_CACHE -#define CONF_USB_EP3_I_CACHE 0 -#endif -// - -// Cache configuration EP4 -// Cache buffer size for EP4 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep4_cache -#ifndef CONF_USB_EP4_CACHE -#define CONF_USB_EP4_CACHE 0 -#endif - -// Cache buffer size for EP4 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep4_I_CACHE -#ifndef CONF_USB_EP4_I_CACHE -#define CONF_USB_EP4_I_CACHE 0 -#endif -// - -// Cache configuration EP5 -// Cache buffer size for EP5 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep5_cache -#ifndef CONF_USB_EP5_CACHE -#define CONF_USB_EP5_CACHE 0 -#endif - -// Cache buffer size for EP5 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep5_I_CACHE -#ifndef CONF_USB_EP5_I_CACHE -#define CONF_USB_EP5_I_CACHE 0 -#endif -// - -// Cache configuration EP6 -// Cache buffer size for EP6 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep6_cache -#ifndef CONF_USB_EP6_CACHE -#define CONF_USB_EP6_CACHE 0 -#endif - -// Cache buffer size for EP6 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep6_I_CACHE -#ifndef CONF_USB_EP6_I_CACHE -#define CONF_USB_EP6_I_CACHE 0 -#endif -// - -// Cache configuration EP7 -// Cache buffer size for EP7 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep7_cache -#ifndef CONF_USB_EP7_CACHE -#define CONF_USB_EP7_CACHE 0 -#endif - -// Cache buffer size for EP7 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep7_I_CACHE -#ifndef CONF_USB_EP7_I_CACHE -#define CONF_USB_EP7_I_CACHE 0 -#endif -// - -// <<< end of configuration section >>> - -#endif // HPL_USB_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/samd51/usbd_config.h b/ports/atmel-samd/asf4_conf/samd51/usbd_config.h deleted file mode 100644 index b2629e1239..0000000000 --- a/ports/atmel-samd/asf4_conf/samd51/usbd_config.h +++ /dev/null @@ -1,850 +0,0 @@ -/* Auto-generated config file usbd_config.h */ -#ifndef USBD_CONFIG_H -#define USBD_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// ---- USB Device Stack Core Options ---- - -// High Speed Support -// Enable high speed specific descriptors support, e.g., DeviceQualifierDescriptor and OtherSpeedConfiguration Descriptor. -// High speed support require descriptors description array on start, for LS/FS and HS support in first and second place. -// usbd_hs_sp -#ifndef CONF_USBD_HS_SP -#define CONF_USBD_HS_SP 0 -#endif - -// ---- USB Device Stack Composite Options ---- - -// Enable String Descriptors -// usb_composite_str_en -#ifndef CONF_USB_COMPOSITE_STR_EN -#define CONF_USB_COMPOSITE_STR_EN 0 -#endif -// Language IDs -// Language IDs in c format, split by comma (E.g., 0x0409 ...) -// usb_composite_langid -#ifndef CONF_USB_COMPOSITE_LANGID -#define CONF_USB_COMPOSITE_LANGID "0x0409" -#endif - -#ifndef CONF_USB_COMPOSITE_LANGID_DESC -#define CONF_USB_COMPOSITE_LANGID_DESC -#endif -// - -// Composite Device Descriptor - -// bcdUSB -// <0x0200=> USB 2.0 version -// <0x0210=> USB 2.1 version -// usb_composite_bcdusb -#ifndef CONF_USB_COMPOSITE_BCDUSB -#define CONF_USB_COMPOSITE_BCDUSB 0x200 -#endif - -// bMaxPackeSize0 -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_bmaxpksz0 -#ifndef CONF_USB_COMPOSITE_BMAXPKSZ0 -#define CONF_USB_COMPOSITE_BMAXPKSZ0 0x40 -#endif - -// idVender <0x0000-0xFFFF> -// usb_composite_idvender -#ifndef CONF_USB_COMPOSITE_IDVENDER -#define CONF_USB_COMPOSITE_IDVENDER 0x3eb -#endif - -// idProduct <0x0000-0xFFFF> -// usb_composite_idproduct -#ifndef CONF_USB_COMPOSITE_IDPRODUCT -#define CONF_USB_COMPOSITE_IDPRODUCT 0x2421 -#endif - -// bcdDevice <0x0000-0xFFFF> -// usb_composite_bcddevice -#ifndef CONF_USB_COMPOSITE_BCDDEVICE -#define CONF_USB_COMPOSITE_BCDDEVICE 0x100 -#endif - -// Enable string descriptor of iManufact -// usb_composite_imanufact_en -#ifndef CONF_USB_COMPOSITE_IMANUFACT_EN -#define CONF_USB_COMPOSITE_IMANUFACT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT -#define CONF_USB_COMPOSITE_IMANUFACT (CONF_USB_COMPOSITE_IMANUFACT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN)) -#endif - -// Unicode string of iManufact -// usb_composite_imanufact_str -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR -#define CONF_USB_COMPOSITE_IMANUFACT_STR "Atmel" -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#define CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#endif - -// - -// Enable string descriptor of iProduct -// usb_composite_iproduct_en -#ifndef CONF_USB_COMPOSITE_IPRODUCT_EN -#define CONF_USB_COMPOSITE_IPRODUCT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT -#define CONF_USB_COMPOSITE_IPRODUCT \ - (CONF_USB_COMPOSITE_IPRODUCT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN)) -#endif - -// Unicode string of iProduct -// usb_composite_iproduct_str -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR -#define CONF_USB_COMPOSITE_IPRODUCT_STR "Composite Demo" -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#define CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#endif - -// - -// Enable string descriptor of iSerialNum -// usb_composite_iserialnum_en -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_EN -#define CONF_USB_COMPOSITE_ISERIALNUM_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM -#define CONF_USB_COMPOSITE_ISERIALNUM \ - (CONF_USB_COMPOSITE_ISERIALNUM_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN)) -#endif - -// Unicode string of iSerialNum -// usb_composite_iserialnum_str -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR -#define CONF_USB_COMPOSITE_ISERIALNUM_STR "123456789ABCDEF" -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#define CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#endif - -// - -// bNumConfigurations <0x01-0xFF> -// usb_composite_bnumconfig -#ifndef CONF_USB_COMPOSITE_BNUMCONFIG -#define CONF_USB_COMPOSITE_BNUMCONFIG 0x1 -#endif - -// - -// Composite Configuration Descriptor -// bConfigurationValue <0x01-0xFF> -// usb_composite_bconfigval -#ifndef CONF_USB_COMPOSITE_BCONFIGVAL -#define CONF_USB_COMPOSITE_BCONFIGVAL 0x1 -#endif -// Enable string descriptor of iConfig -// usb_composite_iconfig_en -#ifndef CONF_USB_COMPOSITE_ICONFIG_EN -#define CONF_USB_COMPOSITE_ICONFIG_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG -#define CONF_USB_COMPOSITE_ICONFIG \ - (CONF_USB_COMPOSITE_ICONFIG_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN \ - + CONF_USB_COMPOSITE_ICONFIG_EN)) -#endif - -// Unicode string of iConfig -// usb_composite_iconfig_str -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR -#define CONF_USB_COMPOSITE_ICONFIG_STR "" -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#define CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#endif - -// - -// bmAttributes -// <0x80=> Bus power supply, not support for remote wakeup -// <0xA0=> Bus power supply, support for remote wakeup -// <0xC0=> Self powered, not support for remote wakeup -// <0xE0=> Self powered, support for remote wakeup -// usb_composite_bmattri -#ifndef CONF_USB_COMPOSITE_BMATTRI -#define CONF_USB_COMPOSITE_BMATTRI 0x80 -#endif - -// bMaxPower <0x00-0xFF> -// usb_composite_bmaxpower -#ifndef CONF_USB_COMPOSITE_BMAXPOWER -#define CONF_USB_COMPOSITE_BMAXPOWER 0x32 -#endif -// - -// CDC ACM Support -// usb_composite_cdc_acm_support -#ifndef CONF_USB_COMPOSITE_CDC_ACM_EN -#define CONF_USB_COMPOSITE_CDC_ACM_EN 0 -#endif - -// CDC ACM Comm Interrupt IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR 0x82 -#endif - -// CDC ACM Comm Interrupt IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_comm_int_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_data_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR 0x81 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Data BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_cdc_acm_data_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR 0x1 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Echo Demo generation -// conf_usb_composite_cdc_echo_demo -// Invoke cdcdf_acm_demo_init(buf[wMaxPacketSize]) to enable the echo demo. -// Buf is packet buffer for data receive and echo back. -// The buffer is 4 byte aligned to support DMA. -#ifndef CONF_USB_COMPOSITE_CDC_ECHO_DEMO -#define CONF_USB_COMPOSITE_CDC_ECHO_DEMO 0 -#endif - -// - -// HID Mouse Support -// usb_composite_hid_mouse_support -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_EN -#define CONF_USB_COMPOSITE_HID_MOUSE_EN 0 -#endif - -// HID Mouse INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_mouse_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR 0x83 -#endif - -// HID Mouse INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_mouse_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ 0x8 -#endif - -// HID Mouse Move Demo generation -// conf_usb_composite_hid_mouse_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Button1 and button3 are the pins used for mouse moving left and right. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_DEMO -#define CONF_USB_COMPOSITE_HID_MOUSE_DEMO 0 -#endif - -// - -// HID Keyboard Support -// usb_composite_hid_keyboard_support -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_EN -#define CONF_USB_COMPOSITE_HID_KEYBOARD_EN 0 -#endif - -// HID Keyboard INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_keyboard_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR 0x84 -#endif - -// HID Keyboard INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ 0x8 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_keyboard_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR 0x2 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ 0x8 -#endif - -// HID Keyboard Caps Lock Demo generation -// conf_usb_composite_hid_keyboard_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Buffon2 is the pin used for keyboard CAPS LOCK simulation. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO -#define CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO 0 -#endif - -// - -// HID Generic Support -// usb_composite_hid_generic_support -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_EN -#define CONF_USB_COMPOSITE_HID_GENERIC_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN 53 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT \ - 0x06, 0xFF, 0xFF, 0x09, 0x01, 0xA1, 0x01, 0x09, 0x02, 0x09, 0x03, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, \ - 0x40, 0x81, 0x02, 0x09, 0x04, 0x09, 0x05, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x40, 0x91, 0x02, \ - 0x09, 0x06, 0x09, 0x07, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x04, 0xB1, 0x02, 0xC0 -#endif - -// HID Generic INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_generic_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR 0x85 -#endif - -// HID Generic INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_generic_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ 0x40 -#endif - -// HID Generic INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_generic_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR 0x3 -#endif - -// HID Generic INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_hid_generic_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ 0x40 -#endif - -// - -// MSC Support -// usb_composite_msc_support -#ifndef CONF_USB_COMPOSITE_MSC_EN -#define CONF_USB_COMPOSITE_MSC_EN 0 -#endif - -// MSC BULK Endpoints wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_msc_bulk_maxpksz -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ 0x40 -#endif - -// MSC BULK Endpoints wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_msc_bulk_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS 0x200 -#endif - -// MSC BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_msc_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR 0x86 -#endif - -// MSC BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_msc_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR 0x4 -#endif - -// Enable Demo code for Disk LUN handling -// usb_composite_msc_demo_en -#ifndef CONF_USB_COMPOSITE_MSC_LUN_DEMO -#define CONF_USB_COMPOSITE_MSC_LUN_DEMO 1 -#endif - -// Disk access cache/buffer of sectors if non-RAM disk (e.g., SD/MMC) enabled <1-64> -// conf_usb_msc_lun_buf_sectors -#ifndef CONF_USB_MSC_LUN_BUF_SECTORS -#define CONF_USB_MSC_LUN_BUF_SECTORS 4 -#endif - -// Enable Demo for RAM Disk -// conf_usb_msc_lun0_enable -#ifndef CONF_USB_MSC_LUN0_ENABLE -#define CONF_USB_MSC_LUN0_ENABLE 1 -#endif - -#ifndef CONF_USB_MSC_LUN0_TYPE -#define CONF_USB_MSC_LUN0_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun0_rmb -#ifndef CONF_USB_MSC_LUN0_RMB -#define CONF_USB_MSC_LUN0_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN0_ISO -#define CONF_USB_MSC_LUN0_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ECMA -#define CONF_USB_MSC_LUN0_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ANSI -#define CONF_USB_MSC_LUN0_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_REPO -#define CONF_USB_MSC_LUN0_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN0_FACTORY -#define CONF_USB_MSC_LUN0_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT -#define CONF_USB_MSC_LUN0_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT_VERSION -#define CONF_USB_MSC_LUN0_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// Windows will not show disk less than 20K, so 22K is used to reserve more RAM for APP -// conf_usb_msc_lun0_capacity - -#ifndef CONF_USB_MSC_LUN0_CAPACITY -#define CONF_USB_MSC_LUN0_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN0_BLOCK_SIZE -#define CONF_USB_MSC_LUN0_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN0_CAPACITY * 1024 / CONF_USB_MSC_LUN0_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for SD/MMC Disk -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_enable -#ifndef CONF_USB_MSC_LUN1_ENABLE -#define CONF_USB_MSC_LUN1_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN1_TYPE -#define CONF_USB_MSC_LUN1_TYPE 0x00 -#endif - -// The disk is removable -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_rmb -#ifndef CONF_USB_MSC_LUN1_RMB -#define CONF_USB_MSC_LUN1_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN1_ISO -#define CONF_USB_MSC_LUN1_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ECMA -#define CONF_USB_MSC_LUN1_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ANSI -#define CONF_USB_MSC_LUN1_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_REPO -#define CONF_USB_MSC_LUN1_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN1_FACTORY -#define CONF_USB_MSC_LUN1_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT -#define CONF_USB_MSC_LUN1_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT_VERSION -#define CONF_USB_MSC_LUN1_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_CAPACITY -#define CONF_USB_MSC_LUN1_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN1_BLOCK_SIZE -#define CONF_USB_MSC_LUN1_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN1_CAPACITY * 1024 / CONF_USB_MSC_LUN1_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 2 -// conf_usb_msc_lun2_enable -#ifndef CONF_USB_MSC_LUN2_ENABLE -#define CONF_USB_MSC_LUN2_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN2_TYPE -#define CONF_USB_MSC_LUN2_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun2_rmb -#ifndef CONF_USB_MSC_LUN2_RMB -#define CONF_USB_MSC_LUN2_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN2_ISO -#define CONF_USB_MSC_LUN2_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ECMA -#define CONF_USB_MSC_LUN2_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ANSI -#define CONF_USB_MSC_LUN2_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_REPO -#define CONF_USB_MSC_LUN2_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN2_FACTORY -#define CONF_USB_MSC_LUN2_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT -#define CONF_USB_MSC_LUN2_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT_VERSION -#define CONF_USB_MSC_LUN2_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun2_capacity - -#ifndef CONF_USB_MSC_LUN2_CAPACITY -#define CONF_USB_MSC_LUN2_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN2_BLOCK_SIZE -#define CONF_USB_MSC_LUN2_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN2_CAPACITY * 1024 / CONF_USB_MSC_LUN2_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 3 -// conf_usb_msc_lun3_enable -#ifndef CONF_USB_MSC_LUN3_ENABLE -#define CONF_USB_MSC_LUN3_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN3_TYPE -#define CONF_USB_MSC_LUN3_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun3_rmb -#ifndef CONF_USB_MSC_LUN3_RMB -#define CONF_USB_MSC_LUN3_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN3_ISO -#define CONF_USB_MSC_LUN3_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ECMA -#define CONF_USB_MSC_LUN3_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ANSI -#define CONF_USB_MSC_LUN3_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_REPO -#define CONF_USB_MSC_LUN3_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN3_FACTORY -#define CONF_USB_MSC_LUN3_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT -#define CONF_USB_MSC_LUN3_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT_VERSION -#define CONF_USB_MSC_LUN3_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun3_capacity - -#ifndef CONF_USB_MSC_LUN3_CAPACITY -#define CONF_USB_MSC_LUN3_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN3_BLOCK_SIZE -#define CONF_USB_MSC_LUN3_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN3_CAPACITY * 1024 / CONF_USB_MSC_LUN3_BLOCK_SIZE - 1) -#endif - -// - -// -// - -// <<< end of configuration section >>> - -#endif // USBD_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/same51/hpl_usb_config.h b/ports/atmel-samd/asf4_conf/same51/hpl_usb_config.h deleted file mode 100644 index d1bb42fe45..0000000000 --- a/ports/atmel-samd/asf4_conf/same51/hpl_usb_config.h +++ /dev/null @@ -1,413 +0,0 @@ -/* Auto-generated config file hpl_usb_config.h */ -#ifndef HPL_USB_CONFIG_H -#define HPL_USB_CONFIG_H - -// CIRCUITPY: - -// Use 64-byte USB buffers for endpoint directions that are in use. They're set to 0 below otherwise. - -#include "genhdr/autogen_usb_descriptor.h" - -#if defined(USB_ENDPOINT_1_OUT_USED) && USB_ENDPOINT_1_OUT_USED -#define CONF_USB_EP1_CACHE 64 -#endif -#if defined(USB_ENDPOINT_1_IN_USED) && USB_ENDPOINT_1_IN_USED -#define CONF_USB_EP1_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_2_OUT_USED) && USB_ENDPOINT_2_OUT_USED -#define CONF_USB_EP2_CACHE 64 -#endif -#if defined(USB_ENDPOINT_2_IN_USED) && USB_ENDPOINT_2_IN_USED -#define CONF_USB_EP2_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_3_OUT_USED) && USB_ENDPOINT_3_OUT_USED -#define CONF_USB_EP3_CACHE 64 -#endif -#if defined(USB_ENDPOINT_3_IN_USED) && USB_ENDPOINT_3_IN_USED -#define CONF_USB_EP3_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_4_OUT_USED) && USB_ENDPOINT_4_OUT_USED -#define CONF_USB_EP4_CACHE 64 -#endif -#if defined(USB_ENDPOINT_4_IN_USED) && USB_ENDPOINT_4_IN_USED -#define CONF_USB_EP4_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_5_OUT_USED) && USB_ENDPOINT_5_OUT_USED -#define CONF_USB_EP5_CACHE 64 -#endif -#if defined(USB_ENDPOINT_5_IN_USED) && USB_ENDPOINT_5_IN_USED -#define CONF_USB_EP5_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_6_OUT_USED) && USB_ENDPOINT_6_OUT_USED -#define CONF_USB_EP6_CACHE 64 -#endif -#if defined(USB_ENDPOINT_6_IN_USED) && USB_ENDPOINT_6_IN_USED -#define CONF_USB_EP6_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_7_OUT_USED) && USB_ENDPOINT_7_OUT_USED -#define CONF_USB_EP7_CACHE 64 -#endif -#if defined(USB_ENDPOINT_7_IN_USED) && USB_ENDPOINT_7_IN_USED -#define CONF_USB_EP7_I_CACHE 64 -#endif - - -// <<< Use Configuration Wizard in Context Menu >>> - -#define CONF_USB_N_0 0 -#define CONF_USB_N_1 1 -#define CONF_USB_N_2 2 -#define CONF_USB_N_3 3 -#define CONF_USB_N_4 4 -#define CONF_USB_N_5 5 -#define CONF_USB_N_6 6 -#define CONF_USB_N_7 7 -#define CONF_USB_N_8 8 -#define CONF_USB_N_9 9 -#define CONF_USB_N_10 10 -#define CONF_USB_N_11 11 -#define CONF_USB_N_12 12 -#define CONF_USB_N_13 13 -#define CONF_USB_N_14 14 -#define CONF_USB_N_15 15 - -#define CONF_USB_D_EP_N_MAX (USB_EPT_NUM - 1) -#define CONF_USB_D_N_EP_MAX (CONF_USB_D_EP_N_MAX * 2 - 1) - -// USB Device HAL Configuration - -// Max number of endpoints supported -// Limits the number of endpoints (described by EP address) can be used in app. -// NOTE(tannewt): This not only limits the number of endpoints but also the -// addresses. In other words, even if you use endpoint 6 you need to set this to 11. -// 1 (EP0 only) -// 2 (EP0 + 1 endpoint) -// 3 (EP0 + 2 endpoints) -// 4 (EP0 + 3 endpoints) -// 5 (EP0 + 4 endpoints) -// 6 (EP0 + 5 endpoints) -// 7 (EP0 + 6 endpoints) -// 8 (EP0 + 7 endpoints) -// Max possible (by "Max Endpoint Number" config) -// usbd_num_ep_sp -#ifndef CONF_USB_D_NUM_EP_SP -#define CONF_USB_D_NUM_EP_SP CONF_USB_D_N_EP_MAX -#endif - -// - -// Max Endpoint Number supported -// Limits the max endpoint number. -// USB endpoint address is constructed by direction and endpoint number. Bit 8 of address set indicates the direction is IN. E.g., EP0x81 and EP0x01 have the same endpoint number, 1. -// Reduce the value according to specific device design, to cut-off memory usage. -// 0 (only EP0) -// 1 (EP 0x81 or 0x01) -// 2 (EP 0x82 or 0x02) -// 3 (EP 0x83 or 0x03) -// 4 (EP 0x84 or 0x04) -// 5 (EP 0x85 or 0x05) -// 6 (EP 0x86 or 0x06) -// 7 (EP 0x87 or 0x07) -// Max possible (by HW) -// The number of physical endpoints - 1 -// usbd_arch_max_ep_n -#ifndef CONF_USB_D_MAX_EP_N -#define CONF_USB_D_MAX_EP_N CONF_USB_D_EP_N_MAX -#endif - -// USB Speed Limit -// Limits the working speed of the device. -// Full speed -// Low Speed -// usbd_arch_speed -#ifndef CONF_USB_D_SPEED -#define CONF_USB_D_SPEED USB_SPEED_FS -#endif - -// Cache buffer size for EP0 -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// EP0 is default control endpoint, so cache must be used to be able to receive SETUP packet at any time. -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// usb_arch_ep0_cache -#ifndef CONF_USB_EP0_CACHE -#define CONF_USB_EP0_CACHE 64 -#endif - -// Cache configuration EP1 -// Cache buffer size for EP1 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep1_cache -#ifndef CONF_USB_EP1_CACHE -#define CONF_USB_EP1_CACHE 0 -#endif - -// Cache buffer size for EP1 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep1_I_CACHE -#ifndef CONF_USB_EP1_I_CACHE -#define CONF_USB_EP1_I_CACHE 0 -#endif -// - -// Cache configuration EP2 -// Cache buffer size for EP2 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep2_cache -#ifndef CONF_USB_EP2_CACHE -#define CONF_USB_EP2_CACHE 0 -#endif - -// Cache buffer size for EP2 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep2_I_CACHE -#ifndef CONF_USB_EP2_I_CACHE -#define CONF_USB_EP2_I_CACHE 0 -#endif -// - -// Cache configuration EP3 -// Cache buffer size for EP3 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep3_cache -#ifndef CONF_USB_EP3_CACHE -#define CONF_USB_EP3_CACHE 0 -#endif - -// Cache buffer size for EP3 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep3_I_CACHE -#ifndef CONF_USB_EP3_I_CACHE -#define CONF_USB_EP3_I_CACHE 0 -#endif -// - -// Cache configuration EP4 -// Cache buffer size for EP4 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep4_cache -#ifndef CONF_USB_EP4_CACHE -#define CONF_USB_EP4_CACHE 0 -#endif - -// Cache buffer size for EP4 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep4_I_CACHE -#ifndef CONF_USB_EP4_I_CACHE -#define CONF_USB_EP4_I_CACHE 0 -#endif -// - -// Cache configuration EP5 -// Cache buffer size for EP5 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep5_cache -#ifndef CONF_USB_EP5_CACHE -#define CONF_USB_EP5_CACHE 0 -#endif - -// Cache buffer size for EP5 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep5_I_CACHE -#ifndef CONF_USB_EP5_I_CACHE -#define CONF_USB_EP5_I_CACHE 0 -#endif -// - -// Cache configuration EP6 -// Cache buffer size for EP6 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep6_cache -#ifndef CONF_USB_EP6_CACHE -#define CONF_USB_EP6_CACHE 0 -#endif - -// Cache buffer size for EP6 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep6_I_CACHE -#ifndef CONF_USB_EP6_I_CACHE -#define CONF_USB_EP6_I_CACHE 0 -#endif -// - -// Cache configuration EP7 -// Cache buffer size for EP7 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep7_cache -#ifndef CONF_USB_EP7_CACHE -#define CONF_USB_EP7_CACHE 0 -#endif - -// Cache buffer size for EP7 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep7_I_CACHE -#ifndef CONF_USB_EP7_I_CACHE -#define CONF_USB_EP7_I_CACHE 0 -#endif -// - -// <<< end of configuration section >>> - -#endif // HPL_USB_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/same51/usbd_config.h b/ports/atmel-samd/asf4_conf/same51/usbd_config.h deleted file mode 100644 index b2629e1239..0000000000 --- a/ports/atmel-samd/asf4_conf/same51/usbd_config.h +++ /dev/null @@ -1,850 +0,0 @@ -/* Auto-generated config file usbd_config.h */ -#ifndef USBD_CONFIG_H -#define USBD_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// ---- USB Device Stack Core Options ---- - -// High Speed Support -// Enable high speed specific descriptors support, e.g., DeviceQualifierDescriptor and OtherSpeedConfiguration Descriptor. -// High speed support require descriptors description array on start, for LS/FS and HS support in first and second place. -// usbd_hs_sp -#ifndef CONF_USBD_HS_SP -#define CONF_USBD_HS_SP 0 -#endif - -// ---- USB Device Stack Composite Options ---- - -// Enable String Descriptors -// usb_composite_str_en -#ifndef CONF_USB_COMPOSITE_STR_EN -#define CONF_USB_COMPOSITE_STR_EN 0 -#endif -// Language IDs -// Language IDs in c format, split by comma (E.g., 0x0409 ...) -// usb_composite_langid -#ifndef CONF_USB_COMPOSITE_LANGID -#define CONF_USB_COMPOSITE_LANGID "0x0409" -#endif - -#ifndef CONF_USB_COMPOSITE_LANGID_DESC -#define CONF_USB_COMPOSITE_LANGID_DESC -#endif -// - -// Composite Device Descriptor - -// bcdUSB -// <0x0200=> USB 2.0 version -// <0x0210=> USB 2.1 version -// usb_composite_bcdusb -#ifndef CONF_USB_COMPOSITE_BCDUSB -#define CONF_USB_COMPOSITE_BCDUSB 0x200 -#endif - -// bMaxPackeSize0 -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_bmaxpksz0 -#ifndef CONF_USB_COMPOSITE_BMAXPKSZ0 -#define CONF_USB_COMPOSITE_BMAXPKSZ0 0x40 -#endif - -// idVender <0x0000-0xFFFF> -// usb_composite_idvender -#ifndef CONF_USB_COMPOSITE_IDVENDER -#define CONF_USB_COMPOSITE_IDVENDER 0x3eb -#endif - -// idProduct <0x0000-0xFFFF> -// usb_composite_idproduct -#ifndef CONF_USB_COMPOSITE_IDPRODUCT -#define CONF_USB_COMPOSITE_IDPRODUCT 0x2421 -#endif - -// bcdDevice <0x0000-0xFFFF> -// usb_composite_bcddevice -#ifndef CONF_USB_COMPOSITE_BCDDEVICE -#define CONF_USB_COMPOSITE_BCDDEVICE 0x100 -#endif - -// Enable string descriptor of iManufact -// usb_composite_imanufact_en -#ifndef CONF_USB_COMPOSITE_IMANUFACT_EN -#define CONF_USB_COMPOSITE_IMANUFACT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT -#define CONF_USB_COMPOSITE_IMANUFACT (CONF_USB_COMPOSITE_IMANUFACT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN)) -#endif - -// Unicode string of iManufact -// usb_composite_imanufact_str -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR -#define CONF_USB_COMPOSITE_IMANUFACT_STR "Atmel" -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#define CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#endif - -// - -// Enable string descriptor of iProduct -// usb_composite_iproduct_en -#ifndef CONF_USB_COMPOSITE_IPRODUCT_EN -#define CONF_USB_COMPOSITE_IPRODUCT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT -#define CONF_USB_COMPOSITE_IPRODUCT \ - (CONF_USB_COMPOSITE_IPRODUCT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN)) -#endif - -// Unicode string of iProduct -// usb_composite_iproduct_str -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR -#define CONF_USB_COMPOSITE_IPRODUCT_STR "Composite Demo" -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#define CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#endif - -// - -// Enable string descriptor of iSerialNum -// usb_composite_iserialnum_en -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_EN -#define CONF_USB_COMPOSITE_ISERIALNUM_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM -#define CONF_USB_COMPOSITE_ISERIALNUM \ - (CONF_USB_COMPOSITE_ISERIALNUM_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN)) -#endif - -// Unicode string of iSerialNum -// usb_composite_iserialnum_str -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR -#define CONF_USB_COMPOSITE_ISERIALNUM_STR "123456789ABCDEF" -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#define CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#endif - -// - -// bNumConfigurations <0x01-0xFF> -// usb_composite_bnumconfig -#ifndef CONF_USB_COMPOSITE_BNUMCONFIG -#define CONF_USB_COMPOSITE_BNUMCONFIG 0x1 -#endif - -// - -// Composite Configuration Descriptor -// bConfigurationValue <0x01-0xFF> -// usb_composite_bconfigval -#ifndef CONF_USB_COMPOSITE_BCONFIGVAL -#define CONF_USB_COMPOSITE_BCONFIGVAL 0x1 -#endif -// Enable string descriptor of iConfig -// usb_composite_iconfig_en -#ifndef CONF_USB_COMPOSITE_ICONFIG_EN -#define CONF_USB_COMPOSITE_ICONFIG_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG -#define CONF_USB_COMPOSITE_ICONFIG \ - (CONF_USB_COMPOSITE_ICONFIG_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN \ - + CONF_USB_COMPOSITE_ICONFIG_EN)) -#endif - -// Unicode string of iConfig -// usb_composite_iconfig_str -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR -#define CONF_USB_COMPOSITE_ICONFIG_STR "" -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#define CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#endif - -// - -// bmAttributes -// <0x80=> Bus power supply, not support for remote wakeup -// <0xA0=> Bus power supply, support for remote wakeup -// <0xC0=> Self powered, not support for remote wakeup -// <0xE0=> Self powered, support for remote wakeup -// usb_composite_bmattri -#ifndef CONF_USB_COMPOSITE_BMATTRI -#define CONF_USB_COMPOSITE_BMATTRI 0x80 -#endif - -// bMaxPower <0x00-0xFF> -// usb_composite_bmaxpower -#ifndef CONF_USB_COMPOSITE_BMAXPOWER -#define CONF_USB_COMPOSITE_BMAXPOWER 0x32 -#endif -// - -// CDC ACM Support -// usb_composite_cdc_acm_support -#ifndef CONF_USB_COMPOSITE_CDC_ACM_EN -#define CONF_USB_COMPOSITE_CDC_ACM_EN 0 -#endif - -// CDC ACM Comm Interrupt IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR 0x82 -#endif - -// CDC ACM Comm Interrupt IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_comm_int_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_data_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR 0x81 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Data BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_cdc_acm_data_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR 0x1 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Echo Demo generation -// conf_usb_composite_cdc_echo_demo -// Invoke cdcdf_acm_demo_init(buf[wMaxPacketSize]) to enable the echo demo. -// Buf is packet buffer for data receive and echo back. -// The buffer is 4 byte aligned to support DMA. -#ifndef CONF_USB_COMPOSITE_CDC_ECHO_DEMO -#define CONF_USB_COMPOSITE_CDC_ECHO_DEMO 0 -#endif - -// - -// HID Mouse Support -// usb_composite_hid_mouse_support -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_EN -#define CONF_USB_COMPOSITE_HID_MOUSE_EN 0 -#endif - -// HID Mouse INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_mouse_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR 0x83 -#endif - -// HID Mouse INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_mouse_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ 0x8 -#endif - -// HID Mouse Move Demo generation -// conf_usb_composite_hid_mouse_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Button1 and button3 are the pins used for mouse moving left and right. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_DEMO -#define CONF_USB_COMPOSITE_HID_MOUSE_DEMO 0 -#endif - -// - -// HID Keyboard Support -// usb_composite_hid_keyboard_support -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_EN -#define CONF_USB_COMPOSITE_HID_KEYBOARD_EN 0 -#endif - -// HID Keyboard INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_keyboard_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR 0x84 -#endif - -// HID Keyboard INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ 0x8 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_keyboard_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR 0x2 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ 0x8 -#endif - -// HID Keyboard Caps Lock Demo generation -// conf_usb_composite_hid_keyboard_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Buffon2 is the pin used for keyboard CAPS LOCK simulation. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO -#define CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO 0 -#endif - -// - -// HID Generic Support -// usb_composite_hid_generic_support -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_EN -#define CONF_USB_COMPOSITE_HID_GENERIC_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN 53 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT \ - 0x06, 0xFF, 0xFF, 0x09, 0x01, 0xA1, 0x01, 0x09, 0x02, 0x09, 0x03, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, \ - 0x40, 0x81, 0x02, 0x09, 0x04, 0x09, 0x05, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x40, 0x91, 0x02, \ - 0x09, 0x06, 0x09, 0x07, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x04, 0xB1, 0x02, 0xC0 -#endif - -// HID Generic INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_generic_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR 0x85 -#endif - -// HID Generic INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_generic_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ 0x40 -#endif - -// HID Generic INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_generic_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR 0x3 -#endif - -// HID Generic INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_hid_generic_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ 0x40 -#endif - -// - -// MSC Support -// usb_composite_msc_support -#ifndef CONF_USB_COMPOSITE_MSC_EN -#define CONF_USB_COMPOSITE_MSC_EN 0 -#endif - -// MSC BULK Endpoints wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_msc_bulk_maxpksz -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ 0x40 -#endif - -// MSC BULK Endpoints wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_msc_bulk_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS 0x200 -#endif - -// MSC BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_msc_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR 0x86 -#endif - -// MSC BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_msc_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR 0x4 -#endif - -// Enable Demo code for Disk LUN handling -// usb_composite_msc_demo_en -#ifndef CONF_USB_COMPOSITE_MSC_LUN_DEMO -#define CONF_USB_COMPOSITE_MSC_LUN_DEMO 1 -#endif - -// Disk access cache/buffer of sectors if non-RAM disk (e.g., SD/MMC) enabled <1-64> -// conf_usb_msc_lun_buf_sectors -#ifndef CONF_USB_MSC_LUN_BUF_SECTORS -#define CONF_USB_MSC_LUN_BUF_SECTORS 4 -#endif - -// Enable Demo for RAM Disk -// conf_usb_msc_lun0_enable -#ifndef CONF_USB_MSC_LUN0_ENABLE -#define CONF_USB_MSC_LUN0_ENABLE 1 -#endif - -#ifndef CONF_USB_MSC_LUN0_TYPE -#define CONF_USB_MSC_LUN0_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun0_rmb -#ifndef CONF_USB_MSC_LUN0_RMB -#define CONF_USB_MSC_LUN0_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN0_ISO -#define CONF_USB_MSC_LUN0_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ECMA -#define CONF_USB_MSC_LUN0_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ANSI -#define CONF_USB_MSC_LUN0_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_REPO -#define CONF_USB_MSC_LUN0_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN0_FACTORY -#define CONF_USB_MSC_LUN0_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT -#define CONF_USB_MSC_LUN0_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT_VERSION -#define CONF_USB_MSC_LUN0_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// Windows will not show disk less than 20K, so 22K is used to reserve more RAM for APP -// conf_usb_msc_lun0_capacity - -#ifndef CONF_USB_MSC_LUN0_CAPACITY -#define CONF_USB_MSC_LUN0_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN0_BLOCK_SIZE -#define CONF_USB_MSC_LUN0_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN0_CAPACITY * 1024 / CONF_USB_MSC_LUN0_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for SD/MMC Disk -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_enable -#ifndef CONF_USB_MSC_LUN1_ENABLE -#define CONF_USB_MSC_LUN1_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN1_TYPE -#define CONF_USB_MSC_LUN1_TYPE 0x00 -#endif - -// The disk is removable -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_rmb -#ifndef CONF_USB_MSC_LUN1_RMB -#define CONF_USB_MSC_LUN1_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN1_ISO -#define CONF_USB_MSC_LUN1_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ECMA -#define CONF_USB_MSC_LUN1_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ANSI -#define CONF_USB_MSC_LUN1_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_REPO -#define CONF_USB_MSC_LUN1_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN1_FACTORY -#define CONF_USB_MSC_LUN1_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT -#define CONF_USB_MSC_LUN1_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT_VERSION -#define CONF_USB_MSC_LUN1_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_CAPACITY -#define CONF_USB_MSC_LUN1_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN1_BLOCK_SIZE -#define CONF_USB_MSC_LUN1_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN1_CAPACITY * 1024 / CONF_USB_MSC_LUN1_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 2 -// conf_usb_msc_lun2_enable -#ifndef CONF_USB_MSC_LUN2_ENABLE -#define CONF_USB_MSC_LUN2_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN2_TYPE -#define CONF_USB_MSC_LUN2_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun2_rmb -#ifndef CONF_USB_MSC_LUN2_RMB -#define CONF_USB_MSC_LUN2_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN2_ISO -#define CONF_USB_MSC_LUN2_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ECMA -#define CONF_USB_MSC_LUN2_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ANSI -#define CONF_USB_MSC_LUN2_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_REPO -#define CONF_USB_MSC_LUN2_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN2_FACTORY -#define CONF_USB_MSC_LUN2_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT -#define CONF_USB_MSC_LUN2_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT_VERSION -#define CONF_USB_MSC_LUN2_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun2_capacity - -#ifndef CONF_USB_MSC_LUN2_CAPACITY -#define CONF_USB_MSC_LUN2_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN2_BLOCK_SIZE -#define CONF_USB_MSC_LUN2_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN2_CAPACITY * 1024 / CONF_USB_MSC_LUN2_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 3 -// conf_usb_msc_lun3_enable -#ifndef CONF_USB_MSC_LUN3_ENABLE -#define CONF_USB_MSC_LUN3_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN3_TYPE -#define CONF_USB_MSC_LUN3_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun3_rmb -#ifndef CONF_USB_MSC_LUN3_RMB -#define CONF_USB_MSC_LUN3_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN3_ISO -#define CONF_USB_MSC_LUN3_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ECMA -#define CONF_USB_MSC_LUN3_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ANSI -#define CONF_USB_MSC_LUN3_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_REPO -#define CONF_USB_MSC_LUN3_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN3_FACTORY -#define CONF_USB_MSC_LUN3_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT -#define CONF_USB_MSC_LUN3_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT_VERSION -#define CONF_USB_MSC_LUN3_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun3_capacity - -#ifndef CONF_USB_MSC_LUN3_CAPACITY -#define CONF_USB_MSC_LUN3_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN3_BLOCK_SIZE -#define CONF_USB_MSC_LUN3_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN3_CAPACITY * 1024 / CONF_USB_MSC_LUN3_BLOCK_SIZE - 1) -#endif - -// - -// -// - -// <<< end of configuration section >>> - -#endif // USBD_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/same54/hpl_usb_config.h b/ports/atmel-samd/asf4_conf/same54/hpl_usb_config.h deleted file mode 100644 index d1bb42fe45..0000000000 --- a/ports/atmel-samd/asf4_conf/same54/hpl_usb_config.h +++ /dev/null @@ -1,413 +0,0 @@ -/* Auto-generated config file hpl_usb_config.h */ -#ifndef HPL_USB_CONFIG_H -#define HPL_USB_CONFIG_H - -// CIRCUITPY: - -// Use 64-byte USB buffers for endpoint directions that are in use. They're set to 0 below otherwise. - -#include "genhdr/autogen_usb_descriptor.h" - -#if defined(USB_ENDPOINT_1_OUT_USED) && USB_ENDPOINT_1_OUT_USED -#define CONF_USB_EP1_CACHE 64 -#endif -#if defined(USB_ENDPOINT_1_IN_USED) && USB_ENDPOINT_1_IN_USED -#define CONF_USB_EP1_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_2_OUT_USED) && USB_ENDPOINT_2_OUT_USED -#define CONF_USB_EP2_CACHE 64 -#endif -#if defined(USB_ENDPOINT_2_IN_USED) && USB_ENDPOINT_2_IN_USED -#define CONF_USB_EP2_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_3_OUT_USED) && USB_ENDPOINT_3_OUT_USED -#define CONF_USB_EP3_CACHE 64 -#endif -#if defined(USB_ENDPOINT_3_IN_USED) && USB_ENDPOINT_3_IN_USED -#define CONF_USB_EP3_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_4_OUT_USED) && USB_ENDPOINT_4_OUT_USED -#define CONF_USB_EP4_CACHE 64 -#endif -#if defined(USB_ENDPOINT_4_IN_USED) && USB_ENDPOINT_4_IN_USED -#define CONF_USB_EP4_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_5_OUT_USED) && USB_ENDPOINT_5_OUT_USED -#define CONF_USB_EP5_CACHE 64 -#endif -#if defined(USB_ENDPOINT_5_IN_USED) && USB_ENDPOINT_5_IN_USED -#define CONF_USB_EP5_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_6_OUT_USED) && USB_ENDPOINT_6_OUT_USED -#define CONF_USB_EP6_CACHE 64 -#endif -#if defined(USB_ENDPOINT_6_IN_USED) && USB_ENDPOINT_6_IN_USED -#define CONF_USB_EP6_I_CACHE 64 -#endif - -#if defined(USB_ENDPOINT_7_OUT_USED) && USB_ENDPOINT_7_OUT_USED -#define CONF_USB_EP7_CACHE 64 -#endif -#if defined(USB_ENDPOINT_7_IN_USED) && USB_ENDPOINT_7_IN_USED -#define CONF_USB_EP7_I_CACHE 64 -#endif - - -// <<< Use Configuration Wizard in Context Menu >>> - -#define CONF_USB_N_0 0 -#define CONF_USB_N_1 1 -#define CONF_USB_N_2 2 -#define CONF_USB_N_3 3 -#define CONF_USB_N_4 4 -#define CONF_USB_N_5 5 -#define CONF_USB_N_6 6 -#define CONF_USB_N_7 7 -#define CONF_USB_N_8 8 -#define CONF_USB_N_9 9 -#define CONF_USB_N_10 10 -#define CONF_USB_N_11 11 -#define CONF_USB_N_12 12 -#define CONF_USB_N_13 13 -#define CONF_USB_N_14 14 -#define CONF_USB_N_15 15 - -#define CONF_USB_D_EP_N_MAX (USB_EPT_NUM - 1) -#define CONF_USB_D_N_EP_MAX (CONF_USB_D_EP_N_MAX * 2 - 1) - -// USB Device HAL Configuration - -// Max number of endpoints supported -// Limits the number of endpoints (described by EP address) can be used in app. -// NOTE(tannewt): This not only limits the number of endpoints but also the -// addresses. In other words, even if you use endpoint 6 you need to set this to 11. -// 1 (EP0 only) -// 2 (EP0 + 1 endpoint) -// 3 (EP0 + 2 endpoints) -// 4 (EP0 + 3 endpoints) -// 5 (EP0 + 4 endpoints) -// 6 (EP0 + 5 endpoints) -// 7 (EP0 + 6 endpoints) -// 8 (EP0 + 7 endpoints) -// Max possible (by "Max Endpoint Number" config) -// usbd_num_ep_sp -#ifndef CONF_USB_D_NUM_EP_SP -#define CONF_USB_D_NUM_EP_SP CONF_USB_D_N_EP_MAX -#endif - -// - -// Max Endpoint Number supported -// Limits the max endpoint number. -// USB endpoint address is constructed by direction and endpoint number. Bit 8 of address set indicates the direction is IN. E.g., EP0x81 and EP0x01 have the same endpoint number, 1. -// Reduce the value according to specific device design, to cut-off memory usage. -// 0 (only EP0) -// 1 (EP 0x81 or 0x01) -// 2 (EP 0x82 or 0x02) -// 3 (EP 0x83 or 0x03) -// 4 (EP 0x84 or 0x04) -// 5 (EP 0x85 or 0x05) -// 6 (EP 0x86 or 0x06) -// 7 (EP 0x87 or 0x07) -// Max possible (by HW) -// The number of physical endpoints - 1 -// usbd_arch_max_ep_n -#ifndef CONF_USB_D_MAX_EP_N -#define CONF_USB_D_MAX_EP_N CONF_USB_D_EP_N_MAX -#endif - -// USB Speed Limit -// Limits the working speed of the device. -// Full speed -// Low Speed -// usbd_arch_speed -#ifndef CONF_USB_D_SPEED -#define CONF_USB_D_SPEED USB_SPEED_FS -#endif - -// Cache buffer size for EP0 -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// EP0 is default control endpoint, so cache must be used to be able to receive SETUP packet at any time. -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// usb_arch_ep0_cache -#ifndef CONF_USB_EP0_CACHE -#define CONF_USB_EP0_CACHE 64 -#endif - -// Cache configuration EP1 -// Cache buffer size for EP1 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep1_cache -#ifndef CONF_USB_EP1_CACHE -#define CONF_USB_EP1_CACHE 0 -#endif - -// Cache buffer size for EP1 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep1_I_CACHE -#ifndef CONF_USB_EP1_I_CACHE -#define CONF_USB_EP1_I_CACHE 0 -#endif -// - -// Cache configuration EP2 -// Cache buffer size for EP2 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep2_cache -#ifndef CONF_USB_EP2_CACHE -#define CONF_USB_EP2_CACHE 0 -#endif - -// Cache buffer size for EP2 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep2_I_CACHE -#ifndef CONF_USB_EP2_I_CACHE -#define CONF_USB_EP2_I_CACHE 0 -#endif -// - -// Cache configuration EP3 -// Cache buffer size for EP3 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep3_cache -#ifndef CONF_USB_EP3_CACHE -#define CONF_USB_EP3_CACHE 0 -#endif - -// Cache buffer size for EP3 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep3_I_CACHE -#ifndef CONF_USB_EP3_I_CACHE -#define CONF_USB_EP3_I_CACHE 0 -#endif -// - -// Cache configuration EP4 -// Cache buffer size for EP4 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep4_cache -#ifndef CONF_USB_EP4_CACHE -#define CONF_USB_EP4_CACHE 0 -#endif - -// Cache buffer size for EP4 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep4_I_CACHE -#ifndef CONF_USB_EP4_I_CACHE -#define CONF_USB_EP4_I_CACHE 0 -#endif -// - -// Cache configuration EP5 -// Cache buffer size for EP5 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep5_cache -#ifndef CONF_USB_EP5_CACHE -#define CONF_USB_EP5_CACHE 0 -#endif - -// Cache buffer size for EP5 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep5_I_CACHE -#ifndef CONF_USB_EP5_I_CACHE -#define CONF_USB_EP5_I_CACHE 0 -#endif -// - -// Cache configuration EP6 -// Cache buffer size for EP6 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep6_cache -#ifndef CONF_USB_EP6_CACHE -#define CONF_USB_EP6_CACHE 0 -#endif - -// Cache buffer size for EP6 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep6_I_CACHE -#ifndef CONF_USB_EP6_I_CACHE -#define CONF_USB_EP6_I_CACHE 0 -#endif -// - -// Cache configuration EP7 -// Cache buffer size for EP7 OUT -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_arch_ep7_cache -#ifndef CONF_USB_EP7_CACHE -#define CONF_USB_EP7_CACHE 0 -#endif - -// Cache buffer size for EP7 IN -// Cache is used because the USB hardware always uses DMA which requires specific memory feature. -// This cache must not be allocated if you plan to use the endpoint as control endpoint. -// No cache means IN transaction not support data buffer outside of RAM, OUT transaction not support unaligned buffer and buffer size less than endpoint max packet size -// <0=> No cache -// <8=> Cached by 8 bytes buffer -// <16=> Cached by 16 bytes buffer -// <32=> Cached by 32 bytes buffer -// <64=> Cached by 64 bytes buffer -// <128=> Cached by 128 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <256=> Cached by 256 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <512=> Cached by 512 bytes buffer (HS Bulk or interrupt or isochronous EP) -// <1024=> Cached by 1024 bytes buffer (interrupt or isochronous EP) -// usb_ep7_I_CACHE -#ifndef CONF_USB_EP7_I_CACHE -#define CONF_USB_EP7_I_CACHE 0 -#endif -// - -// <<< end of configuration section >>> - -#endif // HPL_USB_CONFIG_H diff --git a/ports/atmel-samd/asf4_conf/same54/usbd_config.h b/ports/atmel-samd/asf4_conf/same54/usbd_config.h deleted file mode 100644 index b2629e1239..0000000000 --- a/ports/atmel-samd/asf4_conf/same54/usbd_config.h +++ /dev/null @@ -1,850 +0,0 @@ -/* Auto-generated config file usbd_config.h */ -#ifndef USBD_CONFIG_H -#define USBD_CONFIG_H - -// <<< Use Configuration Wizard in Context Menu >>> - -// ---- USB Device Stack Core Options ---- - -// High Speed Support -// Enable high speed specific descriptors support, e.g., DeviceQualifierDescriptor and OtherSpeedConfiguration Descriptor. -// High speed support require descriptors description array on start, for LS/FS and HS support in first and second place. -// usbd_hs_sp -#ifndef CONF_USBD_HS_SP -#define CONF_USBD_HS_SP 0 -#endif - -// ---- USB Device Stack Composite Options ---- - -// Enable String Descriptors -// usb_composite_str_en -#ifndef CONF_USB_COMPOSITE_STR_EN -#define CONF_USB_COMPOSITE_STR_EN 0 -#endif -// Language IDs -// Language IDs in c format, split by comma (E.g., 0x0409 ...) -// usb_composite_langid -#ifndef CONF_USB_COMPOSITE_LANGID -#define CONF_USB_COMPOSITE_LANGID "0x0409" -#endif - -#ifndef CONF_USB_COMPOSITE_LANGID_DESC -#define CONF_USB_COMPOSITE_LANGID_DESC -#endif -// - -// Composite Device Descriptor - -// bcdUSB -// <0x0200=> USB 2.0 version -// <0x0210=> USB 2.1 version -// usb_composite_bcdusb -#ifndef CONF_USB_COMPOSITE_BCDUSB -#define CONF_USB_COMPOSITE_BCDUSB 0x200 -#endif - -// bMaxPackeSize0 -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_bmaxpksz0 -#ifndef CONF_USB_COMPOSITE_BMAXPKSZ0 -#define CONF_USB_COMPOSITE_BMAXPKSZ0 0x40 -#endif - -// idVender <0x0000-0xFFFF> -// usb_composite_idvender -#ifndef CONF_USB_COMPOSITE_IDVENDER -#define CONF_USB_COMPOSITE_IDVENDER 0x3eb -#endif - -// idProduct <0x0000-0xFFFF> -// usb_composite_idproduct -#ifndef CONF_USB_COMPOSITE_IDPRODUCT -#define CONF_USB_COMPOSITE_IDPRODUCT 0x2421 -#endif - -// bcdDevice <0x0000-0xFFFF> -// usb_composite_bcddevice -#ifndef CONF_USB_COMPOSITE_BCDDEVICE -#define CONF_USB_COMPOSITE_BCDDEVICE 0x100 -#endif - -// Enable string descriptor of iManufact -// usb_composite_imanufact_en -#ifndef CONF_USB_COMPOSITE_IMANUFACT_EN -#define CONF_USB_COMPOSITE_IMANUFACT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT -#define CONF_USB_COMPOSITE_IMANUFACT (CONF_USB_COMPOSITE_IMANUFACT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN)) -#endif - -// Unicode string of iManufact -// usb_composite_imanufact_str -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR -#define CONF_USB_COMPOSITE_IMANUFACT_STR "Atmel" -#endif - -#ifndef CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#define CONF_USB_COMPOSITE_IMANUFACT_STR_DESC -#endif - -// - -// Enable string descriptor of iProduct -// usb_composite_iproduct_en -#ifndef CONF_USB_COMPOSITE_IPRODUCT_EN -#define CONF_USB_COMPOSITE_IPRODUCT_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT -#define CONF_USB_COMPOSITE_IPRODUCT \ - (CONF_USB_COMPOSITE_IPRODUCT_EN * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN)) -#endif - -// Unicode string of iProduct -// usb_composite_iproduct_str -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR -#define CONF_USB_COMPOSITE_IPRODUCT_STR "Composite Demo" -#endif - -#ifndef CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#define CONF_USB_COMPOSITE_IPRODUCT_STR_DESC -#endif - -// - -// Enable string descriptor of iSerialNum -// usb_composite_iserialnum_en -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_EN -#define CONF_USB_COMPOSITE_ISERIALNUM_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM -#define CONF_USB_COMPOSITE_ISERIALNUM \ - (CONF_USB_COMPOSITE_ISERIALNUM_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN)) -#endif - -// Unicode string of iSerialNum -// usb_composite_iserialnum_str -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR -#define CONF_USB_COMPOSITE_ISERIALNUM_STR "123456789ABCDEF" -#endif - -#ifndef CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#define CONF_USB_COMPOSITE_ISERIALNUM_STR_DESC -#endif - -// - -// bNumConfigurations <0x01-0xFF> -// usb_composite_bnumconfig -#ifndef CONF_USB_COMPOSITE_BNUMCONFIG -#define CONF_USB_COMPOSITE_BNUMCONFIG 0x1 -#endif - -// - -// Composite Configuration Descriptor -// bConfigurationValue <0x01-0xFF> -// usb_composite_bconfigval -#ifndef CONF_USB_COMPOSITE_BCONFIGVAL -#define CONF_USB_COMPOSITE_BCONFIGVAL 0x1 -#endif -// Enable string descriptor of iConfig -// usb_composite_iconfig_en -#ifndef CONF_USB_COMPOSITE_ICONFIG_EN -#define CONF_USB_COMPOSITE_ICONFIG_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG -#define CONF_USB_COMPOSITE_ICONFIG \ - (CONF_USB_COMPOSITE_ICONFIG_EN \ - * (CONF_USB_COMPOSITE_IMANUFACT_EN + CONF_USB_COMPOSITE_IPRODUCT_EN + CONF_USB_COMPOSITE_ISERIALNUM_EN \ - + CONF_USB_COMPOSITE_ICONFIG_EN)) -#endif - -// Unicode string of iConfig -// usb_composite_iconfig_str -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR -#define CONF_USB_COMPOSITE_ICONFIG_STR "" -#endif - -#ifndef CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#define CONF_USB_COMPOSITE_ICONFIG_STR_DESC -#endif - -// - -// bmAttributes -// <0x80=> Bus power supply, not support for remote wakeup -// <0xA0=> Bus power supply, support for remote wakeup -// <0xC0=> Self powered, not support for remote wakeup -// <0xE0=> Self powered, support for remote wakeup -// usb_composite_bmattri -#ifndef CONF_USB_COMPOSITE_BMATTRI -#define CONF_USB_COMPOSITE_BMATTRI 0x80 -#endif - -// bMaxPower <0x00-0xFF> -// usb_composite_bmaxpower -#ifndef CONF_USB_COMPOSITE_BMAXPOWER -#define CONF_USB_COMPOSITE_BMAXPOWER 0x32 -#endif -// - -// CDC ACM Support -// usb_composite_cdc_acm_support -#ifndef CONF_USB_COMPOSITE_CDC_ACM_EN -#define CONF_USB_COMPOSITE_CDC_ACM_EN 0 -#endif - -// CDC ACM Comm Interrupt IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_EPADDR 0x82 -#endif - -// CDC ACM Comm Interrupt IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_comm_int_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_COMM_INT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_cdc_acm_data_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_EPADDR 0x81 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK IN Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_builin_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKIN_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Data BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_cdc_acm_data_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_EPADDR 0x1 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ 0x40 -#endif - -// CDC ACM Data BULK OUT Endpoint wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_cdc_acm_data_buckout_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_CDC_ACM_DATA_BULKOUT_MAXPKSZ_HS 0x200 -#endif - -// CDC ACM Echo Demo generation -// conf_usb_composite_cdc_echo_demo -// Invoke cdcdf_acm_demo_init(buf[wMaxPacketSize]) to enable the echo demo. -// Buf is packet buffer for data receive and echo back. -// The buffer is 4 byte aligned to support DMA. -#ifndef CONF_USB_COMPOSITE_CDC_ECHO_DEMO -#define CONF_USB_COMPOSITE_CDC_ECHO_DEMO 0 -#endif - -// - -// HID Mouse Support -// usb_composite_hid_mouse_support -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_EN -#define CONF_USB_COMPOSITE_HID_MOUSE_EN 0 -#endif - -// HID Mouse INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_mouse_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_EPADDR 0x83 -#endif - -// HID Mouse INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_mouse_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_MOUSE_INTIN_MAXPKSZ 0x8 -#endif - -// HID Mouse Move Demo generation -// conf_usb_composite_hid_mouse_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Button1 and button3 are the pins used for mouse moving left and right. -#ifndef CONF_USB_COMPOSITE_HID_MOUSE_DEMO -#define CONF_USB_COMPOSITE_HID_MOUSE_DEMO 0 -#endif - -// - -// HID Keyboard Support -// usb_composite_hid_keyboard_support -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_EN -#define CONF_USB_COMPOSITE_HID_KEYBOARD_EN 0 -#endif - -// HID Keyboard INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_keyboard_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_EPADDR 0x84 -#endif - -// HID Keyboard INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTIN_MAXPKSZ 0x8 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_keyboard_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_EPADDR 0x2 -#endif - -// HID Keyboard INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_keyboard_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_KEYBOARD_INTOUT_MAXPKSZ 0x8 -#endif - -// HID Keyboard Caps Lock Demo generation -// conf_usb_composite_hid_keyboard_demo -// Invoke hiddf_demo_init(button1, button2, button3) to enabled the move demo. -// Buffon2 is the pin used for keyboard CAPS LOCK simulation. -#ifndef CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO -#define CONF_USB_COMPOSITE_HID_KEYBOARD_DEMO 0 -#endif - -// - -// HID Generic Support -// usb_composite_hid_generic_support -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_EN -#define CONF_USB_COMPOSITE_HID_GENERIC_EN 0 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT_LEN 53 -#endif - -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_REPORT -#define CONF_USB_COMPOSITE_HID_GENERIC_REPORT \ - 0x06, 0xFF, 0xFF, 0x09, 0x01, 0xA1, 0x01, 0x09, 0x02, 0x09, 0x03, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, \ - 0x40, 0x81, 0x02, 0x09, 0x04, 0x09, 0x05, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x40, 0x91, 0x02, \ - 0x09, 0x06, 0x09, 0x07, 0x15, 0x00, 0x26, 0xFF, 0x00, 0x75, 0x08, 0x95, 0x04, 0xB1, 0x02, 0xC0 -#endif - -// HID Generic INTERRUPT IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_hid_generic_intin_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_EPADDR 0x85 -#endif - -// HID Generic INTERRUPT IN Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_hid_generic_intin_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTIN_MAXPKSZ 0x40 -#endif - -// HID Generic INTERRUPT OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_hid_generic_intout_epaddr -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_EPADDR 0x3 -#endif - -// HID Generic INTERRUPT OUT Endpoint wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// usb_composite_hid_generic_intout_maxpksz -// Please make sure that the setting here is coincide with the endpoint setting in USB device driver. -#ifndef CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ -#define CONF_USB_COMPOSITE_HID_GENERIC_INTOUT_MAXPKSZ 0x40 -#endif - -// - -// MSC Support -// usb_composite_msc_support -#ifndef CONF_USB_COMPOSITE_MSC_EN -#define CONF_USB_COMPOSITE_MSC_EN 0 -#endif - -// MSC BULK Endpoints wMaxPacketSize -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes - -// usb_composite_msc_bulk_maxpksz -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ 0x40 -#endif - -// MSC BULK Endpoints wMaxPacketSize for High Speed -// <0x0008=> 8 bytes -// <0x0010=> 16 bytes -// <0x0020=> 32 bytes -// <0x0040=> 64 bytes -// <0x0080=> 128 bytes -// <0x0100=> 256 bytes -// <0x0200=> 512 bytes - -// usb_composite_msc_bulk_maxpksz_hs -#ifndef CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS -#define CONF_USB_COMPOSITE_MSC_BULK_MAXPKSZ_HS 0x200 -#endif - -// MSC BULK IN Endpoint Address -// <0x81=> EndpointAddress = 0x81 -// <0x82=> EndpointAddress = 0x82 -// <0x83=> EndpointAddress = 0x83 -// <0x84=> EndpointAddress = 0x84 -// <0x85=> EndpointAddress = 0x85 -// <0x86=> EndpointAddress = 0x86 -// <0x87=> EndpointAddress = 0x87 -// <0x88=> EndpointAddress = 0x88 -// <0x89=> EndpointAddress = 0x89 - -// usb_composite_msc_bulkin_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKIN_EPADDR 0x86 -#endif - -// MSC BULK OUT Endpoint Address -// <0x01=> EndpointAddress = 0x01 -// <0x02=> EndpointAddress = 0x02 -// <0x03=> EndpointAddress = 0x03 -// <0x04=> EndpointAddress = 0x04 -// <0x05=> EndpointAddress = 0x05 -// <0x06=> EndpointAddress = 0x06 -// <0x07=> EndpointAddress = 0x07 -// <0x08=> EndpointAddress = 0x08 -// <0x09=> EndpointAddress = 0x09 - -// usb_composite_msc_bulkout_epaddr -#ifndef CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR -#define CONF_USB_COMPOSITE_MSC_BULKOUT_EPADDR 0x4 -#endif - -// Enable Demo code for Disk LUN handling -// usb_composite_msc_demo_en -#ifndef CONF_USB_COMPOSITE_MSC_LUN_DEMO -#define CONF_USB_COMPOSITE_MSC_LUN_DEMO 1 -#endif - -// Disk access cache/buffer of sectors if non-RAM disk (e.g., SD/MMC) enabled <1-64> -// conf_usb_msc_lun_buf_sectors -#ifndef CONF_USB_MSC_LUN_BUF_SECTORS -#define CONF_USB_MSC_LUN_BUF_SECTORS 4 -#endif - -// Enable Demo for RAM Disk -// conf_usb_msc_lun0_enable -#ifndef CONF_USB_MSC_LUN0_ENABLE -#define CONF_USB_MSC_LUN0_ENABLE 1 -#endif - -#ifndef CONF_USB_MSC_LUN0_TYPE -#define CONF_USB_MSC_LUN0_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun0_rmb -#ifndef CONF_USB_MSC_LUN0_RMB -#define CONF_USB_MSC_LUN0_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN0_ISO -#define CONF_USB_MSC_LUN0_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ECMA -#define CONF_USB_MSC_LUN0_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_ANSI -#define CONF_USB_MSC_LUN0_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_REPO -#define CONF_USB_MSC_LUN0_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN0_FACTORY -#define CONF_USB_MSC_LUN0_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT -#define CONF_USB_MSC_LUN0_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN0_PRODUCT_VERSION -#define CONF_USB_MSC_LUN0_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// Windows will not show disk less than 20K, so 22K is used to reserve more RAM for APP -// conf_usb_msc_lun0_capacity - -#ifndef CONF_USB_MSC_LUN0_CAPACITY -#define CONF_USB_MSC_LUN0_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN0_BLOCK_SIZE -#define CONF_USB_MSC_LUN0_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN0_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN0_CAPACITY * 1024 / CONF_USB_MSC_LUN0_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for SD/MMC Disk -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_enable -#ifndef CONF_USB_MSC_LUN1_ENABLE -#define CONF_USB_MSC_LUN1_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN1_TYPE -#define CONF_USB_MSC_LUN1_TYPE 0x00 -#endif - -// The disk is removable -// SD/MMC stack must be added before enable SD/MMC demo -// SD/MMC insert/eject not supported by this simple demo -// conf_usb_msc_lun1_rmb -#ifndef CONF_USB_MSC_LUN1_RMB -#define CONF_USB_MSC_LUN1_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN1_ISO -#define CONF_USB_MSC_LUN1_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ECMA -#define CONF_USB_MSC_LUN1_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_ANSI -#define CONF_USB_MSC_LUN1_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_REPO -#define CONF_USB_MSC_LUN1_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN1_FACTORY -#define CONF_USB_MSC_LUN1_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT -#define CONF_USB_MSC_LUN1_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_PRODUCT_VERSION -#define CONF_USB_MSC_LUN1_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN1_CAPACITY -#define CONF_USB_MSC_LUN1_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN1_BLOCK_SIZE -#define CONF_USB_MSC_LUN1_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN1_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN1_CAPACITY * 1024 / CONF_USB_MSC_LUN1_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 2 -// conf_usb_msc_lun2_enable -#ifndef CONF_USB_MSC_LUN2_ENABLE -#define CONF_USB_MSC_LUN2_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN2_TYPE -#define CONF_USB_MSC_LUN2_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun2_rmb -#ifndef CONF_USB_MSC_LUN2_RMB -#define CONF_USB_MSC_LUN2_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN2_ISO -#define CONF_USB_MSC_LUN2_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ECMA -#define CONF_USB_MSC_LUN2_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_ANSI -#define CONF_USB_MSC_LUN2_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_REPO -#define CONF_USB_MSC_LUN2_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN2_FACTORY -#define CONF_USB_MSC_LUN2_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT -#define CONF_USB_MSC_LUN2_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN2_PRODUCT_VERSION -#define CONF_USB_MSC_LUN2_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun2_capacity - -#ifndef CONF_USB_MSC_LUN2_CAPACITY -#define CONF_USB_MSC_LUN2_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN2_BLOCK_SIZE -#define CONF_USB_MSC_LUN2_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN2_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN2_CAPACITY * 1024 / CONF_USB_MSC_LUN2_BLOCK_SIZE - 1) -#endif - -// - -// Enable Demo for LUN 3 -// conf_usb_msc_lun3_enable -#ifndef CONF_USB_MSC_LUN3_ENABLE -#define CONF_USB_MSC_LUN3_ENABLE 0 -#endif - -#ifndef CONF_USB_MSC_LUN3_TYPE -#define CONF_USB_MSC_LUN3_TYPE 0x00 -#endif - -// The disk is removable -// conf_usb_msc_lun3_rmb -#ifndef CONF_USB_MSC_LUN3_RMB -#define CONF_USB_MSC_LUN3_RMB 0x1 -#endif - -#ifndef CONF_USB_MSC_LUN3_ISO -#define CONF_USB_MSC_LUN3_ISO 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ECMA -#define CONF_USB_MSC_LUN3_ECMA 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_ANSI -#define CONF_USB_MSC_LUN3_ANSI 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_REPO -#define CONF_USB_MSC_LUN3_REPO 0x01 -#endif - -#ifndef CONF_USB_MSC_LUN3_FACTORY -#define CONF_USB_MSC_LUN3_FACTORY 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT -#define CONF_USB_MSC_LUN3_PRODUCT 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -#endif - -#ifndef CONF_USB_MSC_LUN3_PRODUCT_VERSION -#define CONF_USB_MSC_LUN3_PRODUCT_VERSION 0x00, 0x00, 0x00, 0x00 -#endif - -// Disk Size (in KB) <0x1-0xFFFFFFFF> -// conf_usb_msc_lun3_capacity - -#ifndef CONF_USB_MSC_LUN3_CAPACITY -#define CONF_USB_MSC_LUN3_CAPACITY 22 -#endif - -#ifndef CONF_USB_MSC_LUN3_BLOCK_SIZE -#define CONF_USB_MSC_LUN3_BLOCK_SIZE 512 -#endif - -#ifndef CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR -#define CONF_USB_MSC_LUN3_LAST_BLOCK_ADDR \ - ((uint32_t)CONF_USB_MSC_LUN3_CAPACITY * 1024 / CONF_USB_MSC_LUN3_BLOCK_SIZE - 1) -#endif - -// - -// -// - -// <<< end of configuration section >>> - -#endif // USBD_CONFIG_H diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk index c7918ad05c..200eea0630 100644 --- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk +++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk @@ -11,10 +11,6 @@ EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_USB_MIDI = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 CIRCUITPY_GAMEPAD = 1 CIRCUITPY_BUSDEVICE = 1 diff --git a/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk index 56cbede39f..a552fc3d64 100644 --- a/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_neokey_trinkey_m0/mpconfigboard.mk @@ -8,26 +8,15 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE - -CIRCUITPY_ANALOGIO = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_PS2IO = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_PWMIO = 0 -CIRCUITPY_AUDIOCORE = 0 -CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 1 - -CIRCUITPY_MATH = 1 -CIRCUITPY_PIXELBUF = 1 -CIRCUITPY_USB_MIDI = 1 -CIRCUITPY_TOUCHIO = 1 CIRCUITPY_FULL_BUILD = 0 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk index 92e7a17f3e..49e5a88c57 100644 --- a/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_proxlight_trinkey_m0/mpconfigboard.mk @@ -8,26 +8,17 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE - -CIRCUITPY_ANALOGIO = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_PS2IO = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_PWMIO = 0 -CIRCUITPY_AUDIOCORE = 0 -CIRCUITPY_BUSIO = 1 -CIRCUITPY_STORAGE = 1 - -CIRCUITPY_MATH = 1 -CIRCUITPY_PIXELBUF = 0 -CIRCUITPY_USB_MIDI = 1 -CIRCUITPY_TOUCHIO = 1 CIRCUITPY_FULL_BUILD = 0 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 +CIRCUITPY_ANALOGIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 + +CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_TOUCHIO = 1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID diff --git a/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk index 29cc9ee195..b596c726cd 100644 --- a/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_rotary_trinkey_m0/mpconfigboard.mk @@ -8,26 +8,15 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_ANALOGIO = 0 -CIRCUITPY_ROTARYIO = 1 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_PS2IO = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 1 - -CIRCUITPY_MATH = 0 -CIRCUITPY_PIXELBUF = 1 -CIRCUITPY_USB_MIDI = 1 CIRCUITPY_TOUCHIO = 0 -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk index 2bc2def52e..5ef783908b 100644 --- a/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/adafruit_slide_trinkey_m0/mpconfigboard.mk @@ -9,25 +9,14 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE -CIRCUITPY_ANALOGIO = 1 +CIRCUITPY_FULL_BUILD = 0 + CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_PS2IO = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 1 - -CIRCUITPY_MATH = 1 -CIRCUITPY_PIXELBUF = 1 -CIRCUITPY_USB_MIDI = 1 -CIRCUITPY_TOUCHIO = 1 -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SimpleMath diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk index 1fd96b0aee..c3d75202bf 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk index fabe52ce23..eea3a27f13 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk index c16c53e6d6..895c027ee5 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk index 697ec02c36..5ee22c59ad 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk index ec037837e5..055e6b19e2 100644 --- a/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/bast_pro_mini_m0/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk index fea765c3f0..1a8cddfda7 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk +++ b/ports/atmel-samd/boards/bdmicro_vina_d21/mpconfigboard.mk @@ -9,16 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "MX25L51245G","GD25S512MD" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 - -CFLAGS_INLINE_LIMIT = 60 -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/blm_badge/mpconfigboard.mk b/ports/atmel-samd/boards/blm_badge/mpconfigboard.mk index 794e38d792..8ba3ae94c3 100644 --- a/ports/atmel-samd/boards/blm_badge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/blm_badge/mpconfigboard.mk @@ -14,11 +14,8 @@ CIRCUITPY_AUDIOIO = 1 CIRCUITPY_AUDIOBUSIO = 1 # Pins for I2SOut are not available. CIRCUITPY_AUDIOBUSIO_I2SOUT = 0 -CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 CIRCUITPY_USB_HID = 1 CIRCUITPY_USB_MIDI = 0 - -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk index b1306f54b6..8724e0d4bb 100644 --- a/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk +++ b/ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk @@ -9,7 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_ROTARYIO = 0 - -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk index 870edb06ee..fbc67f3c71 100755 --- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk @@ -9,29 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 -MICROPY_PY_ASYNC_AWAIT = 0 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index 97434a90b8..5311cdc1d4 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -10,16 +10,13 @@ SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ -# Make room for frozen libs. -CIRCUITPY_BITMAPTOOLS = 0 +# Turn off displayio to make room for frozen libs. CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -MICROPY_PY_ASYNC_AWAIT = 0 -SUPEROPT_GC = 0 -CFLAGS_INLINE_LIMIT = 55 +# Now we actually have a lot of room. Put back some useful modules. +CIRCUITPY_BITBANGIO = 1 +CIRCUITPY_COUNTIO = 1 +CIRCUITPY_BUSDEVICE = 1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk index d6994a4c01..902e9594e3 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.mk @@ -11,19 +11,9 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" # Turn off features and optimizations for Crickit build to make room for additional frozen libs. LONGINT_IMPL = NONE -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 + +CIRCUITPY_BUSDEVICE = 1 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_PIXELBUF = 1 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk index ec85666719..68fb51ab00 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.mk @@ -9,23 +9,16 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" -# Turn off features and optimizations for Crickit build to make room for additional frozen libs. +# Turn off features and optimizations for displayio build to make room for additional frozen libs. LONGINT_IMPL = NONE -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 CIRCUITPY_PIXELBUF = 0 -CIRCUITPY_RE = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 +CIRCUITPY_USB_MIDI = 0 + # So not all of displayio, sorry! CIRCUITPY_VECTORIO = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 +CIRCUITPY_BITMAPTOOLS = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground diff --git a/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk index 3799d7ef73..4b32f1f623 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp_sapling_m0/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/cp_sapling_m0_revb/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0_revb/mpconfigboard.mk index 173327a3af..6bf1d73079 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_revb/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp_sapling_m0_revb/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk index 1a1bf8cc79..7a060a168b 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/mpconfigboard.mk @@ -13,21 +13,3 @@ EXTERNAL_FLASH_DEVICES = AT25DF081A CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk index 22b55f6fd5..f51bd9a5c9 100644 --- a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk index 7e99182912..9c3b642330 100644 --- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk index 5916f23b31..a34b751042 100644 --- a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk index 1065fb50aa..01a9063654 100644 --- a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk b/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk index 8b2ce7fbf4..3c88b60a37 100644 --- a/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk +++ b/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk @@ -10,28 +10,10 @@ SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q32C LONGINT_IMPL = MPZ -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FULL_BUILD = 0 -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_SDCARDIO = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x diff --git a/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk b/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk index 915270c579..04cc49e181 100644 --- a/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk +++ b/ports/atmel-samd/boards/dynossat_edu_eps/mpconfigboard.mk @@ -14,15 +14,6 @@ LONGINT_IMPL = MPZ CIRCUITPY_FULLBUILD = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 1 -CIRCUITPY_VECTORIO = 0 CIRCUITPY_BUSDEVICE = 0 -CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ROTARYIO = 0 - -CFLAGS_INLINE_LIMIT = 60 - -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/dynossat_edu_obc/mpconfigboard.mk b/ports/atmel-samd/boards/dynossat_edu_obc/mpconfigboard.mk index 8f552c5b4d..8ac6c0a2d0 100644 --- a/ports/atmel-samd/boards/dynossat_edu_obc/mpconfigboard.mk +++ b/ports/atmel-samd/boards/dynossat_edu_obc/mpconfigboard.mk @@ -10,6 +10,3 @@ CHIP_FAMILY = samd51 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "GD25Q32C" LONGINT_IMPL = MPZ - -CFLAGS_INLINE_LIMIT = 60 -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk index ffe76d9307..7317dfbf1b 100644 --- a/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk +++ b/ports/atmel-samd/boards/escornabot_makech/mpconfigboard.mk @@ -9,7 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_RTC = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index ab6c4ed99d..62336ecf50 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk index 183a80ffa4..cfd1f63cb3 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index fcf1b4a1aa..3aa03e61f6 100644 --- a/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -9,15 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk index e29f3c0b29..d18d986e6d 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/mpconfigboard.mk @@ -11,14 +11,7 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ # Make space for frozen libs -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_GAMEPAD = 0 -CFLAGS_INLINE_LIMIT = 50 -CIRCUITPY_MSGPACK = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Crickit diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk index b544a3680a..48c0f47064 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm69/mpconfigboard.mk @@ -13,20 +13,12 @@ CIRCUITPY_FULL_BUILD = 0 # A number of modules are removed for RFM69 to make room for frozen libraries. # Many I/O functions are not available. CIRCUITPY_ANALOGIO = 1 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_NEOPIXEL_WRITE = 1 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_BUSDEVICE = 1 -CFLAGS_INLINE_LIMIT = 35 - -# Make more room. -SUPEROPT_GC = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM69 diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk index e307ab4f6b..4003dd67f0 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/mpconfigboard.mk @@ -14,20 +14,12 @@ CIRCUITPY_FULL_BUILD = 0 # A number of modules are removed for RFM9x to make room for frozen libraries. # Many I/O functions are not available. CIRCUITPY_ANALOGIO = 1 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_NEOPIXEL_WRITE = 1 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 0 CIRCUITPY_USB_HID = 0 CIRCUITPY_TOUCHIO = 0 CIRCUITPY_BUSDEVICE = 1 -CFLAGS_INLINE_LIMIT = 35 -# Make more room. -SUPEROPT_GC = 0 - # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x diff --git a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk index 5921bd2f1a..811336885b 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk @@ -9,19 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL064L" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_BUSDEVICE = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -# supersized, not ultra-supersized -CIRCUITPY_VECTORIO = 0 - -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk index 4c0c5137c1..ecadf211ff 100644 --- a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk @@ -10,5 +10,4 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_VECTORIO = 1 CIRCUITPY_CANIO = 1 diff --git a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk index a8b4460a6e..2606572d8c 100644 --- a/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_express/mpconfigboard.mk @@ -10,5 +10,4 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ -CIRCUITPY_VECTORIO = 1 CIRCUITPY__EVE = 1 diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h deleted file mode 100644 index b1839f2c99..0000000000 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.h +++ /dev/null @@ -1,31 +0,0 @@ -#define MICROPY_HW_BOARD_NAME "Adafruit Feather RadioFruit Zigbee" -#define MICROPY_HW_MCU_NAME "samr21g18" - -#define MICROPY_HW_LED_STATUS (&pin_PA27) -#define MICROPY_HW_NEOPIXEL (&pin_PA22) - -#define SPI_FLASH_MOSI_PIN &pin_PA31 -#define SPI_FLASH_MISO_PIN &pin_PA30 -#define SPI_FLASH_SCK_PIN &pin_PA17 -#define SPI_FLASH_CS_PIN &pin_PA28 - -// These are pins not to reset. -#define MICROPY_PORT_A (PORT_PA22) -#define MICROPY_PORT_B (0) -#define MICROPY_PORT_C (0) - -#define BOARD_HAS_CRYSTAL 1 - -#define DEFAULT_I2C_BUS_SCL (&pin_PA13) -#define DEFAULT_I2C_BUS_SDA (&pin_PA12) - -#define DEFAULT_SPI_BUS_SCK (&pin_PB23) -#define DEFAULT_SPI_BUS_MOSI (&pin_PB22) -#define DEFAULT_SPI_BUS_MISO (&pin_PA23) - -#define DEFAULT_UART_BUS_RX (&pin_PA09) -#define DEFAULT_UART_BUS_TX (&pin_PA08) - -// USB is always used internally so skip the pin objects for it. -#define IGNORE_PIN_PA24 1 -#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk b/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk deleted file mode 100755 index 29774db742..0000000000 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/mpconfigboard.mk +++ /dev/null @@ -1,39 +0,0 @@ -USB_VID = 0x239A -USB_PID = 0x80D0 -USB_PRODUCT = "Feather RadioFruit Zigbee" -USB_MANUFACTURER = "Adafruit Industries LLC" - -CHIP_VARIANT = SAMR21G18A -CHIP_FAMILY = samd21 - -SPI_FLASH_FILESYSTEM = 1 -EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" -LONGINT_IMPL = MPZ - -# No I2S on SAMR21G -CIRCUITPY_AUDIOBUSIO = 0 -# No DAC on SAMR21G -CIRCUITPY_AUDIOIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/pins.c b/ports/atmel-samd/boards/feather_radiofruit_zigbee/pins.c deleted file mode 100755 index 7133978784..0000000000 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/pins.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "shared-bindings/board/__init__.h" - -STATIC const mp_rom_map_elem_t board_global_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PB02) }, - { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB03) }, - { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA04) }, - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA05) }, - { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA06) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB23) }, - { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB22) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA23) }, - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA08) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA12) }, - { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA13) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA14) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA15) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, - { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA19) }, - { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA22) }, - { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA27) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, - { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, - - // Internally connected within the package - { MP_ROM_QSTR(MP_QSTR_DIG3), MP_ROM_PTR(&pin_PA10) }, - { MP_ROM_QSTR(MP_QSTR_DIG4), MP_ROM_PTR(&pin_PA11) }, - { MP_ROM_QSTR(MP_QSTR_SLP_TR), MP_ROM_PTR(&pin_PA20) }, - { MP_ROM_QSTR(MP_QSTR_IRQ), MP_ROM_PTR(&pin_PB00) }, - { MP_ROM_QSTR(MP_QSTR_DIG1), MP_ROM_PTR(&pin_PA16) }, - { MP_ROM_QSTR(MP_QSTR_DIG2), MP_ROM_PTR(&pin_PA17) }, - { MP_ROM_QSTR(MP_QSTR_RF_MOSI), MP_ROM_PTR(&pin_PB30) }, - { MP_ROM_QSTR(MP_QSTR_SEL), MP_ROM_PTR(&pin_PB31) }, - { MP_ROM_QSTR(MP_QSTR_CLKM), MP_ROM_PTR(&pin_PC16) }, - { MP_ROM_QSTR(MP_QSTR_RF_SCK), MP_ROM_PTR(&pin_PC18) }, - { MP_ROM_QSTR(MP_QSTR_RF_MISO), MP_ROM_PTR(&pin_PC19) }, - { MP_ROM_QSTR(MP_QSTR_RESETN), MP_ROM_PTR(&pin_PB15) }, -}; -MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/fluff_m0/mpconfigboard.mk b/ports/atmel-samd/boards/fluff_m0/mpconfigboard.mk index 52fcaec020..8825143d02 100644 --- a/ports/atmel-samd/boards/fluff_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/fluff_m0/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk index 9d086c8f59..f37b8c7be7 100644 --- a/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/gemma_m0/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk index e97f9884da..300419fa19 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk @@ -12,20 +12,7 @@ LONGINT_IMPL = NONE # To keep the build small CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_VECTORIO = 0 - -CFLAGS_INLINE_LIMIT = 55 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/atmel-samd/boards/huntercat_nfc/mpconfigboard.mk b/ports/atmel-samd/boards/huntercat_nfc/mpconfigboard.mk index 43a0d38d7d..5e9a1372b4 100644 --- a/ports/atmel-samd/boards/huntercat_nfc/mpconfigboard.mk +++ b/ports/atmel-samd/boards/huntercat_nfc/mpconfigboard.mk @@ -6,20 +6,6 @@ USB_MANUFACTURER = "Electronic Cats" CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 -INTERNAL_FLASH_FILESYSTEM = 0 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" LONGINT_IMPL = MPZ - -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_NEOPIXEL_WRITE = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_USB_MIDI = 1 -CIRCUITPY_TOUCHIO = 0 -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk index 106eef89cf..447e15600e 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/mpconfigboard.mk @@ -12,32 +12,4 @@ LONGINT_IMPL = MPZ CIRCUITPY_BITBANG_APA102 = 1 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_RTC = 0 -# too itsy bitsy for all of displayio -CIRCUITPY_VECTORIO = 0 - -CFLAGS_INLINE_LIMIT = 60 -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif +CIRCUITPY_PULSEIO = 0 diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk index ea010ed2ee..d7b8a4bb1e 100644 --- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk +++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk @@ -12,12 +12,15 @@ LONGINT_IMPL = MPZ # Not needed. CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOMP3 = 0 -CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_MSGPACK = 0 CIRCUITPY_PS2IO = 0 CIRCUITPY_RGBMATRIX = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_TOUCHIO = 0 + CIRCUITPY_ULAB = 0 # Override optimization to keep binary small diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk index 8ee9d23fe5..55c6bb6de3 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk @@ -9,9 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_RTC = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index 01e6094cdf..4e7d799985 100644 --- a/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -9,15 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 -MICROPY_PY_ASYNC_AWAIT = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk b/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk index 3882e780eb..b60852d470 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ndgarage_ndbit6/mpconfigboard.mk @@ -10,6 +10,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk index 4ae1d8741d..58ef17ce03 100644 --- a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk @@ -10,6 +10,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk index 0f90dba6a1..4ff9677693 100644 --- a/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/neopixel_trinkey_m0/mpconfigboard.mk @@ -9,25 +9,19 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + CIRCUITPY_ANALOGIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 -CIRCUITPY_PS2IO = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_BUSIO = 0 -CIRCUITPY_STORAGE = 1 -CIRCUITPY_MATH = 1 CIRCUITPY_PIXELBUF = 1 CIRCUITPY_USB_MIDI = 1 CIRCUITPY_TOUCHIO = 1 -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk index 8b2ac7ff78..869ad42fa9 100644 --- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.mk @@ -11,15 +11,8 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_PEW = 1 -CIRCUITPY_ANALOGIO = 1 -CIRCUITPY_MATH = 1 -CIRCUITPY_NEOPIXEL_WRITE = 1 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 0 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x diff --git a/ports/atmel-samd/boards/picoplanet/mpconfigboard.mk b/ports/atmel-samd/boards/picoplanet/mpconfigboard.mk index e931553747..5769493579 100644 --- a/ports/atmel-samd/boards/picoplanet/mpconfigboard.mk +++ b/ports/atmel-samd/boards/picoplanet/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk index 22e59cd773..33ebf81a4c 100644 --- a/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk @@ -8,6 +8,7 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 # A number of modules are removed for pIRKey to make room for frozen libraries. # Many I/O functions are not available. @@ -15,16 +16,10 @@ LONGINT_IMPL = NONE CIRCUITPY_ANALOGIO = 0 CIRCUITPY_MATH = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 -CIRCUITPY_PULSEIO = 1 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_RTC = 0 -CIRCUITPY_SAMD = 0 CIRCUITPY_USB_MIDI = 1 CIRCUITPY_TOUCHIO = 0 -CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 # Include these Python libraries in firmware. # FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk index 1a73ade94d..82ed445658 100644 --- a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk @@ -9,8 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_RTC = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/qtpy_m0/mpconfigboard.mk b/ports/atmel-samd/boards/qtpy_m0/mpconfigboard.mk index c214006ead..a53694e74e 100644 --- a/ports/atmel-samd/boards/qtpy_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/qtpy_m0/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk index 1ffe1669e7..f9928c21b8 100644 --- a/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk +++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/mpconfigboard.mk @@ -6,19 +6,6 @@ USB_MANUFACTURER = "Adafruit Industries LLC" CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 -INTERNAL_FLASH_FILESYSTEM = 0 LONGINT_IMPL = MPZ SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C - -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/sam32/mpconfigboard.mk b/ports/atmel-samd/boards/sam32/mpconfigboard.mk index 9ac24a014c..cddfa49b3b 100644 --- a/ports/atmel-samd/boards/sam32/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sam32/mpconfigboard.mk @@ -9,8 +9,4 @@ CHIP_FAMILY = samd51 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = MPZ -# No I2S on SAMD51 -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_USTACK = 1 - FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_wio_terminal/mpconfigboard.mk index 9788f5ff40..fefc78addc 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/mpconfigboard.mk +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ" LONGINT_IMPL = MPZ - -CIRCUITPY_VECTORIO = 1 diff --git a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk index 6bbd84235a..1334c8312c 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk +++ b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index f5ce4a5d13..196d36816f 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/serpente/mpconfigboard.mk b/ports/atmel-samd/boards/serpente/mpconfigboard.mk index 422baf46ad..5fa4485552 100644 --- a/ports/atmel-samd/boards/serpente/mpconfigboard.mk +++ b/ports/atmel-samd/boards/serpente/mpconfigboard.mk @@ -9,13 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q32C LONGINT_IMPL = NONE - -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_BUSDEVICE = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_MSGPACK = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk index 70fe447232..798fd8fcb3 100644 --- a/ports/atmel-samd/boards/shirtty/mpconfigboard.mk +++ b/ports/atmel-samd/boards/shirtty/mpconfigboard.mk @@ -9,8 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_I2CPERIPHERAL = 1 -CIRCUITPY_TOUCHIO = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk index e64045f13a..58411aa03e 100644 --- a/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk +++ b/ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ - -CIRCUITPY_VECTORIO = 1 diff --git a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk index 3467ef7578..d19e606319 100644 --- a/ports/atmel-samd/boards/snekboard/mpconfigboard.mk +++ b/ports/atmel-samd/boards/snekboard/mpconfigboard.mk @@ -9,30 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 - -CFLAGS_INLINE_LIMIT = 60 - -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk index aca557cec6..dcf15beb11 100755 --- a/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_lumidrive/mpconfigboard.mk @@ -12,11 +12,5 @@ LONGINT_IMPL = MPZ CIRCUITPY_AUDIOIO = 0 CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_BUSDEVICE = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar - -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/mpconfigboard.mk index 435ee87fde..5c2ad88dfc 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/mpconfigboard.mk @@ -10,6 +10,3 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/mpconfigboard.mk index 7c2fd57ea1..468aa7360b 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/mpconfigboard.mk @@ -11,4 +11,3 @@ EXTERNAL_FLASH_DEVICES = "W25Q32FV" LONGINT_IMPL = MPZ CIRCUITPY_FULL_BUILD = 0 -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk index a5cd49239e..70ece9b9fc 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/mpconfigboard.mk @@ -9,30 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q32FV" LONGINT_IMPL = MPZ - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 - -CFLAGS_INLINE_LIMIT = 60 -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk index bafcc02a2b..b8ac2dc256 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk index aef38661be..77dfe8887d 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk b/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk index 0f9b8a3c18..1088ca1e8d 100644 --- a/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stackrduino_m0_pro/mpconfigboard.mk @@ -9,17 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" LONGINT_IMPL = MPZ - - -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_MSGPACK = 0 -CIRCUITPY_VECTORIO = 0 -CIRCUITPY_BUSDEVICE = 0 -MICROPY_PY_ASYNC_AWAIT = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk index 91644386f2..53aeda3c50 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk @@ -12,29 +12,3 @@ EXTERNAL_FLASH_DEVICES = AT25SF161 LONGINT_IMPL = MPZ CIRCUITPY_BITBANG_APA102 = 1 - -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_GAMEPAD = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_VECTORIO = 0 - -CFLAGS_INLINE_LIMIT = 60 -SUPEROPT_GC = 0 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 -ifeq ($(TRANSLATION), zh_Latn_pinyin) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), ja) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -endif -ifeq ($(TRANSLATION), de_DE) -RELEASE_NEEDS_CLEAN_BUILD = 1 -CFLAGS_INLINE_LIMIT = 35 -SUPEROPT_VM = 0 -endif diff --git a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk index fbbb974cdf..a51349f5f3 100644 --- a/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -9,9 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - -# On this particular board, these save about 180 bytes. On other boards, they may -increase- space used. -CFLAGS_BOARD = -fweb -frename-registers diff --git a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk index e91c94e56d..028114091e 100644 --- a/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk +++ b/ports/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk @@ -9,19 +9,3 @@ CHIP_FAMILY = samd21 SPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = W25Q32BV LONGINT_IMPL = MPZ - -CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_FREQUENCYIO = 0 -CIRCUITPY_I2CPERIPHERAL = 0 -MICROPY_PY_ASYNC_AWAIT = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - -CFLAGS_INLINE_LIMIT = 35 - -CFLAGS_BOARD = --param max-inline-insns-auto=15 diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk index d6ba805b14..90b5600dcb 100644 --- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk +++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk @@ -9,6 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk index 74f438b714..2f1062e419 100644 --- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk +++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk @@ -34,5 +34,3 @@ CIRCUITPY_BUSDEVICE = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/ugame10 CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf - -SUPEROPT_GC = 0 diff --git a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk index 9497bf78cb..321ebd951b 100644 --- a/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cc03/mpconfigboard.mk @@ -8,11 +8,9 @@ CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = MPZ -CIRCUITPY_FULL_BUILD = 0 +LONGINT_IMPL = NONE -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 +CIRCUITPY_FULL_BUILD = 0 # Make room for frozen libs. CIRCUITPY_FREQUENCYIO = 0 diff --git a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index eb43bd8afd..e0bec4e623 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -8,24 +8,20 @@ CHIP_VARIANT = SAMD21G18A CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 -LONGINT_IMPL = MPZ +LONGINT_IMPL = NONE + CIRCUITPY_FULL_BUILD = 0 -SUPEROPT_GC = 0 -SUPEROPT_VM = 0 - # Make room for frozen libs. -CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_ANALOGIO=0 +CIRCUITPY_BUSDEVICE=1 CIRCUITPY_NEOPIXEL_WRITE=0 CIRCUITPY_PULSEIO=0 CIRCUITPY_ROTARYIO=0 -CIRCUITPY_TOUCHIO_USE_NATIVE=0 CIRCUITPY_TOUCHIO=0 CIRCUITPY_USB_MIDI=0 CIRCUITPY_RTC=0 -CIRCUITPY_COUNTIO=0 -CIRCUITPY_BUSDEVICE=1 +CIRCUITPY_SDCARDIO=1 # Include these Python libraries in firmware. FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c.uncrustify b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c.uncrustify deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index f04055d43b..060b17daf5 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -20,8 +20,6 @@ endif INTERNAL_LIBM = 1 -USB_SERIAL_NUMBER_LENGTH = 32 - # Number of USB endpoint pairs. USB_NUM_EP = 8 @@ -34,28 +32,33 @@ ifeq ($(CHIP_FAMILY),samd21) # The ?='s allow overriding in mpconfigboard.mk. +# Some of these are on by default with CIRCUITPY_FULL_BUILD, but don't +# fit in 256kB of flash + CIRCUITPY_AUDIOMIXER ?= 0 CIRCUITPY_BINASCII ?= 0 +CIRCUITPY_BITBANGIO ?= 0 +CIRCUITPY_BITMAPTOOLS ?= 0 +CIRCUITPY_BUSDEVICE ?= 0 CIRCUITPY_AUDIOMP3 ?= 0 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_BUILTINS_POW3 ?= 0 CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 1 -CIRCUITPY_FREQUENCYIO ?= 0 -CIRCUITPY_JSON ?= 0 -CIRCUITPY_SYNTHIO ?= 0 -CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1 - -# No room for HCI _bleio on SAMD21. -CIRCUITPY_BLEIO_HCI = 0 - -CIRCUITPY_SDCARDIO ?= 0 - +CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 - -# Not enough room in 192kB or 256kB builds for secondary CDC. -CIRCUITPY_USB_CDC ?= 0 - +CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_I2CPERIPHERAL ?= 0 +CIRCUITPY_JSON ?= 0 +CIRCUITPY_MSGPACK ?= 0 +CIRCUITPY_RE ?= 0 +CIRCUITPY_SDCARDIO ?= 0 +CIRCUITPY_SYNTHIO ?= 0 +CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1 CIRCUITPY_ULAB = 0 +CIRCUITPY_VECTORIO = 0 + +MICROPY_PY_ASYNC_AWAIT = 0 ifeq ($(TRANSLATION), ja) RELEASE_NEEDS_CLEAN_BUILD = 1 @@ -67,6 +70,14 @@ RELEASE_NEEDS_CLEAN_BUILD = 1 CIRCUITPY_TERMINALIO = 0 endif +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +ifeq ($(CIRCUITPY_FULL_BUILD),0) +# On the smallest boards, this saves about 180 bytes. On other boards, it may -increase- space used. +CFLAGS_BOARD = -fweb -frename-registers +endif + endif # samd21 ###################################################################### diff --git a/ports/cxd56/mpconfigport.h b/ports/cxd56/mpconfigport.h index 27c82337bc..4c332577e6 100644 --- a/ports/cxd56/mpconfigport.h +++ b/ports/cxd56/mpconfigport.h @@ -32,6 +32,15 @@ // 64kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE (0x10000) +// CXD56 architecture uses fixed endpoint numbers. +// Override default definitions in circuitpy_mpconfig.h, +// so define these before #include'ing that file. +#define USB_CDC_EP_NUM_NOTIFICATION (3) +#define USB_CDC_EP_NUM_DATA_OUT (2) +#define USB_CDC_EP_NUM_DATA_IN (2) +#define USB_MSC_EP_NUM_OUT (5) +#define USB_MSC_EP_NUM_IN (4) + #include "py/circuitpy_mpconfig.h" #define MICROPY_BYTES_PER_GC_BLOCK (32) diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index e767c6326f..5dbc71825d 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -1,11 +1,4 @@ -USB_SERIAL_NUMBER_LENGTH = 10 USB_HIGHSPEED = 1 -USB_RENUMBER_ENDPOINTS = 0 -USB_CDC_EP_NUM_NOTIFICATION = 3 -USB_CDC_EP_NUM_DATA_OUT = 2 -USB_CDC_EP_NUM_DATA_IN = 1 -USB_MSC_EP_NUM_OUT = 5 -USB_MSC_EP_NUM_IN = 4 # Number of USB endpoint pairs. USB_NUM_EP = 6 diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk index 5073d8812d..2671c30558 100644 --- a/ports/esp32s2/mpconfigport.mk +++ b/ports/esp32s2/mpconfigport.mk @@ -6,9 +6,6 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz # Internal math library is substantially smaller than toolchain one INTERNAL_LIBM = 1 -# Chip supplied serial number, in bytes -USB_SERIAL_NUMBER_LENGTH = 12 - # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index de37e40ffc..d99b303f6d 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -9,9 +9,6 @@ INTERNAL_LIBM = 1 # Number of USB endpoint pairs. USB_NUM_EP = 16 -# Chip supplied serial number, in bytes -USB_SERIAL_NUMBER_LENGTH = 30 - # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index 49fc4a2aaa..31b0dbfdac 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -14,7 +14,6 @@ endif INTERNAL_LIBM = 1 -USB_SERIAL_NUMBER_LENGTH = 32 USB_HIGHSPEED = 1 # Number of USB endpoint pairs. diff --git a/ports/nrf/bluetooth/ble_uart.c b/ports/nrf/bluetooth/ble_uart.c index df64568678..022b866ce6 100644 --- a/ports/nrf/bluetooth/ble_uart.c +++ b/ports/nrf/bluetooth/ble_uart.c @@ -40,7 +40,7 @@ #include "shared-bindings/_bleio/Service.h" #include "shared-bindings/_bleio/UUID.h" -#if CIRCUITPY_REPL_BLE +#if CIRCUITPY_CONSOLE_BLE static const char default_name[] = "CP-REPL"; // max 8 chars or uuid won't fit in adv data static const char NUS_UUID[] = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"; @@ -188,4 +188,4 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { } } -#endif // CIRCUITPY_REPL_BLE +#endif // CIRCUITPY_CONSOLE_BLE diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index dd59eb96c9..9fae5ccc4d 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -9,25 +9,24 @@ INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_ALARM = 0 CIRCUITPY_AUDIOMP3 = 0 +CIRCUITPY_BINASCII = 0 CIRCUITPY_BITBANGIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 -CIRCUITPY_BUSIO = 1 +CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 +CIRCUITPY_JSON = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_RE = 0 CIRCUITPY_RGBMATRIX = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 1 CIRCUITPY_SDCARDIO = 0 -CIRCUITPY_TOUCHIO = 0 CIRCUITPY_ULAB = 0 -CIRCUITPY_BUSDEVICE = 0 + MICROPY_PY_ASYNC_AWAIT = 0 SUPEROPT_GC = 0 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index bf02321410..b00a051479 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -9,8 +9,6 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz INTERNAL_LIBM = 1 -USB_SERIAL_NUMBER_LENGTH = 16 - # Number of USB endpoint pairs. USB_NUM_EP = 8 diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c index 10bdb2819a..41aa34721a 100644 --- a/ports/nrf/supervisor/serial.c +++ b/ports/nrf/supervisor/serial.c @@ -28,15 +28,15 @@ #include "supervisor/serial.h" -#if CIRCUITPY_REPL_BLE +#if CIRCUITPY_CONSOLE_BLE #include "ble_uart.h" -#elif CIRCUITPY_REPL_UART +#elif CIRCUITPY_CONSOLE_UART #include #include "nrf_gpio.h" #include "nrfx_uarte.h" #endif -#if CIRCUITPY_REPL_BLE +#if CIRCUITPY_CONSOLE_BLE void serial_init(void) { ble_uart_init(); @@ -58,7 +58,7 @@ void serial_write(const char *text) { ble_uart_stdout_tx_str(text); } -#elif CIRCUITPY_REPL_UART +#elif CIRCUITPY_CONSOLE_UART uint8_t serial_received_char; nrfx_uarte_t serial_instance = NRFX_UARTE_INSTANCE(0); @@ -124,4 +124,4 @@ void serial_write_substring(const char *text, uint32_t len) { } } -#endif // CIRCUITPY_REPL_UART +#endif // CIRCUITPY_CONSOLE_UART diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index ed0eeba8f0..75c5d227f0 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -48,8 +48,6 @@ CIRCUITPY_AUDIOMIXER = 1 INTERNAL_LIBM = 1 -USB_SERIAL_NUMBER_LENGTH = 16 - # Number of USB endpoint pairs. USB_NUM_EP = 8 diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index 9148160286..efbbaa22e2 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -9,8 +9,6 @@ MCU_SERIES = F4 MCU_VARIANT = STM32F401xE MCU_PACKAGE = UFQFPN48 -OPTIMIZATION_FLAGS = -Os - LD_COMMON = boards/common_default.ld # use for internal flash LD_FILE = boards/STM32F401xd_fs.ld @@ -19,11 +17,15 @@ LD_FILE = boards/STM32F401xd_fs.ld # INTERNAL_FLASH_FILESYSTEM. It can probably be reenabled if we enable # lto for this port, and if other stuff hasn't been added in the # meantime -CIRCUITPY_ULAB = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_ULAB = 0 +CIRCUITPY_VECTORIO = 0 SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +OPTIMIZATION_FLAGS = -Os diff --git a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk index 211a658967..2dff6e8955 100644 --- a/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk +++ b/ports/stm/boards/stm32f411ce_blackpill_with_flash/mpconfigboard.mk @@ -17,4 +17,5 @@ MCU_PACKAGE = UFQFPN48 LD_COMMON = boards/common_default.ld LD_FILE = boards/STM32F411_nvm_nofs.ld -CIRCUITPY_SYNTHIO = 0 +CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_VECTORIO = 0 diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index abddd63a63..ae021426df 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -1,7 +1,6 @@ MPY_TOOL_LONGINT_IMPL ?= -mlongint-impl=mpz LONGINT_IMPL ?= MPZ INTERNAL_LIBM ?= 1 -USB_SERIAL_NUMBER_LENGTH ?= 24 ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F405xx STM32F407xx)) CIRCUITPY_CANIO = 1 diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index e68d509ebc..e722645c35 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -994,4 +994,57 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_VERBOSE_BLE 0 +// USB settings + +// If the port requires certain USB endpoint numbers, define these in mpconfigport.h. + +#ifndef USB_CDC_EP_NUM_NOTIFICATION +#define USB_CDC_EP_NUM_NOTIFICATION (0) +#endif + +#ifndef USB_CDC_EP_NUM_DATA_OUT +#define USB_CDC_EP_NUM_DATA_OUT (0) +#endif + +#ifndef USB_CDC_EP_NUM_DATA_IN +#define USB_CDC_EP_NUM_DATA_IN (0) +#endif + +#ifndef USB_CDC2_EP_NUM_NOTIFICATION +#define USB_CDC2_EP_NUM_NOTIFICATION (0) +#endif + +#ifndef USB_CDC2_EP_NUM_DATA_OUT +#define USB_CDC2_EP_NUM_DATA_OUT (0) +#endif + +#ifndef USB_CDC2_EP_NUM_DATA_IN +#define USB_CDC2_EP_NUM_DATA_IN (0) +#endif + +#ifndef USB_MSC_EP_NUM_OUT +#define USB_MSC_EP_NUM_OUT (0) +#endif + +#ifndef USB_MSC_EP_NUM_IN +#define USB_MSC_EP_NUM_IN (0) +#endif + +#ifndef USB_HID_EP_NUM_OUT +#define USB_HID_EP_NUM_OUT (0) +#endif + +#ifndef USB_HID_EP_NUM_IN +#define USB_HID_EP_NUM_IN (0) +#endif + +#ifndef USB_MIDI_EP_NUM_OUT +#define USB_MIDI_EP_NUM_OUT (0) +#endif + +#ifndef USB_MIDI_EP_NUM_IN +#define USB_MIDI_EP_NUM_IN (0) +#endif + + #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index cee70f62ff..295682e905 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -133,12 +133,32 @@ CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 0 CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) +CIRCUITPY_CONSOLE_BLE ?= 0 +CFLAGS += -DCIRCUITPY_CONSOLE_BLE=$(CIRCUITPY_CONSOLE_BLE) + +CIRCUITPY_CONSOLE_UART ?= 0 +CFLAGS += -DCIRCUITPY_CONSOLE_UART=$(CIRCUITPY_CONSOLE_UART) + CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO) +# bitmaptools and framebufferio rely on displayio +ifeq ($(CIRCUITPY_DISPLAYIO),1) +CIRCUITPY_BITMAPTOOLS ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_VECTORIO ?= 1 +else +CIRCUITPY_BITMAPTOOLS ?= 0 +CIRCUITPY_FRAMEBUFFERIO ?= 0 +CIRCUITPY_VECTORIO ?= 0 +endif +CFLAGS += -DCIRCUITPY_BITMAPTOOLS=$(CIRCUITPY_BITMAPTOOLS) +CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO) +CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO) + CIRCUITPY_DUALBANK ?= 0 CFLAGS += -DCIRCUITPY_DUALBANK=$(CIRCUITPY_DUALBANK) @@ -155,20 +175,6 @@ CFLAGS += -DCIRCUITPY_ERRNO=$(CIRCUITPY_ERRNO) CIRCUITPY_ESPIDF ?= 0 CFLAGS += -DCIRCUITPY_ESPIDF=$(CIRCUITPY_ESPIDF) -# bitmaptools and framebufferio rely on displayio -ifeq ($(CIRCUITPY_DISPLAYIO),1) -CIRCUITPY_BITMAPTOOLS ?= $(CIRCUITPY_FULL_BUILD) -CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) -else -CIRCUITPY_BITMAPTOOLS ?= 0 -CIRCUITPY_FRAMEBUFFERIO ?= 0 -endif -CFLAGS += -DCIRCUITPY_BITMAPTOOLS=$(CIRCUITPY_BITMAPTOOLS) -CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO) - -CIRCUITPY_VECTORIO ?= $(CIRCUITPY_DISPLAYIO) -CFLAGS += -DCIRCUITPY_VECTORIO=$(CIRCUITPY_VECTORIO) - CIRCUITPY_FREQUENCYIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO) @@ -246,15 +252,6 @@ CFLAGS += -DCIRCUITPY_RE=$(CIRCUITPY_RE) CIRCUITPY_RE_DEBUG ?= 0 CFLAGS += -DCIRCUITPY_RE_DEBUG=$(CIRCUITPY_RE_DEBUG) -CIRCUITPY_REPL_BLE ?= 0 -CFLAGS += -DCIRCUITPY_REPL_BLE=$(CIRCUITPY_REPL_BLE) - -CIRCUITPY_REPL_UART ?= 0 -CFLAGS += -DCIRCUITPY_REPL_UART=$(CIRCUITPY_REPL_UART) - -CIRCUITPY_REPL_USB ?= 1 -CFLAGS += -DCIRCUITPY_REPL_USB=$(CIRCUITPY_REPL_USB) - # Should busio.I2C() check for pullups? # Some boards in combination with certain peripherals may not want this. CIRCUITPY_REQUIRE_I2C_PULLUPS ?= 1 @@ -335,41 +332,31 @@ CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP) CIRCUITPY_USB ?= 1 CFLAGS += -DCIRCUITPY_USB=$(CIRCUITPY_USB) -# Disable by default for now, until we have dynamic enabling. -CIRCUITPY_USB_CDC ?= 0 -# Secondary CDC is usually available if there are at least 8 endpoints. -#CIRCUITPY_USB_CDC ?= $(shell expr $(USB_NUM_EP) '>=' 8) +# Compute this value once, so the shell command is not reinvoked many times. +USB_NUM_EP_8_OR_GREATER := $(shell expr $(USB_NUM_EP) '>=' 8) + +CIRCUITPY_USB_CDC ?= 1 CFLAGS += -DCIRCUITPY_USB_CDC=$(CIRCUITPY_USB_CDC) +CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT ?= 1 +CFLAGS += -DCIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT=$(CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT) +CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT ?= 0 +CFLAGS += -DCIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT=$(CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT) CIRCUITPY_USB_HID ?= 1 CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID) +CIRCUITPY_USB_HID_ENABLED_DEFAULT = $(CIRCUITPY_USB_HID) +CFLAGS += -DCIRCUITPY_USB_HID_ENABLED_DEFAULT=$(CIRCUITPY_USB_HID_ENABLED_DEFAULT) -CIRCUITPY_USB_HID_CONSUMER ?= 1 -CFLAGS += -DCIRCUITPY_USB_HID_CONSUMER=$(CIRCUITPY_USB_HID_CONSUMER) - -CIRCUITPY_USB_HID_DIGITIZER ?= 0 -CFLAGS += -DCIRCUITPY_USB_HID_DIGITIZER=$(CIRCUITPY_USB_HID_DIGITIZER) - -CIRCUITPY_USB_HID_GAMEPAD ?= 1 -CFLAGS += -DCIRCUITPY_USB_HID_GAMEPAD=$(CIRCUITPY_USB_HID_GAMEPAD) - -CIRCUITPY_USB_HID_KEYBOARD ?= 1 -CFLAGS += -DCIRCUITPY_USB_HID_KEYBOARD=$(CIRCUITPY_USB_HID_KEYBOARD) - -CIRCUITPY_USB_HID_MOUSE ?= 1 -CFLAGS += -DCIRCUITPY_USB_HID_MOUSE=$(CIRCUITPY_USB_HID_MOUSE) - -CIRCUITPY_USB_HID_SYS_CONTROL ?= 0 -CFLAGS += -DCIRCUITPY_USB_HID_SYS_CONTROL=$(CIRCUITPY_USB_HID_SYS_CONTROL) - -CIRCUITPY_USB_HID_XAC_COMPATIBLE_GAMEPAD ?= 0 -CFLAGS += -DCIRCUITPY_USB_HID_XAC_COMPATIBLE_GAMEPAD=$(CIRCUITPY_USB_HID_XAC_COMPATIBLE_GAMEPAD) - -CIRCUITPY_USB_MIDI ?= 1 +# MIDI is usually available if there are at least 8 endpoints. +CIRCUITPY_USB_MIDI ?= $(USB_NUM_EP_8_OR_GREATER) CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI) +CIRCUITPY_USB_MIDI_ENABLED_DEFAULT = $(CIRCUITPY_USB_MIDI) +CFLAGS += -DCIRCUITPY_USB_MIDI_ENABLED_DEFAULT=$(CIRCUITPY_USB_MIDI_ENABLED_DEFAULT) CIRCUITPY_USB_MSC ?= 1 CFLAGS += -DCIRCUITPY_USB_MSC=$(CIRCUITPY_USB_MSC) +CIRCUITPY_USB_MSC_ENABLED_DEFAULT = $(CIRCUITPY_USB_MSC) +CFLAGS += -DCIRCUITPY_USB_MSC_ENABLED_DEFAULT=$(CIRCUITPY_USB_MSC_ENABLED_DEFAULT) # Defaulting this to OFF initially because it has only been tested on a # limited number of platforms, and the other platforms do not have this @@ -380,6 +367,7 @@ CFLAGS += -DCIRCUITPY_USB_VENDOR=$(CIRCUITPY_USB_VENDOR) ifndef USB_NUM_EP $(error "USB_NUM_EP (number of USB endpoint pairs)must be defined") endif +CFLAGS += -DUSB_NUM_EP=$(USB_NUM_EP) # For debugging. CIRCUITPY_USTACK ?= 0 diff --git a/py/repl.c b/py/repl.c index ac88e91114..7ceae573d4 100644 --- a/py/repl.c +++ b/py/repl.c @@ -153,7 +153,7 @@ STATIC bool test_qstr(mp_obj_t obj, qstr name) { } else { // try builtin module return mp_map_lookup((mp_map_t *)&mp_builtin_module_map, - MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP); + MP_OBJ_NEW_QSTR(name), MP_MAP_LOOKUP) != NULL; } } diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 8e8fe73beb..754b6866c8 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -158,14 +158,45 @@ mp_obj_t storage_erase_filesystem(void) { } MP_DEFINE_CONST_FUN_OBJ_0(storage_erase_filesystem_obj, storage_erase_filesystem); +//| def disable_usb_drive() -> None: +//| """Disable presenting ``CIRCUITPY`` as a USB mass storage device. +//| By default, the device is enabled and ``CIRCUITPY`` is visible. +//| Can be called in ``boot.py``, before USB is connected.""" +//| ... +//| +STATIC mp_obj_t storage_disable_usb_drive(void) { + if (!common_hal_storage_disable_usb_drive()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(storage_disable_usb_drive_obj, storage_disable_usb_drive); + +//| def enable_usb_drive() -> None: +//| """Enabled presenting ``CIRCUITPY`` as a USB mass storage device. +//| By default, the device is enabled and ``CIRCUITPY`` is visible, +//| so you do not normally need to call this function. +//| Can be called in ``boot.py``, before USB is connected.""" +//| ... +//| +STATIC mp_obj_t storage_enable_usb_drive(void) { + if (!common_hal_storage_enable_usb_drive()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(storage_enable_usb_drive_obj, storage_enable_usb_drive); + STATIC const mp_rom_map_elem_t storage_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) }, - { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) }, - { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) }, - { MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) }, - { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) }, - { MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) }, + { MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) }, + { MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) }, + { MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) }, + { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) }, + { MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) }, + { MP_ROM_QSTR(MP_QSTR_disable_usb_drive), MP_ROM_PTR(&storage_disable_usb_drive_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable_usb_drive), MP_ROM_PTR(&storage_enable_usb_drive_obj) }, //| class VfsFat: //| def __init__(self, block_device: str) -> None: diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h index eeb0d3a73b..fbf492efab 100644 --- a/shared-bindings/storage/__init__.h +++ b/shared-bindings/storage/__init__.h @@ -30,6 +30,8 @@ #include #include +#include "shared-module/storage/__init__.h" + void common_hal_storage_mount(mp_obj_t vfs_obj, const char *path, bool readonly); void common_hal_storage_umount_path(const char *path); void common_hal_storage_umount_object(mp_obj_t vfs_obj); @@ -37,4 +39,7 @@ void common_hal_storage_remount(const char *path, bool readonly, bool disable_co mp_obj_t common_hal_storage_getmount(const char *path); void common_hal_storage_erase_filesystem(void); +bool common_hal_storage_disable_usb_drive(void); +bool common_hal_storage_enable_usb_drive(void); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index 9e9ccb898d..557c06a3ec 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -36,24 +36,100 @@ //| """USB CDC Serial streams //| -//| The `usb_cdc` module allows access to USB CDC (serial) communications.""" +//| The `usb_cdc` module allows access to USB CDC (serial) communications. //| -//| serials: Tuple[Serial, ...] -//| """Tuple of all CDC streams. Each item is a `Serial`. -//| ``serials[0]`` is the USB REPL connection. -//| ``serials[1]`` is a second USB serial connection, unconnected to the REPL. +//| On Windows, each `Serial` is visible as a separate COM port. The ports will often +//| be assigned consecutively, `console` first, but this is not always true. +//| +//| On Linux, the ports are typically ``/dev/ttyACM0`` and ``/dev/ttyACM1``. +//| The `console` port will usually be first. +//| +//| On MacOS, the ports are typically ``/dev/cu.usbmodem``. The something +//| varies based on the USB bus and port used. The `console` port will usually be first. //| """ //| +//| console: Optional[Serial] +//| """The `console` `Serial` object is used for the REPL, and for `sys.stdin` and `sys.stdout`. +//| `console` is ``None`` if disabled. +//| +//| However, note that`sys.stdin` and `sys.stdout` are text-based streams, +//| and the `console` object is a binary stream. +//| You do not normally need to write to `console` unless you wnat to write binary data. +//| """ +//| +//| data: Optional[Serial] +//| """A `Serial` object that can be used to send and receive binary data to and from +//| the host. +//| Note that `data` is *disabled* by default. ``data`` is ``None`` if disabled.""" -static const mp_map_elem_t usb_cdc_module_globals_table[] = { +//| def disable() -> None: +//| """Do not present any USB CDC device to the host. +//| Can be called in ``boot.py``, before USB is connected. +//| Equivalent to ``usb_cdc.enable(console=False, data=False)``.""" +//| ... +//| +STATIC mp_obj_t usb_cdc_disable(void) { + if (!common_hal_usb_cdc_disable()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(usb_cdc_disable_obj, usb_cdc_disable); + +//| def enable(*, console: bool = True, data: bool = False) -> None: +//| """Enable or disable each CDC device. Can be called in ``boot.py``, before USB is connected. +//| +//| :param console bool: Enable or disable the `console` USB serial device. +//| True to enable; False to disable. Enabled by default. +//| :param data bool: Enable or disable the `data` USB serial device. +//| True to enable; False to disable. *Disabled* by default.""" +//| ... +//| +STATIC mp_obj_t usb_cdc_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_console, ARG_data }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_console, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true } }, + { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + if (!common_hal_usb_cdc_enable(args[ARG_console].u_bool, args[ARG_data].u_bool)) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(usb_cdc_enable_obj, 0, usb_cdc_enable); + +// The usb_cdc module dict is mutable so that .console and .data may +// be set to a Serial or to None depending on whether they are enabled or not. +static mp_map_elem_t usb_cdc_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usb_cdc) }, { MP_ROM_QSTR(MP_QSTR_Serial), MP_OBJ_FROM_PTR(&usb_cdc_serial_type) }, - { MP_ROM_QSTR(MP_QSTR_serials), MP_OBJ_FROM_PTR(&usb_cdc_serials_tuple) }, + { MP_ROM_QSTR(MP_QSTR_console), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_data), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_disable), MP_OBJ_FROM_PTR(&usb_cdc_disable_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable), MP_OBJ_FROM_PTR(&usb_cdc_enable_obj) }, }; -static MP_DEFINE_CONST_DICT(usb_cdc_module_globals, usb_cdc_module_globals_table); +static MP_DEFINE_MUTABLE_DICT(usb_cdc_module_globals, usb_cdc_module_globals_table); const mp_obj_module_t usb_cdc_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&usb_cdc_module_globals, }; + +static void set_module_dict_entry(mp_obj_t key_qstr, mp_obj_t serial_obj) { + mp_map_elem_t *elem = mp_map_lookup(&usb_cdc_module_globals.map, key_qstr, MP_MAP_LOOKUP); + if (elem) { + elem->value = serial_obj; + } +} + +void usb_cdc_set_console(mp_obj_t serial_obj) { + set_module_dict_entry(MP_ROM_QSTR(MP_QSTR_console), serial_obj); +} + +void usb_cdc_set_data(mp_obj_t serial_obj) { + set_module_dict_entry(MP_ROM_QSTR(MP_QSTR_data), serial_obj); +} diff --git a/shared-bindings/usb_cdc/__init__.h b/shared-bindings/usb_cdc/__init__.h index e81d243e6c..0a517f4cec 100644 --- a/shared-bindings/usb_cdc/__init__.h +++ b/shared-bindings/usb_cdc/__init__.h @@ -29,4 +29,11 @@ #include "shared-module/usb_cdc/__init__.h" +// Set the module dict entries. +void usb_cdc_set_console(mp_obj_t serial_obj); +void usb_cdc_set_data(mp_obj_t serial_obj); + +extern bool common_hal_usb_cdc_disable(void); +extern bool common_hal_usb_cdc_enable(bool console, bool data); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_CDC___INIT___H diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index cd4f3dd54b..511966731c 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -26,23 +26,100 @@ #include "py/objproperty.h" #include "shared-bindings/usb_hid/Device.h" +#include "py/runtime.h" //| class Device: -//| """HID Device +//| """HID Device specification""" //| -//| Usage:: +//| def __init__(self, *, descriptor: ReadableBuffer, usage_page: int, usage: int, in_report_length: int, out_report_length: int = 0, report_id_index: Optional[int]) -> None: +//| """Create a description of a USB HID device. The actual device is created when you +//| pass a `Device` to `usb_hid.enable()`. //| -//| import usb_hid -//| -//| mouse = usb_hid.devices[0] -//| -//| mouse.send_report()""" -//| - -//| def __init__(self) -> None: -//| """Not currently dynamically supported.""" +//| :param ReadableBuffer report_descriptor: The USB HID Report descriptor bytes. The descriptor is not +//| not verified for correctness; it is up to you to make sure it is not malformed. +//| :param int usage_page: The Usage Page value from the descriptor. Must match what is in the descriptor. +//| :param int usage: The Usage value from the descriptor. Must match what is in the descriptor. +//| :param int in_report_length: Size in bytes of the HID report sent to the host. +//| "In" is with respect to the host. +//| :param int out_report_length: Size in bytes of the HID report received from the host. +//| "Out" is with respect to the host. If no reports are expected, use 0. +//| :param int report_id_index: position of byte in descriptor that contains the Report ID. +//| A Report ID will be assigned when the device is created. If there is no +//| Report ID, use ``None``. +//| """ //| ... //| +//| KEYBOARD: Device +//| """Standard keyboard device supporting keycodes 0x00-0xDD, modifiers 0xE-0xE7, and five LED indicators.""" +//| +//| MOUSE: Device +//| """Standard mouse device supporting five mouse buttons, X and Y relative movements from -127 to 127 +//| in each report, and a relative mouse wheel change from -127 to 127 in each report.""" +//| +//| CONSUMER_CONTROL: Device +//| """Consumer Control device supporting sent values from 1-652, with no rollover.""" +//| + +STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + usb_hid_device_obj_t *self = m_new_obj(usb_hid_device_obj_t); + self->base.type = &usb_hid_device_type; + enum { ARG_report_descriptor, ARG_usage_page, ARG_usage, ARG_in_report_length, ARG_out_report_length, ARG_report_id_index }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_report_descriptor, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_usage_page, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_usage, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_in_report_length, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, + { MP_QSTR_out_report_length, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_int = 0 } }, + { MP_QSTR_report_id_index, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none } }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_report_descriptor].u_obj, &bufinfo, MP_BUFFER_READ); + mp_obj_t descriptor = mp_obj_new_bytearray(bufinfo.len, bufinfo.buf); + + const mp_int_t usage_page_arg = args[ARG_usage_page].u_int; + if (usage_page_arg <= 0 || usage_page_arg > 255) { + mp_raise_ValueError_varg(translate("%q must be 1-255"), MP_QSTR_usage_page); + } + const uint8_t usage_page = usage_page_arg; + + const mp_int_t usage_arg = args[ARG_usage].u_int; + if (usage_arg <= 0 || usage_arg > 255) { + mp_raise_ValueError_varg(translate("%q must be 1-255"), MP_QSTR_usage); + } + const uint8_t usage = usage_arg; + + const mp_int_t in_report_length_arg = args[ARG_in_report_length].u_int; + if (in_report_length_arg <= 0 || in_report_length_arg > 255) { + mp_raise_ValueError_varg(translate("%q must be 1-255"), MP_QSTR_in_report_length); + } + const uint8_t in_report_length = in_report_length_arg; + + const mp_int_t out_report_length_arg = args[ARG_out_report_length].u_int; + if (out_report_length_arg <= 0 || out_report_length_arg > 255) { + mp_raise_ValueError_varg(translate("%q must be 1-255"), MP_QSTR_out_report_length); + } + const uint8_t out_report_length = out_report_length_arg; + + const mp_obj_t report_id_index_arg = args[ARG_report_id_index].u_obj; + uint8_t report_id_index = 0; + if (report_id_index_arg != mp_const_none) { + const mp_int_t report_id_index_int = mp_obj_int_get_checked(report_id_index_arg); + if (report_id_index_int <= 0 || report_id_index_int > 255) { + mp_raise_ValueError_varg(translate("%q must be None or 1-255"), MP_QSTR_report_id_index); + } + report_id_index = report_id_index_int; + } + + common_hal_usb_hid_device_construct( + self, descriptor, usage_page, usage, in_report_length, out_report_length, report_id_index); + return (mp_obj_t)self; +} + + //| def send_report(self, buf: ReadableBuffer) -> None: //| """Send a HID report.""" //| ... @@ -116,8 +193,11 @@ const mp_obj_property_t usb_hid_device_usage_obj = { STATIC const mp_rom_map_elem_t usb_hid_device_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_send_report), MP_ROM_PTR(&usb_hid_device_send_report_obj) }, { MP_ROM_QSTR(MP_QSTR_last_received_report), MP_ROM_PTR(&usb_hid_device_last_received_report_obj) }, - { MP_ROM_QSTR(MP_QSTR_usage_page), MP_ROM_PTR(&usb_hid_device_usage_page_obj)}, - { MP_ROM_QSTR(MP_QSTR_usage), MP_ROM_PTR(&usb_hid_device_usage_obj)}, + { MP_ROM_QSTR(MP_QSTR_usage_page), MP_ROM_PTR(&usb_hid_device_usage_page_obj) }, + { MP_ROM_QSTR(MP_QSTR_usage), MP_ROM_PTR(&usb_hid_device_usage_obj) }, + { MP_ROM_QSTR(MP_QSTR_KEYBOARD), MP_ROM_PTR(&usb_hid_device_keyboard_obj) }, + { MP_ROM_QSTR(MP_QSTR_MOUSE), MP_ROM_PTR(&usb_hid_device_mouse_obj) }, + { MP_ROM_QSTR(MP_QSTR_CONSUMER_CONTROL), MP_ROM_PTR(&usb_hid_device_consumer_control_obj) }, }; STATIC MP_DEFINE_CONST_DICT(usb_hid_device_locals_dict, usb_hid_device_locals_dict_table); @@ -125,5 +205,6 @@ STATIC MP_DEFINE_CONST_DICT(usb_hid_device_locals_dict, usb_hid_device_locals_di const mp_obj_type_t usb_hid_device_type = { { &mp_type_type }, .name = MP_QSTR_Device, + .make_new = usb_hid_device_make_new, .locals_dict = (mp_obj_t)&usb_hid_device_locals_dict, }; diff --git a/shared-bindings/usb_hid/Device.h b/shared-bindings/usb_hid/Device.h index d9918d4060..c1af92fd4f 100644 --- a/shared-bindings/usb_hid/Device.h +++ b/shared-bindings/usb_hid/Device.h @@ -27,10 +27,13 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_HID_DEVICE_H #define MICROPY_INCLUDED_SHARED_BINDINGS_USB_HID_DEVICE_H +#include "py/objarray.h" + #include "shared-module/usb_hid/Device.h" extern const mp_obj_type_t usb_hid_device_type; +void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t descriptor, uint8_t usage_page, uint8_t usage, uint8_t in_report_length, uint8_t out_report_length, uint8_t report_id_index); void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len); uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self); uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self); diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 1a2f28d431..8e85cc67f0 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -39,15 +39,66 @@ //| devices: Tuple[Device, ...] //| """Tuple of all active HID device interfaces.""" //| -STATIC const mp_rom_map_elem_t usb_hid_module_globals_table[] = { + +//| def disable() -> None: +//| """Do not present any USB HID devices to the host computer. +//| Can be called in ``boot.py``, before USB is connected.""" +STATIC mp_obj_t usb_hid_disable(void) { + if (!common_hal_usb_hid_disable()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable); + +//| def enable(devices: Optional[Sequence[Device]]) -> None: +//| """Specify which USB HID devices that will be available. +//| Can be called in ``boot.py``, before USB is connected. +//| +//| :param Sequence devices: `Device` objects. +//| If `devices` is empty, HID is disabled. The order of the ``Devices`` +//| may matter to the host. For instance, for MacOS, put the mouse device +//| before any Gamepad or Digitizer HID device or else it will not work. +//| """ +//| ... +//| +STATIC mp_obj_t usb_hid_enable(mp_obj_t devices) { + const mp_int_t len = mp_obj_get_int(mp_obj_len(devices)); + for (mp_int_t i = 0; i < len; i++) { + mp_obj_t item = mp_obj_subscr(devices, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL); + if (!mp_obj_is_type(item, &usb_hid_device_type)) { + mp_raise_ValueError_varg(translate("non-Device in %q"), MP_QSTR_devices); + } + } + + if (!common_hal_usb_hid_enable(devices)) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_enable_obj, usb_hid_enable); + +// usb_hid.devices is set once the usb devices are determined, after boot.py runs. +STATIC mp_map_elem_t usb_hid_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) }, - { MP_ROM_QSTR(MP_QSTR_devices), MP_ROM_PTR(&common_hal_usb_hid_devices) }, - { MP_ROM_QSTR(MP_QSTR_Device), MP_ROM_PTR(&usb_hid_device_type) }, + { MP_ROM_QSTR(MP_QSTR_Device), MP_OBJ_FROM_PTR(&usb_hid_device_type) }, + { MP_ROM_QSTR(MP_QSTR_devices), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_disable), MP_OBJ_FROM_PTR(&usb_hid_disable_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable), MP_OBJ_FROM_PTR(&usb_hid_enable_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(usb_hid_module_globals, usb_hid_module_globals_table); +STATIC MP_DEFINE_MUTABLE_DICT(usb_hid_module_globals, usb_hid_module_globals_table); const mp_obj_module_t usb_hid_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&usb_hid_module_globals, }; + +void usb_hid_set_devices(mp_obj_t devices) { + mp_map_elem_t *elem = + mp_map_lookup(&usb_hid_module_globals.map, MP_ROM_QSTR(MP_QSTR_devices), MP_MAP_LOOKUP); + if (elem) { + elem->value = devices; + } +} diff --git a/shared-bindings/usb_hid/__init__.h b/shared-bindings/usb_hid/__init__.h index 3d56fbfd02..d5fc7743a3 100644 --- a/shared-bindings/usb_hid/__init__.h +++ b/shared-bindings/usb_hid/__init__.h @@ -27,9 +27,15 @@ #ifndef SHARED_BINDINGS_USB_HID_H #define SHARED_BINDINGS_USB_HID_H -#include -#include +#include "py/obj.h" +#include "py/objtuple.h" +#include "shared-module/usb_hid/__init__.h" extern mp_obj_tuple_t common_hal_usb_hid_devices; -#endif // SHARED_BINDINGS_USB_HID_H +void usb_hid_set_devices(mp_obj_t devices); + +bool common_hal_usb_hid_disable(void); +bool common_hal_usb_hid_enable(const mp_obj_t devices_seq); + +#endif // SHARED_BINDINGS_USB_HID_H diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index 4bbe46fda5..a3ed06dd8c 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -43,11 +43,41 @@ //| """Tuple of all MIDI ports. Each item is ether `PortIn` or `PortOut`.""" //| +//| def disable() -> None: +//| """Disable presenting a USB MIDI device to the host. +//| The device is normally enabled by default. +//| Can be called in ``boot.py``, before USB is connected.""" +//| ... +//| +STATIC mp_obj_t usb_midi_disable(void) { + if (!common_hal_usb_midi_disable()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(usb_midi_disable_obj, usb_midi_disable); + +//| def enable() -> None: +//| """Enable presenting a USB MIDI device to the host. +//| The device is enabled by default, so you do not normally need to call this function. +//| Can be called in ``boot.py``, before USB is connected.""" +//| ... +//| +STATIC mp_obj_t usb_midi_enable(void) { + if (!common_hal_usb_midi_enable()) { + mp_raise_RuntimeError(translate("Cannot change USB devices now")); + } + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_0(usb_midi_enable_obj, usb_midi_enable); + mp_map_elem_t usb_midi_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usb_midi) }, - { MP_ROM_QSTR(MP_QSTR_ports), mp_const_empty_tuple }, + { MP_ROM_QSTR(MP_QSTR_disable), MP_OBJ_FROM_PTR(&usb_midi_disable_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable), MP_OBJ_FROM_PTR(&usb_midi_enable_obj) }, + { MP_ROM_QSTR(MP_QSTR_ports), mp_const_empty_tuple }, { MP_ROM_QSTR(MP_QSTR_PortIn), MP_OBJ_FROM_PTR(&usb_midi_portin_type) }, - { MP_ROM_QSTR(MP_QSTR_PortOut), MP_OBJ_FROM_PTR(&usb_midi_portout_type) }, + { MP_ROM_QSTR(MP_QSTR_PortOut), MP_OBJ_FROM_PTR(&usb_midi_portout_type) }, }; // This isn't const so we can set ports dynamically. diff --git a/shared-bindings/usb_midi/__init__.h b/shared-bindings/usb_midi/__init__.h index e81818e04c..b657cfe57b 100644 --- a/shared-bindings/usb_midi/__init__.h +++ b/shared-bindings/usb_midi/__init__.h @@ -28,7 +28,11 @@ #define MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI___INIT___H #include "py/obj.h" +#include "shared-module/usb_midi/__init__.h" extern mp_obj_dict_t usb_midi_module_globals; +bool common_hal_usb_midi_disable(void); +bool common_hal_usb_midi_enable(void); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI___INIT___H diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index c3de03e7b0..b1d038a7d3 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -40,6 +40,93 @@ #include "supervisor/flash.h" #include "supervisor/usb.h" +#if CIRCUITPY_USB_MSC +#include "tusb.h" + +static const uint8_t usb_msc_descriptor_template[] = { + // MSC Interface Descriptor + 0x09, // 0 bLength + 0x04, // 1 bDescriptorType (Interface) + 0xFF, // 2 bInterfaceNumber [SET AT RUNTIME] +#define MSC_INTERFACE_INDEX (2) + 0x00, // 3 bAlternateSetting + 0x02, // 4 bNumEndpoints 2 + 0x08, // 5 bInterfaceClass: MSC + 0x06, // 6 bInterfaceSubClass: TRANSPARENT + 0x50, // 7 bInterfaceProtocol: BULK + 0xFF, // 8 iInterface (String Index) [SET AT RUNTIME] +#define MSC_INTERFACE_STRING_INDEX (8) + + // MSC Endpoint IN Descriptor + 0x07, // 9 bLength + 0x05, // 10 bDescriptorType (Endpoint) + 0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define MSC_IN_ENDPOINT_INDEX (11) + 0x02, // 12 bmAttributes (Bulk) + 0x40, 0x00, // 13,14 wMaxPacketSize 64 + 0x00, // 15 bInterval 0 (unit depends on device speed) + + // MSC Endpoint OUT Descriptor + 0x07, // 16 bLength + 0x05, // 17 bDescriptorType (Endpoint) + 0xFF, // 18 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] +#define MSC_OUT_ENDPOINT_INDEX (18) + 0x02, // 19 bmAttributes (Bulk) + 0x40, 0x00, // 20,21 wMaxPacketSize 64 + 0x00, // 22 bInterval 0 (unit depends on device speed) +}; + +// Is the MSC device enabled? +bool storage_usb_is_enabled; + +void storage_usb_set_defaults(void) { + storage_usb_is_enabled = CIRCUITPY_USB_MSC_ENABLED_DEFAULT; +} + +bool storage_usb_enabled(void) { + return storage_usb_is_enabled; +} + +size_t storage_usb_descriptor_length(void) { + return sizeof(usb_msc_descriptor_template); +} + +static const char storage_interface_name[] = USB_INTERFACE_NAME " Mass Storage"; + +size_t storage_usb_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string) { + memcpy(descriptor_buf, usb_msc_descriptor_template, sizeof(usb_msc_descriptor_template)); + descriptor_buf[MSC_INTERFACE_INDEX] = *current_interface; + (*current_interface)++; + + descriptor_buf[MSC_IN_ENDPOINT_INDEX] = 0x80 | (USB_MSC_EP_NUM_IN ? USB_MSC_EP_NUM_IN : *current_endpoint); + descriptor_buf[MSC_OUT_ENDPOINT_INDEX] = USB_MSC_EP_NUM_OUT ? USB_MSC_EP_NUM_OUT : *current_endpoint; + (*current_endpoint)++; + + usb_add_interface_string(*current_interface_string, storage_interface_name); + descriptor_buf[MSC_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + return sizeof(usb_msc_descriptor_template); +} + +static bool usb_drive_set_enabled(bool enabled) { + // We can't change the descriptors once we're connected. + if (tud_connected()) { + return false; + } + storage_usb_is_enabled = enabled; + return true; +} + +bool common_hal_storage_disable_usb_drive(void) { + return usb_drive_set_enabled(false); +} + +bool common_hal_storage_enable_usb_drive(void) { + return usb_drive_set_enabled(true); +} +#endif // CIRCUITPY_USB_MSC + STATIC mp_obj_t mp_vfs_proxy_call(mp_vfs_mount_t *vfs, qstr meth_name, size_t n_args, const mp_obj_t *args) { if (vfs == MP_VFS_NONE) { // mount point not found @@ -150,8 +237,8 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa } #if CIRCUITPY_USB_MSC - if (!usb_msc_ejected()) { - mp_raise_RuntimeError(translate("Cannot remount '/' when USB is active.")); + if (!usb_msc_ejected() && storage_usb_is_enabled) { + mp_raise_RuntimeError(translate("Cannot remount '/' when visible via USB.")); } #endif diff --git a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c b/shared-module/storage/__init__.h similarity index 70% rename from ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c rename to shared-module/storage/__init__.h index 84960e73cf..addc8e3d05 100644 --- a/ports/atmel-samd/boards/feather_radiofruit_zigbee/board.c +++ b/shared-module/storage/__init__.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2021 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,14 +24,16 @@ * THE SOFTWARE. */ -#include "supervisor/board.h" +#ifndef SHARED_MODULE_STORAGE___INIT___H +#define SHARED_MODULE_STORAGE___INIT___H -void board_init(void) { -} +#include "py/mpconfig.h" -bool board_requests_safe_mode(void) { - return false; -} +#if CIRCUITPY_USB +bool storage_usb_enabled(void); +void storage_usb_set_defaults(void); +size_t storage_usb_descriptor_length(void); +size_t storage_usb_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string); +#endif -void reset_board(void) { -} +#endif // SHARED_MODULE_STORAGE___INIT___H diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index 3cf80a8b5c..446c65931e 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -24,7 +24,6 @@ * THE SOFTWARE. */ -#include "genhdr/autogen_usb_descriptor.h" #include "py/gc.h" #include "py/obj.h" #include "py/mphal.h" @@ -32,29 +31,211 @@ #include "py/objtuple.h" #include "shared-bindings/usb_cdc/__init__.h" #include "shared-bindings/usb_cdc/Serial.h" +#include "supervisor/usb.h" + #include "tusb.h" #if CFG_TUD_CDC != 2 #error CFG_TUD_CDC must be exactly 2 #endif -static usb_cdc_serial_obj_t serial_objs[CFG_TUD_CDC] = { - { .base.type = &usb_cdc_serial_type, - .timeout = -1.0f, - .write_timeout = -1.0f, - .idx = 0,}, { - .base.type = &usb_cdc_serial_type, - .timeout = -1.0f, - .write_timeout = -1.0f, - .idx = 1, - } +static const uint8_t usb_cdc_descriptor_template[] = { + // CDC IAD Descriptor + 0x08, // 0 bLength + 0x0B, // 1 bDescriptorType: IAD Descriptor + 0xFF, // 2 bFirstInterface [SET AT RUNTIME] +#define CDC_FIRST_INTERFACE_INDEX 2 + 0x02, // 3 bInterfaceCount: 2 + 0x02, // 4 bFunctionClass: COMM + 0x02, // 5 bFunctionSubclass: ACM + 0x00, // 6 bFunctionProtocol: NONE + 0x00, // 7 iFunction + + // CDC Comm Interface Descriptor + 0x09, // 8 bLength + 0x04, // 9 bDescriptorType (Interface) + 0xFF, // 10 bInterfaceNumber [SET AT RUNTIME] +#define CDC_COMM_INTERFACE_INDEX 10 + 0x00, // 11 bAlternateSetting + 0x01, // 12 bNumEndpoints 1 + 0x02, // 13 bInterfaceClass: COMM + 0x02, // 14 bInterfaceSubClass: ACM + 0x00, // 15 bInterfaceProtocol: NONE + 0xFF, // 16 iInterface (String Index) +#define CDC_COMM_INTERFACE_STRING_INDEX 16 + + // CDC Header Descriptor + 0x05, // 17 bLength + 0x24, // 18 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x00, // 19 bDescriptorSubtype: NONE + 0x10, 0x01, // 20,21 bcdCDC: 1.10 + + // CDC Call Management Descriptor + 0x05, // 22 bLength + 0x24, // 23 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x01, // 24 bDescriptorSubtype: CALL MANAGEMENT + 0x01, // 25 bmCapabilities + 0xFF, // 26 bDataInterface [SET AT RUNTIME] +#define CDC_CALL_MANAGEMENT_DATA_INTERFACE_INDEX 26 + + // CDC Abstract Control Management Descriptor + 0x04, // 27 bLength + 0x24, // 28 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x02, // 29 bDescriptorSubtype: ABSTRACT CONTROL MANAGEMENT + 0x02, // 30 bmCapabilities + + // CDC Union Descriptor + 0x05, // 31 bLength + 0x24, // 32 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x06, // 33 bDescriptorSubtype: CDC + 0xFF, // 34 bMasterInterface [SET AT RUNTIME] +#define CDC_UNION_MASTER_INTERFACE_INDEX 34 + 0xFF, // 35 bSlaveInterface_list (1 item) +#define CDC_UNION_SLAVE_INTERFACE_INDEX 35 + + // CDC Control IN Endpoint Descriptor + 0x07, // 36 bLength + 0x05, // 37 bDescriptorType (Endpoint) + 0xFF, // 38 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define CDC_CONTROL_IN_ENDPOINT_INDEX 38 + 0x03, // 39 bmAttributes (Interrupt) + 0x40, 0x00, // 40, 41 wMaxPacketSize 64 + 0x10, // 42 bInterval 16 (unit depends on device speed) + + // CDC Data Interface + 0x09, // 43 bLength + 0x04, // 44 bDescriptorType (Interface) + 0xFF, // 45 bInterfaceNumber [SET AT RUNTIME] +#define CDC_DATA_INTERFACE_INDEX 45 + 0x00, // 46 bAlternateSetting + 0x02, // 47 bNumEndpoints 2 + 0x0A, // 48 bInterfaceClass: DATA + 0x00, // 49 bInterfaceSubClass: NONE + 0x00, // 50 bInterfaceProtocol + 0x05, // 51 iInterface (String Index) +#define CDC_DATA_INTERFACE_STRING_INDEX 51 + + // CDC Data OUT Endpoint Descriptor + 0x07, // 52 bLength + 0x05, // 53 bDescriptorType (Endpoint) + 0xFF, // 54 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] +#define CDC_DATA_OUT_ENDPOINT_INDEX 54 + 0x02, // 55 bmAttributes (Bulk) + 0x40, 0x00, // 56,57 wMaxPacketSize 64 + 0x00, // 58 bInterval 0 (unit depends on device speed) + + // CDC Data IN Endpoint Descriptor + 0x07, // 59 bLength + 0x05, // 60 bDescriptorType (Endpoint) + 0xFF, // 61 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define CDC_DATA_IN_ENDPOINT_INDEX 61 + 0x02, // 62 bmAttributes (Bulk) + 0x40, 0x00, // 63,64 wMaxPacketSize 64 + 0x00, // 65 bInterval 0 (unit depends on device speed) }; -const mp_rom_obj_tuple_t usb_cdc_serials_tuple = { - .base.type = &mp_type_tuple, - .len = CFG_TUD_CDC, - .items = { - &serial_objs[0], - &serial_objs[1], - }, +static const char console_cdc_comm_interface_name[] = USB_INTERFACE_NAME " CDC control"; +static const char data_cdc_comm_interface_name[] = USB_INTERFACE_NAME " CDC2 control"; +static const char console_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC data"; +static const char data_cdc_data_interface_name[] = USB_INTERFACE_NAME " CDC2 data"; + +static usb_cdc_serial_obj_t usb_cdc_console_obj = { + .base.type = &usb_cdc_serial_type, + .timeout = -1.0f, + .write_timeout = -1.0f, + .idx = 0, }; + +static usb_cdc_serial_obj_t usb_cdc_data_obj = { + .base.type = &usb_cdc_serial_type, + .timeout = -1.0f, + .write_timeout = -1.0f, + .idx = 1, +}; + +static bool usb_cdc_console_is_enabled; +static bool usb_cdc_data_is_enabled; + +void usb_cdc_set_defaults(void) { + usb_cdc_console_is_enabled = CIRCUITPY_USB_CDC_CONSOLE_ENABLED_DEFAULT; + usb_cdc_data_is_enabled = CIRCUITPY_USB_CDC_DATA_ENABLED_DEFAULT; +} + +bool usb_cdc_console_enabled(void) { + return usb_cdc_console_is_enabled; +} + +bool usb_cdc_data_enabled(void) { + return usb_cdc_data_is_enabled; +} + +size_t usb_cdc_descriptor_length(void) { + return sizeof(usb_cdc_descriptor_template); +} + +size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string, bool console) { + memcpy(descriptor_buf, usb_cdc_descriptor_template, sizeof(usb_cdc_descriptor_template)); + + // Store comm interface number. + descriptor_buf[CDC_FIRST_INTERFACE_INDEX] = *current_interface; + descriptor_buf[CDC_COMM_INTERFACE_INDEX] = *current_interface; + descriptor_buf[CDC_UNION_MASTER_INTERFACE_INDEX] = *current_interface; + (*current_interface)++; + + // Now store data interface number. + descriptor_buf[CDC_CALL_MANAGEMENT_DATA_INTERFACE_INDEX] = *current_interface; + descriptor_buf[CDC_UNION_SLAVE_INTERFACE_INDEX] = *current_interface; + descriptor_buf[CDC_DATA_INTERFACE_INDEX] = *current_interface; + (*current_interface)++; + + descriptor_buf[CDC_CONTROL_IN_ENDPOINT_INDEX] = 0x80 | ( + console + ? (USB_CDC_EP_NUM_NOTIFICATION ? USB_CDC_EP_NUM_NOTIFICATION : *current_endpoint) + : (USB_CDC2_EP_NUM_NOTIFICATION ? USB_CDC2_EP_NUM_NOTIFICATION : *current_endpoint)); + (*current_endpoint)++; + + descriptor_buf[CDC_DATA_OUT_ENDPOINT_INDEX] = + console + ? (USB_CDC_EP_NUM_DATA_OUT ? USB_CDC_EP_NUM_DATA_OUT : *current_endpoint) + : (USB_CDC2_EP_NUM_DATA_OUT ? USB_CDC2_EP_NUM_DATA_OUT : *current_endpoint); + + descriptor_buf[CDC_DATA_IN_ENDPOINT_INDEX] = 0x80 | ( + console + ? (USB_CDC_EP_NUM_DATA_IN ? USB_CDC_EP_NUM_DATA_IN : *current_endpoint) + : (USB_CDC2_EP_NUM_DATA_IN ? USB_CDC2_EP_NUM_DATA_IN : *current_endpoint)); + (*current_endpoint)++; + + usb_add_interface_string(*current_interface_string, + console ? console_cdc_comm_interface_name : data_cdc_comm_interface_name); + descriptor_buf[CDC_COMM_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + usb_add_interface_string(*current_interface_string, + console ? console_cdc_data_interface_name : data_cdc_data_interface_name); + descriptor_buf[CDC_DATA_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + return sizeof(usb_cdc_descriptor_template); +} + +bool common_hal_usb_cdc_disable(void) { + return common_hal_usb_cdc_enable(false, false); +} + +bool common_hal_usb_cdc_enable(bool console, bool data) { + // We can't change the descriptors once we're connected. + if (tud_connected()) { + return false; + } + + // Right now these objects contain no heap objects, but if that changes, + // they will need to be protected against gc. + + usb_cdc_console_is_enabled = console; + usb_cdc_set_console(console ? MP_OBJ_FROM_PTR(&usb_cdc_console_obj) : mp_const_none); + + usb_cdc_data_is_enabled = data; + usb_cdc_set_data(data ? MP_OBJ_FROM_PTR(&usb_cdc_data_obj) : mp_const_none); + + return true; +} diff --git a/shared-module/usb_cdc/__init__.h b/shared-module/usb_cdc/__init__.h index 9de3eb2faa..ae39143017 100644 --- a/shared-module/usb_cdc/__init__.h +++ b/shared-module/usb_cdc/__init__.h @@ -27,8 +27,15 @@ #ifndef SHARED_MODULE_USB_CDC___INIT___H #define SHARED_MODULE_USB_CDC___INIT___H +#include "py/mpconfig.h" #include "py/objtuple.h" -extern const mp_rom_obj_tuple_t usb_cdc_serials_tuple; +bool usb_cdc_console_enabled(void); +bool usb_cdc_data_enabled(void); + +void usb_cdc_set_defaults(void); + +size_t usb_cdc_descriptor_length(void); +size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string, bool repl); #endif /* SHARED_MODULE_USB_CDC___INIT___H */ diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 4f392847ff..7650854de3 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -26,13 +26,164 @@ #include +#include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/usb_hid/Device.h" +#include "shared-module/usb_hid/__init__.h" #include "shared-module/usb_hid/Device.h" #include "supervisor/shared/translate.h" #include "supervisor/shared/tick.h" #include "tusb.h" +static const uint8_t keyboard_report_descriptor[] = { + 0x05, 0x01, // 0,1 Usage Page (Generic Desktop Ctrls) + 0x09, 0x06, // 2,3 Usage (Keyboard) + 0xA1, 0x01, // 4,5 Collection (Application) + 0x85, 0xFF, // 6,7 Report ID [SET AT RUNTIME] +#define KEYBOARD_REPORT_ID_INDEX (7) + 0x05, 0x07, // Usage Page (Kbrd/Keypad) + 0x19, 0xE0, // Usage Minimum (0xE0) + 0x29, 0xE7, // Usage Maximum (0xE7) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x75, 0x01, // Report Size (1) + 0x95, 0x08, // Report Count (8) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x19, 0x00, // Usage Minimum (0x00) + 0x29, 0xDD, // Usage Maximum (0xDD) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0xDD, // Logical Maximum (-35) + 0x75, 0x08, // Report Size (8) + 0x95, 0x06, // Report Count (6) + 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x05, 0x08, // Usage Page (LEDs) + 0x19, 0x01, // Usage Minimum (Num Lock) + 0x29, 0x05, // Usage Maximum (Kana) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x75, 0x01, // Report Size (1) + 0x95, 0x05, // Report Count (5) + 0x91, 0x02, // Output (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0x95, 0x03, // Report Count (3) + 0x91, 0x01, // Output (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) + 0xC0, // End Collection +}; + +const usb_hid_device_obj_t usb_hid_device_keyboard_obj = { + .base = { + .type = &usb_hid_device_type, + }, + .report_descriptor = keyboard_report_descriptor, + .report_descriptor_length = sizeof(keyboard_report_descriptor), + .usage_page = 0x01, + .usage = 0x06, + .in_report_length = 8, + .out_report_length = 1, + .report_id_index = KEYBOARD_REPORT_ID_INDEX, + +}; + +static const uint8_t mouse_report_descriptor[] = { + 0x05, 0x01, // 0,1 Usage Page (Generic Desktop Ctrls) + 0x09, 0x02, // 2,3 Usage (Mouse) + 0xA1, 0x01, // 4,5 Collection (Application) + 0x09, 0x01, // 6,7 Usage (Pointer) + 0xA1, 0x00, // 8,9 Collection (Physical) + 0x85, 0xFF, // 10, 11 Report ID [SET AT RUNTIME] +#define MOUSE_REPORT_ID_INDEX (11) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (0x01) + 0x29, 0x05, // Usage Maximum (0x05) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x05, // Report Count (5) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x95, 0x01, // Report Count (1) + 0x75, 0x03, // Report Size (3) + 0x81, 0x01, // Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x75, 0x08, // Report Size (8) + 0x95, 0x02, // Report Count (2) + 0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) + 0x09, 0x38, // Usage (Wheel) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x75, 0x08, // Report Size (8) + 0x95, 0x01, // Report Count (1) + 0x81, 0x06, // Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) + 0xC0, // End Collection + 0xC0, // End Collection +}; + +const usb_hid_device_obj_t usb_hid_device_mouse_obj = { + .base = { + .type = &usb_hid_device_type, + }, + .report_descriptor = mouse_report_descriptor, + .report_descriptor_length = sizeof(mouse_report_descriptor), + .usage_page = 0x01, + .usage = 0x02, + .in_report_length = 4, + .out_report_length = 0, + .report_id_index = MOUSE_REPORT_ID_INDEX, +}; + +static const uint8_t consumer_control_report_descriptor[] = { + 0x05, 0x0C, // 0,1 Usage Page (Consumer) + 0x09, 0x01, // 2,3 Usage (Consumer Control) + 0xA1, 0x01, // 4,5 Collection (Application) + 0x85, 0xFF, // 6,7 Report ID [SET AT RUNTIME] +#define CONSUMER_CONTROL_REPORT_ID_INDEX (7) + 0x75, 0x10, // Report Size (16) + 0x95, 0x01, // Report Count (1) + 0x15, 0x01, // Logical Minimum (1) + 0x26, 0x8C, 0x02, // Logical Maximum (652) + 0x19, 0x01, // Usage Minimum (Consumer Control) + 0x2A, 0x8C, 0x02, // Usage Maximum (AC Send) + 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) + 0xC0, // End Collection +}; + +const usb_hid_device_obj_t usb_hid_device_consumer_control_obj = { + .base = { + .type = &usb_hid_device_type, + }, + .report_descriptor = consumer_control_report_descriptor, + .report_descriptor_length = sizeof(consumer_control_report_descriptor), + .usage_page = 0x0C, + .usage = 0x01, + .in_report_length = 2, + .out_report_length = 0, + .report_id_index = CONSUMER_CONTROL_REPORT_ID_INDEX, +}; + + +void common_hal_usb_hid_device_construct(usb_hid_device_obj_t *self, mp_obj_t report_descriptor, uint8_t usage_page, uint8_t usage, uint8_t in_report_length, uint8_t out_report_length, uint8_t report_id_index) { + // report buffer pointers are NULL at start, and are created when USB is initialized. + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(report_descriptor, &bufinfo, MP_BUFFER_READ); + self->report_descriptor_length = bufinfo.len; + + // Copy the raw the descriptor bytes into a heap obj. We don't keep the Python descriptor object. + + uint8_t *descriptor_bytes = gc_alloc(bufinfo.len, false, false); + memcpy(descriptor_bytes, bufinfo.buf, bufinfo.len); + self->report_descriptor = descriptor_bytes; + + self->usage_page = usage_page; + self->usage = usage; + self->in_report_length = in_report_length; + self->out_report_length = out_report_length; + self->report_id_index = report_id_index; +} + uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) { return self->usage_page; } @@ -42,8 +193,8 @@ uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self) { } void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len) { - if (len != self->report_length) { - mp_raise_ValueError_varg(translate("Buffer incorrect size. Should be %d bytes."), self->report_length); + if (len != self->in_report_length) { + mp_raise_ValueError_varg(translate("Buffer incorrect size. Should be %d bytes."), self->in_report_length); } // Wait until interface is ready, timeout = 2 seconds @@ -56,22 +207,24 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t * mp_raise_msg(&mp_type_OSError, translate("USB Busy")); } - memcpy(self->report_buffer, report, len); + memcpy(self->in_report_buffer, report, len); - if (!tud_hid_report(self->report_id, self->report_buffer, len)) { + if (!tud_hid_report(self->report_id, self->in_report_buffer, len)) { mp_raise_msg(&mp_type_OSError, translate("USB Error")); } } -static usb_hid_device_obj_t *get_hid_device(uint8_t report_id) { - for (uint8_t i = 0; i < USB_HID_NUM_DEVICES; i++) { - if (usb_hid_devices[i].report_id == report_id) { - return &usb_hid_devices[i]; - } + +void usb_hid_device_create_report_buffers(usb_hid_device_obj_t *self) { + if (self->in_report_length > 0) { + self->in_report_buffer = gc_alloc(self->in_report_length, false, true /*long-lived*/); + } + if (self->out_report_length > 0) { + self->out_report_buffer = gc_alloc(self->out_report_length, false, true /*long-lived*/); } - return NULL; } + // Callbacks invoked when receive Get_Report request through control endpoint uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) { (void)itf; @@ -81,7 +234,7 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t } // fill buffer with current report - memcpy(buffer, get_hid_device(report_id)->report_buffer, reqlen); + memcpy(buffer, usb_hid_get_device_with_report_id(report_id)->in_report_buffer, reqlen); return reqlen; } @@ -96,7 +249,7 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t rep return; } - usb_hid_device_obj_t *hid_device = get_hid_device(report_id); + usb_hid_device_obj_t *hid_device = usb_hid_get_device_with_report_id(report_id); if (hid_device && hid_device->out_report_length >= bufsize) { memcpy(hid_device->out_report_buffer, buffer, bufsize); diff --git a/shared-module/usb_hid/Device.h b/shared-module/usb_hid/Device.h index bf4e9d9adb..db3d8ecf65 100644 --- a/shared-module/usb_hid/Device.h +++ b/shared-module/usb_hid/Device.h @@ -32,26 +32,25 @@ #include "py/obj.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct { mp_obj_base_t base; - uint8_t *report_buffer; - uint8_t report_id; - uint8_t report_length; + // Python buffer object whose contents are the descriptor. + const uint8_t *report_descriptor; + uint8_t *in_report_buffer; + uint8_t *out_report_buffer; + uint16_t report_id_index; + uint16_t report_descriptor_length; uint8_t usage_page; uint8_t usage; - uint8_t *out_report_buffer; + uint8_t report_id; + uint8_t in_report_length; uint8_t out_report_length; } usb_hid_device_obj_t; +extern const usb_hid_device_obj_t usb_hid_device_keyboard_obj; +extern const usb_hid_device_obj_t usb_hid_device_mouse_obj; +extern const usb_hid_device_obj_t usb_hid_device_consumer_control_obj; -extern usb_hid_device_obj_t usb_hid_devices[]; - -#ifdef __cplusplus -} -#endif +void usb_hid_device_create_report_buffers(usb_hid_device_obj_t *self); #endif /* SHARED_MODULE_USB_HID_DEVICE_H */ diff --git a/shared-module/usb_hid/__init__.c b/shared-module/usb_hid/__init__.c index d88f9787ac..42c1347357 100644 --- a/shared-module/usb_hid/__init__.c +++ b/shared-module/usb_hid/__init__.c @@ -24,4 +24,254 @@ * THE SOFTWARE. */ -// Nothing needed here. Tables of HID devices are generated in autogen_usb_descriptor.c at compile-time. +#include + +#include "tusb.h" + +#include "py/gc.h" +#include "py/runtime.h" +#include "shared-bindings/usb_hid/__init__.h" +#include "shared-module/usb_hid/Device.h" +#include "supervisor/memory.h" +#include "supervisor/usb.h" + +static const uint8_t usb_hid_descriptor_template[] = { + 0x09, // 0 bLength + 0x04, // 1 bDescriptorType (Interface) + 0xFF, // 2 bInterfaceNumber 3 +#define HID_DESCRIPTOR_INTERFACE_INDEX (2) + 0x00, // 3 bAlternateSetting + 0x02, // 4 bNumEndpoints 2 + 0x03, // 5 bInterfaceClass: HID + 0x00, // 6 bInterfaceSubClass: NOBOOT + 0x00, // 7 bInterfaceProtocol: NONE + 0xFF, // 8 iInterface (String Index) [SET AT RUNTIME] +#define HID_DESCRIPTOR_INTERFACE_STRING_INDEX (8) + + 0x09, // 9 bLength + 0x21, // 10 bDescriptorType (HID) + 0x11, 0x01, // 11,12 bcdHID 1.11 + 0x00, // 13 bCountryCode + 0x01, // 14 bNumDescriptors + 0x22, // 15 bDescriptorType[0] (HID) + 0xFF, 0xFF, // 16,17 wDescriptorLength[0] [SET AT RUNTIME: lo, hi] +#define HID_DESCRIPTOR_LENGTH_INDEX (16) + + 0x07, // 18 bLength + 0x05, // 19 bDescriptorType (Endpoint) + 0xFF, // 20 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | endpoint] +#define HID_IN_ENDPOINT_INDEX (20) + 0x03, // 21 bmAttributes (Interrupt) + 0x40, 0x00, // 22,23 wMaxPacketSize 64 + 0x08, // 24 bInterval 8 (unit depends on device speed) + + 0x07, // 25 bLength + 0x05, // 26 bDescriptorType (Endpoint) + 0xFF, // 27 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] +#define HID_OUT_ENDPOINT_INDEX (27) + 0x03, // 28 bmAttributes (Interrupt) + 0x40, 0x00, // 29,30 wMaxPacketSize 64 + 0x08, // 31 bInterval 8 (unit depends on device speed) +}; + +#define MAX_HID_DEVICES 8 + +static supervisor_allocation *hid_report_descriptor_allocation; +static usb_hid_device_obj_t hid_devices[MAX_HID_DEVICES]; +// If 0, USB HID is disabled. +static mp_int_t hid_devices_num; + +// This tuple is store in usb_hid.devices. +static mp_obj_tuple_t *hid_devices_tuple; + +static mp_obj_tuple_t default_hid_devices_tuple = { + .base = { + .type = &mp_type_tuple, + }, + .len = 3, + .items = { + MP_OBJ_FROM_PTR(&usb_hid_device_keyboard_obj), + MP_OBJ_FROM_PTR(&usb_hid_device_mouse_obj), + MP_OBJ_FROM_PTR(&usb_hid_device_consumer_control_obj), + }, +}; + +bool usb_hid_enabled(void) { + return hid_devices_num == 0; +} + +void usb_hid_set_defaults(void) { + common_hal_usb_hid_enable( + CIRCUITPY_USB_HID_ENABLED_DEFAULT ? &default_hid_devices_tuple : mp_const_empty_tuple); +} + +// This is the interface descriptor, not the report descriptor. +size_t usb_hid_descriptor_length(void) { + return sizeof(usb_hid_descriptor_template); +} + +static const char usb_hid_interface_name[] = USB_INTERFACE_NAME " HID"; + +// This is the interface descriptor, not the report descriptor. +size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string, uint16_t report_descriptor_length) { + memcpy(descriptor_buf, usb_hid_descriptor_template, sizeof(usb_hid_descriptor_template)); + + descriptor_buf[HID_DESCRIPTOR_INTERFACE_INDEX] = *current_interface; + (*current_interface)++; + + usb_add_interface_string(*current_interface, usb_hid_interface_name); + descriptor_buf[HID_DESCRIPTOR_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + descriptor_buf[HID_DESCRIPTOR_LENGTH_INDEX] = report_descriptor_length & 0xFF; + descriptor_buf[HID_DESCRIPTOR_LENGTH_INDEX + 1] = (report_descriptor_length >> 8); + + descriptor_buf[HID_IN_ENDPOINT_INDEX] = 0x80 | (USB_HID_EP_NUM_IN ? USB_HID_EP_NUM_IN : *current_endpoint); + descriptor_buf[HID_OUT_ENDPOINT_INDEX] = USB_HID_EP_NUM_OUT ? USB_HID_EP_NUM_OUT : *current_endpoint; + (*current_endpoint)++; + + return sizeof(usb_hid_descriptor_template); +} + +// Make up a fresh tuple containing the device objects saved in the static +// devices table. Save the tuple in usb_hid.devices. +static void usb_hid_set_devices_from_hid_devices(void) { + mp_obj_t tuple_items[hid_devices_num]; + for (mp_int_t i = 0; i < hid_devices_num; i++) { + tuple_items[i] = &hid_devices[i]; + } + + // Remember tuple for gc purposes. + hid_devices_tuple = mp_obj_new_tuple(hid_devices_num, tuple_items); + usb_hid_set_devices(hid_devices_tuple); +} + +bool common_hal_usb_hid_disable(void) { + return common_hal_usb_hid_enable(mp_const_empty_tuple); +} + +bool common_hal_usb_hid_enable(const mp_obj_t devices) { + // We can't change the devices once we're connected. + if (tud_connected()) { + return false; + } + + hid_devices_num = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(devices)); + if (hid_devices_num > MAX_HID_DEVICES) { + mp_raise_ValueError_varg(translate("No more than %d HID devices allowed"), MAX_HID_DEVICES); + } + + // Remember the devices in static storage so they live across VMs. + for (mp_int_t i = 0; i < hid_devices_num; i++) { + // devices has already been validated to contain only usb_hid_device_obj_t objects. + usb_hid_device_obj_t *device = + MP_OBJ_TO_PTR(mp_obj_subscr(devices, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL)); + memcpy(&hid_devices[i], device, sizeof(usb_hid_device_obj_t)); + } + + usb_hid_set_devices_from_hid_devices(); + + return true; +} + +// Called when HID devices are ready to be used, when code.py or the REPL starts running. +void usb_hid_setup_devices(void) { + usb_hid_set_devices_from_hid_devices(); + + // Create report buffers on the heap. + for (mp_int_t i = 0; i < hid_devices_num; i++) { + usb_hid_device_create_report_buffers(&hid_devices[i]); + } +} + +// Total length of the report descriptor, with all configured devices. +size_t usb_hid_report_descriptor_length(void) { + size_t total_hid_report_descriptor_length = 0; + for (mp_int_t i = 0; i < hid_devices_num; i++) { + total_hid_report_descriptor_length += hid_devices[i].report_descriptor_length; + } + + // Don't need space for a report id if there's only one device. + if (hid_devices_num == 1) { + total_hid_report_descriptor_length -= 2; + } + return total_hid_report_descriptor_length; +} + +// Build the combined HID report descriptor in the given space. +void usb_hid_build_report_descriptor(uint8_t *report_descriptor_space, size_t report_descriptor_length) { + if (!usb_hid_enabled()) { + return; + } + + uint8_t *report_descriptor_start = report_descriptor_space; + + for (mp_int_t i = 0; i < hid_devices_num; i++) { + usb_hid_device_obj_t *device = &hid_devices[i]; + // Copy the report descriptor for this device. + if (hid_devices_num == 1) { + // There's only one device, so it shouldn't have a report ID. + // Copy the descriptor, but splice out the report id indicator and value (2 bytes). + memcpy(report_descriptor_start, device->report_descriptor, device->report_id_index - 1); + report_descriptor_start += device->report_id_index - 1; + memcpy(report_descriptor_start, device->report_descriptor + device->report_id_index + 1, + device->report_descriptor_length - device->report_id_index - 1); + } else { + // Copy the whole descriptor and fill in the report id. + memcpy(report_descriptor_start, device->report_descriptor, device->report_descriptor_length); + report_descriptor_start[device->report_id_index] = i + 1; + + // Remember the report id that was assigned. + device->report_id = i + 1; + + // Advance to the next free chunk for the next report descriptor.x + report_descriptor_start += device->report_descriptor_length; + } + // Clear the heap pointer to the bytes of the descriptor. + // We don't need it any more and it will get lost when the heap goes away. + device->report_descriptor = NULL; + } +} + +// Call this after the heap and VM are finished. +void usb_hid_save_report_descriptor(uint8_t *report_descriptor_space, size_t report_descriptor_length) { + if (!usb_hid_enabled()) { + return; + } + + // Allocate storage that persists across VMs to hold the combined report descriptor. + // and to remember the device details. + + // Copy the descriptor from the temporary area to a supervisor storage allocation that + // will leave between VM instantiations. + hid_report_descriptor_allocation = + allocate_memory(align32_size(report_descriptor_length), + /*high_address*/ false, /*movable*/ false); + memcpy((uint8_t *)hid_report_descriptor_allocation->ptr, report_descriptor_space, report_descriptor_length); +} + +void usb_hid_gc_collect(void) { + gc_collect_ptr(hid_devices_tuple); + + // Mark any heap pointers in the static device list as in use. + for (mp_int_t i = 0; i < hid_devices_num; i++) { + gc_collect_ptr(&hid_devices[i]); + } +} + +usb_hid_device_obj_t *usb_hid_get_device_with_report_id(uint8_t report_id) { + for (uint8_t i = 0; i < hid_devices_num; i++) { + usb_hid_device_obj_t *device = &hid_devices[i]; + if (device->report_id == report_id) { + return &hid_devices[i]; + } + } + return NULL; +} + +// Invoked when GET HID REPORT DESCRIPTOR is received. +// Application return pointer to descriptor +// Descriptor contents must exist long enough for transfer to complete +uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) { + return (uint8_t *)hid_report_descriptor_allocation->ptr; +} diff --git a/shared-module/usb_hid/__init__.h b/shared-module/usb_hid/__init__.h new file mode 100644 index 0000000000..24a4d57a69 --- /dev/null +++ b/shared-module/usb_hid/__init__.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef SHARED_MODULE_USB_HID___INIT___H +#define SHARED_MODULE_USB_HID___INIT___H + +#include "shared-module/usb_hid/Device.h" + +extern usb_hid_device_obj_t usb_hid_devices[]; + +bool usb_hid_enabled(void); +void usb_hid_set_defaults(void); + +size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string, uint16_t report_descriptor_length); +size_t usb_hid_descriptor_length(void); +size_t usb_hid_report_descriptor_length(void); + +void usb_hid_setup_devices(void); +size_t usb_hid_report_descriptor_length(void); +void usb_hid_build_report_descriptor(uint8_t *report_descriptor_space, size_t report_descriptor_length); +void usb_hid_save_report_descriptor(uint8_t *report_descriptor_space, size_t report_descriptor_length); + +usb_hid_device_obj_t *usb_hid_get_device_with_report_id(uint8_t report_id); + +void usb_hid_gc_collect(void); + +#endif // SHARED_MODULE_USB_HID___INIT___H diff --git a/shared-module/usb_midi/__init__.c b/shared-module/usb_midi/__init__.c index 0684112b72..fb564af8d4 100644 --- a/shared-module/usb_midi/__init__.c +++ b/shared-module/usb_midi/__init__.c @@ -26,7 +26,7 @@ #include "shared-bindings/usb_midi/__init__.h" -#include "genhdr/autogen_usb_descriptor.h" +#include "py/gc.h" #include "py/obj.h" #include "py/mphal.h" #include "py/runtime.h" @@ -34,30 +34,227 @@ #include "shared-bindings/usb_midi/PortIn.h" #include "shared-bindings/usb_midi/PortOut.h" #include "supervisor/memory.h" +#include "supervisor/usb.h" #include "tusb.h" -supervisor_allocation *usb_midi_allocation; +static const uint8_t usb_midi_descriptor_template[] = { + // Audio Interface Descriptor + 0x09, // 0 bLength + 0x04, // 1 bDescriptorType (Interface) + 0xFF, // 2 bInterfaceNumber [SET AT RUNTIME] +#define MIDI_AUDIO_CONTROL_INTERFACE_NUMBER_INDEX (2) + 0x00, // 3 bAlternateSetting + 0x00, // 4 bNumEndpoints 0 + 0x01, // 5 bInterfaceClass (Audio) + 0x01, // 6 bInterfaceSubClass (Audio Control) + 0x00, // 7 bInterfaceProtocol + 0xFF, // 8 iInterface (String Index) [SET AT RUNTIME] +#define MIDI_AUDIO_CONTROL_INTERFACE_STRING_INDEX (8) -void usb_midi_init(void) { - // TODO(tannewt): Make this dynamic. - size_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t *) * 2); - size_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t)); - size_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t)); + // Audio10 Control Interface Descriptor + 0x09, // 9 bLength + 0x24, // 10 bDescriptorType (See Next Line) + 0x01, // 11 bDescriptorSubtype (CS_INTERFACE -> HEADER) + 0x00, 0x01, // 12,13 bcdADC 1.00 + 0x09, 0x00, // 14,15 wTotalLength 9 + 0x01, // 16 binCollection 0x01 + 0xFF, // 17 baInterfaceNr [SET AT RUNTIME: one-element list: same as 20] +#define MIDI_STREAMING_INTERFACE_NUMBER_INDEX_2 (17) - // For each embedded MIDI Jack in the descriptor we create a Port - usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false, false); + // MIDI Streaming Interface Descriptor + 0x09, // 18 bLength + 0x04, // 19 bDescriptorType (Interface) + 0xFF, // 20 bInterfaceNumber [SET AT RUNTIME] +#define MIDI_STREAMING_INTERFACE_NUMBER_INDEX (20) + 0x00, // 21 bAlternateSetting + 0x02, // 22 bNumEndpoints 2 + 0x01, // 23 bInterfaceClass (Audio) + 0x03, // 24 bInterfaceSubClass (MIDI Streaming) + 0x00, // 25 bInterfaceProtocol + 0xFF, // 26 iInterface (String Index) [SET AT RUNTIME] +#define MIDI_STREAMING_INTERFACE_STRING_INDEX (26) - mp_obj_tuple_t *ports = (mp_obj_tuple_t *)usb_midi_allocation->ptr; - ports->base.type = &mp_type_tuple; - ports->len = 2; + // MIDI Header Descriptor + 0x07, // 27 bLength + 0x24, // 28 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x01, // 29 bDescriptorSubtype: MIDI STREAMING HEADER + 0x00, 0x01, // 30,31 bsdMSC (MIDI STREAMING) version 1.0 + 0x25, 0x00, // 32,33 wLength - usb_midi_portin_obj_t *in = (usb_midi_portin_obj_t *)(usb_midi_allocation->ptr + tuple_size / 4); - in->base.type = &usb_midi_portin_type; - ports->items[0] = MP_OBJ_FROM_PTR(in); + // MIDI Embedded In Jack Descriptor + 0x06, // 34 bLength + 0x24, // 35 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x02, // 36 bDescriptorSubtype: MIDI IN JACK + 0x01, // 37 bJackType: EMBEDDED + 0x01, // 38 id (always 1) + 0xFF, // 39 iJack (String Index) [SET AT RUNTIME] +#define MIDI_IN_JACK_STRING_INDEX (39) - usb_midi_portout_obj_t *out = (usb_midi_portout_obj_t *)(usb_midi_allocation->ptr + tuple_size / 4 + portin_size / 4); - out->base.type = &usb_midi_portout_type; - ports->items[1] = MP_OBJ_FROM_PTR(out); + // MIDI External In Jack Descriptor + 0x06, // 40 bLength + 0x24, // 41 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x02, // 42 bDescriptorSubtype: MIDI IN JACK + 0x02, // 43 bJackType: EXTERNAL + 0x02, // 44 bJackId (always 2) + 0x00, // 45 iJack (String Index) - mp_map_lookup(&usb_midi_module_globals.map, MP_ROM_QSTR(MP_QSTR_ports), MP_MAP_LOOKUP)->value = MP_OBJ_FROM_PTR(ports); + // MIDI Embedded Out Jack Descriptor + 0x09, // 46 bLength + 0x24, // 47 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x03, // 48 bDescriptorSubtype: MIDI OUT JACK + 0x01, // 49 bJackType: EMBEDDED + 0x03, // 50 bJackID (always 3) + 0x01, // 51 bNrInputPins (always 1) + 0x02, // 52 BaSourceID(1) (always 2) + 0x01, // 53 BaSourcePin(1) (always 1) + 0xFF, // 54 iJack (String Index) [SET AT RUNTIME] +#define MIDI_OUT_JACK_STRING_INDEX (54) + + // MIDI External Out Jack Descriptor + 0x09, // 55 bLength + 0x24, // 56 bDescriptorType: CLASS SPECIFIC INTERFACE + 0x03, // 57 bDescriptorSubtype: MIDI OUT JACK + 0x02, // 58 bJackType: EXTERNAL + 0x04, // 59 bJackID (always 4) + 0x01, // 60 bNrInputPins (always 1) + 0x01, // 61 BaSourceID(1) (always 1) + 0x01, // 62 BaSourcePin(1) (always 1) + 0x00, // 63 iJack (String Index) + + // MIDI Streaming Endpoint OUT Descriptor + 0x07, // 64 bLength + 0x05, // 65 bDescriptorType (EndPoint) + 0xFF, // 66 bEndpointAddress (OUT/H2D) [SET AT RUNTIME] +#define MIDI_STREAMING_OUT_ENDPOINT_INDEX (66) + 0x02, // 67 bmAttributes (Bulk) + 0x40, 0x00, // 68,69 wMaxPacketSize (64) + 0x00, // 70 bInterval 0 (unit depends on device speed) + + // MIDI Data Endpoint Descriptor + 0x05, // 71 bLength + 0x25, // 72 bDescriptorType: CLASS SPECIFIC ENDPOINT + 0x01, // 73 bDescriptorSubtype: MIDI STREAMING 1.0 + 0x01, // 74 bNumGrpTrmBlock (always 1) + 0x01, // 75 baAssoGrpTrmBlkID(1) (always 1) + + // MIDI IN Data Endpoint + 0x07, // 76 bLength + 0x05, // 77 bDescriptorType: Endpoint + 0xFF, // 78 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define MIDI_STREAMING_IN_ENDPOINT_INDEX (78) + 0x02, // 79 bmAttributes (Bulk) + 0x40, 0x00, // 8081 wMaxPacketSize 64 + 0x00, // 82 bInterval 0 (unit depends on device speed) + + // MIDI Data Endpoint Descriptor + 0x05, // 83 bLength + 0x25, // 84 bDescriptorType: CLASS SPECIFIC ENDPOINT + 0x01, // 85 bDescriptorSubtype: MIDI STREAMING 1.0 + 0x01, // 86 bNumGrpTrmBlock (always 1) + 0x03, // 87 baAssoGrpTrmBlkID(1) (always 3) +}; + +// Is the USB MIDI device enabled? +static bool usb_midi_is_enabled; + +void usb_midi_set_defaults(void) { + usb_midi_is_enabled = CIRCUITPY_USB_MIDI_ENABLED_DEFAULT; +} + +bool usb_midi_enabled(void) { + return usb_midi_is_enabled; +} + + +size_t usb_midi_descriptor_length(void) { + return sizeof(usb_midi_descriptor_template); +} + +static const char midi_streaming_interface_name[] = USB_INTERFACE_NAME " MIDI"; +static const char midi_audio_control_interface_name[] = USB_INTERFACE_NAME " Audio"; +static const char midi_in_jack_name[] = USB_INTERFACE_NAME " usb_midi.ports[0]"; +static const char midi_out_jack_name[] = USB_INTERFACE_NAME " usb_midi.ports[0]"; + +size_t usb_midi_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string) { + memcpy(descriptor_buf, usb_midi_descriptor_template, sizeof(usb_midi_descriptor_template)); + + descriptor_buf[MIDI_AUDIO_CONTROL_INTERFACE_NUMBER_INDEX] = *current_interface; + (*current_interface)++; + + descriptor_buf[MIDI_STREAMING_IN_ENDPOINT_INDEX] = + 0x80 | (USB_MIDI_EP_NUM_IN ? USB_MIDI_EP_NUM_IN : *current_endpoint); + descriptor_buf[MIDI_STREAMING_OUT_ENDPOINT_INDEX] = + USB_MIDI_EP_NUM_OUT ? USB_MIDI_EP_NUM_OUT : *current_endpoint; + (*current_endpoint)++; + + descriptor_buf[MIDI_STREAMING_INTERFACE_NUMBER_INDEX] = *current_interface; + descriptor_buf[MIDI_STREAMING_INTERFACE_NUMBER_INDEX_2] = *current_interface; + (*current_interface)++; + + usb_add_interface_string(*current_interface, midi_streaming_interface_name); + descriptor_buf[MIDI_STREAMING_INTERFACE_STRING_INDEX] = *current_interface; + (*current_interface_string)++; + + usb_add_interface_string(*current_interface, midi_audio_control_interface_name); + descriptor_buf[MIDI_AUDIO_CONTROL_INTERFACE_STRING_INDEX] = *current_interface; + (*current_interface_string)++; + + usb_add_interface_string(*current_interface, midi_in_jack_name); + descriptor_buf[MIDI_IN_JACK_STRING_INDEX] = *current_interface; + (*current_interface_string)++; + + usb_add_interface_string(*current_interface, midi_out_jack_name); + descriptor_buf[MIDI_OUT_JACK_STRING_INDEX] = *current_interface; + (*current_interface_string)++; + + return sizeof(usb_midi_descriptor_template); +} + +static const usb_midi_portin_obj_t midi_portin_obj = { + .base = { + .type = &usb_midi_portin_type, + }, +}; + +static const usb_midi_portout_obj_t midi_portout_obj = { + .base = { + .type = &usb_midi_portout_type, + } +}; + +static const mp_rom_obj_tuple_t midi_ports_tuple = { + .base = { + .type = &mp_type_tuple, + }, + .len = 2, + .items = { + MP_ROM_PTR(&midi_portin_obj), + MP_ROM_PTR(&midi_portout_obj), + }, +}; + +void usb_midi_setup_ports(void) { + // Right now midi_ports_tuple contains no heap objects, but if it does in the future, + // it will need to be protected against gc. + + mp_obj_tuple_t *ports = usb_midi_is_enabled ? MP_OBJ_FROM_PTR(&midi_ports_tuple) : mp_const_empty_tuple; + mp_map_lookup(&usb_midi_module_globals.map, MP_ROM_QSTR(MP_QSTR_ports), MP_MAP_LOOKUP)->value = + MP_OBJ_FROM_PTR(ports); +} + +static bool usb_midi_set_enabled(bool enabled) { + // We can't change the descriptors once we're connected. + if (tud_connected()) { + return false; + } + usb_midi_is_enabled = enabled; + return true; +} + +bool common_hal_usb_midi_disable(void) { + return usb_midi_set_enabled(false); +} + +bool common_hal_usb_midi_enable(void) { + return usb_midi_set_enabled(true); } diff --git a/shared-module/usb_midi/__init__.h b/shared-module/usb_midi/__init__.h index e1ad1fbafb..9ab61e12db 100644 --- a/shared-module/usb_midi/__init__.h +++ b/shared-module/usb_midi/__init__.h @@ -27,6 +27,11 @@ #ifndef SHARED_MODULE_USB_MIDI___INIT___H #define SHARED_MODULE_USB_MIDI___INIT___H -void usb_midi_init(void); +bool usb_midi_enabled(void); +void usb_midi_set_defaults(void); +void usb_midi_setup_ports(void); + +size_t usb_midi_descriptor_length(void); +size_t usb_midi_add_descriptor(uint8_t *descriptor_buf, uint8_t *current_interface, uint8_t *current_endpoint, uint8_t *current_interface_string); #endif /* SHARED_MODULE_USB_MIDI___INIT___H */ diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index 30482ea7b9..a20df618ca 100644 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -36,13 +36,23 @@ enum { CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT = // stack + heap 2 + #if INTERNAL_FLASH_FILESYSTEM == 0 + 1 #endif - #if CIRCUITPY_USB_MIDI - + 1 + + #if CIRCUITPY_USB + + 1 // device_descriptor_allocation + + 1 // configuration_descriptor_allocation + + 1 // string_descriptors_allocation + #endif + + #if CIRCUITPY_USB_HID + + 1 // hid_report_descriptor_allocation + + 1 // hid_devices_allocation #endif , + CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT = 0 #if CIRCUITPY_DISPLAYIO @@ -61,6 +71,7 @@ enum { ) #endif , + CIRCUITPY_SUPERVISOR_ALLOC_COUNT = CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT + CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT }; @@ -308,9 +319,11 @@ void supervisor_move_memory(void) { // Notify clients that their movable allocations may have moved. old_allocations = &old_allocations_array[0]; + #if CIRCUITPY_DISPLAYIO supervisor_display_move_memory(); #endif + // Add calls to further clients here. old_allocations = NULL; } diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index cd73e1b9f9..661fd79af8 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -165,38 +165,47 @@ void print_safe_mode_message(safe_mode_t reason) { } serial_write_compressed(translate("CircuitPython core code crashed hard. Whoops!\n")); + + const compressed_string_t *message = NULL; switch (reason) { case HARD_CRASH: - serial_write_compressed(translate("Crash into the HardFault_Handler.")); - return; + message = translate("Crash into the HardFault_Handler."); + break; case MICROPY_NLR_JUMP_FAIL: - serial_write_compressed(translate("NLR jump failed. Likely memory corruption.")); - return; + message = translate("NLR jump failed. Likely memory corruption."); + break; case MICROPY_FATAL_ERROR: - serial_write_compressed(translate("Fatal error.")); + message = translate("Fatal error."); break; case GC_ALLOC_OUTSIDE_VM: - serial_write_compressed(translate("Attempted heap allocation when VM not running.")); + message = translate("Attempted heap allocation when VM not running."); break; #ifdef SOFTDEVICE_PRESENT // defined in ports/nrf/bluetooth/bluetooth_common.mk // will print "Unknown reason" if somehow encountered on other ports case NORDIC_SOFT_DEVICE_ASSERT: - serial_write_compressed(translate("Nordic system firmware failure assertion.")); + message = translate("Nordic system firmware failure assertion."); break; #endif case FLASH_WRITE_FAIL: - serial_write_compressed(translate("Failed to write internal flash.")); + message = translate("Failed to write internal flash."); break; case MEM_MANAGE: - serial_write_compressed(translate("Invalid memory access.")); + message = translate("Invalid memory access."); break; case WATCHDOG_RESET: - serial_write_compressed(translate("Watchdog timer expired.")); + message = translate("Watchdog timer expired."); + break; + case USB_TOO_MANY_ENDPOINTS: + message = translate("USB devices need more endpoints than are available."); + break; + case USB_TOO_MANY_INTERFACE_NAMES: + message = translate("USB devices specify too many interface names."); break; default: - serial_write_compressed(translate("Unknown reason.")); + message = translate("Unknown reason."); break; } + serial_write_compressed(message); serial_write_compressed(FILE_AN_ISSUE); } diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h index 722e970333..01aed37d63 100644 --- a/supervisor/shared/safe_mode.h +++ b/supervisor/shared/safe_mode.h @@ -44,6 +44,8 @@ typedef enum { FLASH_WRITE_FAIL, MEM_MANAGE, WATCHDOG_RESET, + USB_TOO_MANY_ENDPOINTS, + USB_TOO_MANY_INTERFACE_NAMES, NO_HEAP, } safe_mode_t; diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index beb2541a15..f7e0aafaaf 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -34,6 +34,7 @@ #include "supervisor/serial.h" #include "supervisor/usb.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/usb_cdc/__init__.h" #include "tusb.h" @@ -77,7 +78,7 @@ void serial_early_init(void) { } void serial_init(void) { - usb_init(); + // USB serial is set up separately. #ifdef NRF_DEBUG_PRINT _debug_uart_init(); #endif @@ -92,6 +93,8 @@ bool serial_connected(void) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return true; + #elif CIRCUITPY_USB_CDC + return usb_cdc_console_enabled() && tud_cdc_connected(); #else return tud_cdc_connected(); #endif @@ -114,9 +117,12 @@ char serial_read(void) { char text; common_hal_busio_uart_read(&debug_uart, (uint8_t *)&text, 1, &uart_errcode); return text; - #else - return (char)tud_cdc_read_char(); + #elif CIRCUITPY_USB_CDC + if (!usb_cdc_console_enabled()) { + return -1; + } #endif + return (char)tud_cdc_read_char(); } bool serial_bytes_available(void) { @@ -128,9 +134,12 @@ bool serial_bytes_available(void) { #if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX) return common_hal_busio_uart_rx_characters_available(&debug_uart) || (tud_cdc_available() > 0); - #else - return tud_cdc_available() > 0; + #elif CIRCUITPY_USB_CDC + if (!usb_cdc_console_enabled()) { + return 0; + } #endif + return tud_cdc_available() > 0; } void serial_write_substring(const char *text, uint32_t length) { if (length == 0) { @@ -147,6 +156,12 @@ void serial_write_substring(const char *text, uint32_t length) { } #endif + #if CIRCUITPY_USB_CDC + if (!usb_cdc_console_enabled()) { + return; + } + #endif + uint32_t count = 0; while (count < length && tud_cdc_connected()) { count += tud_cdc_write(text + count, length - count); diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index 0b23d56b9b..e75a653244 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -38,8 +38,6 @@ #ifndef _TUSB_CONFIG_H_ #define _TUSB_CONFIG_H_ -#include "genhdr/autogen_usb_descriptor.h" - #ifdef __cplusplus extern "C" { #endif @@ -61,11 +59,22 @@ extern "C" { // DEVICE CONFIGURATION // --------------------------------------------------------------------+ +#if USB_HIGHSPEED +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED) +#else +#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE) +#endif + +// Vendor name included in Inquiry response, max 8 bytes +#define CFG_TUD_MSC_VENDOR USB_MANUFACTURER_8 + +// Product name included in Inquiry response, max 16 bytes +#define CFG_TUD_MSC_PRODUCT USB_PRODUCT_16 #define CFG_TUD_ENDPOINT0_SIZE 64 // ------------- CLASS -------------// -// Could be 2 if secondary CDC channel requested. +// Will be set to 2 in supervisor.mk if CIRCUITPY_USB_CDC is set. #ifndef CFG_TUD_CDC #define CFG_TUD_CDC 1 #endif diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index ea5faaf06b..2abe5adb71 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -34,6 +34,18 @@ #include "lib/utils/interrupt_char.h" #include "lib/mp-readline/readline.h" +#if CIRCUITPY_STORAGE +#include "shared-module/storage/__init__.h" +#endif + +#if CIRCUITPY_USB_CDC +#include "shared-module/usb_cdc/__init__.h" +#endif + +#if CIRCUITPY_USB_HID +#include "shared-module/usb_hid/__init__.h" +#endif + #if CIRCUITPY_USB_MIDI #include "shared-module/usb_midi/__init__.h" #endif @@ -41,7 +53,6 @@ #include "tusb.h" #if CIRCUITPY_USB_VENDOR -#include "genhdr/autogen_usb_descriptor.h" // The WebUSB support being conditionally added to this file is based on the // tinyusb demo examples/device/webusb_serial. @@ -51,27 +62,6 @@ extern const tusb_desc_webusb_url_t desc_webusb_url; static bool web_serial_connected = false; #endif - - -// Serial number as hex characters. This writes directly to the USB -// descriptor. -extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2]; - -void load_serial_number(void) { - // create serial number based on device unique id - uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; - common_hal_mcu_processor_get_uid(raw_id); - - usb_serial_number[0] = 0x300 | sizeof(usb_serial_number); - for (int i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { - for (int j = 0; j < 2; j++) { - uint8_t nibble = (raw_id[i] >> (j * 4)) & 0xf; - // Strings are UTF-16-LE encoded. - usb_serial_number[1 + i * 2 + j] = nibble_to_hex_upper[nibble]; - } - } -} - bool usb_enabled(void) { return tusb_inited(); } @@ -81,7 +71,6 @@ MP_WEAK void post_usb_init(void) { void usb_init(void) { init_usb_hardware(); - load_serial_number(); tusb_init(); @@ -92,9 +81,63 @@ void usb_init(void) { // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here tud_cdc_set_wanted_char(CHAR_CTRL_C); #endif +} + +// Set up USB defaults before any USB changes are made in boot.py +void usb_set_defaults(void) { + #if CIRCUITPY_STORAGE + storage_usb_set_defaults(); + #endif + + #if CIRCUITPY_USB_CDC + usb_cdc_set_defaults(); + #endif + + #if CIRCUITPY_USB_HID + usb_hid_set_defaults(); + #endif #if CIRCUITPY_USB_MIDI - usb_midi_init(); + usb_midi_set_defaults(); + #endif +}; + +// Some dynamic USB data must be saved after boot.py. How much is needed +size_t usb_boot_py_data_size(void) { + size_t size = 0; + + #if CIRCUITPY_USB_HID + size += usb_hid_report_descriptor_length(); + #endif + + return size; +} + +// Fill in the data to save. +void usb_get_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size) { + #if CIRCUITPY_USB_HID + usb_hid_build_report_descriptor(temp_storage, temp_storage_size); + #endif +} + +// After VM is gone, save data into non-heap storage (storage_allocations). +void usb_return_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size) { + #if CIRCUITPY_USB_HID + usb_hid_save_report_descriptor(temp_storage, temp_storage_size); + #endif + + // Now we can also build the rest of the descriptors and place them in storage_allocations. + usb_build_descriptors(); +} + +// Call this when ready to run code.py or a REPL, and a VM has been started. +void usb_setup_with_vm(void) { + #if CIRCUITPY_USB_HID + usb_hid_setup_devices(); + #endif + + #if CIRCUITPY_USB_MIDI + usb_midi_setup_ports(); #endif } diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c index 67df4f44bf..99a769c704 100644 --- a/supervisor/shared/usb/usb_desc.c +++ b/supervisor/shared/usb/usb_desc.c @@ -25,37 +25,309 @@ */ #include "lib/tinyusb/src/tusb.h" -#include "shared-module/usb_hid/Device.h" -#include "genhdr/autogen_usb_descriptor.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "supervisor/memory.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/usb.h" -// Invoked when received GET DEVICE DESCRIPTOR -// Application return pointer to descriptor -uint8_t const *tud_descriptor_device_cb(void) { - return usb_desc_dev; +#if CIRCUITPY_USB_CDC +#include "shared-bindings/usb_cdc/__init__.h" +#endif + +#if CIRCUITPY_USB_HID +#include "shared-bindings/usb_hid/__init__.h" +#endif + +#if CIRCUITPY_USB_MIDI +#include "shared-bindings/usb_midi/__init__.h" +#endif + +#if CIRCUITPY_USB_MSC && CIRCUITPY_STORAGE +#include "shared-bindings/storage/__init__.h" +#endif + +#include "shared-bindings/microcontroller/Processor.h" + + +// Table for collecting interface strings (interface names) as descriptor is built. +// We reuse the same table after collection, replacing the char string pointers with le16 string pointers. +#define MAX_INTERFACE_STRINGS 16 +// slot 0 is always the Language ID +typedef union { + const char *char_str; + const uint16_t *descriptor; +} interface_string_t; +static interface_string_t collected_interface_strings[MAX_INTERFACE_STRINGS]; + +static size_t collected_interface_strings_length; +static uint8_t current_interface_string; + +static supervisor_allocation *device_descriptor_allocation; +static supervisor_allocation *configuration_descriptor_allocation; +static supervisor_allocation *string_descriptors_allocation; + +static const char manufacturer_name[] = USB_MANUFACTURER; +static const char product_name[] = USB_PRODUCT; + +// Serial number string is UID length * 2 (2 nibbles per byte) + 1 byte for null termination. +static char serial_number_hex_string[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2 + 1]; + + +static const uint8_t device_descriptor_template[] = { + 0x12, // 0 bLength + 0x01, // 1 bDescriptorType (Device) + 0x00, 0x02, // 2,3 bcdUSB 2.00 + 0x00, // 4 bDeviceClass (Use class information in the Interface Descriptors) + 0x00, // 5 bDeviceSubClass + 0x00, // 6 bDeviceProtocol + 0x40, // 7 bMaxPacketSize0 64 + 0xFF, 0xFF, // 8,9 idVendor [SET AT RUNTIME: lo,hi] +#define DEVICE_VID_LO_INDEX (8) +#define DEVICE_VID_HI_INDEX (9) + 0xFF, 0xFF, // 10,11 idProduct [SET AT RUNTIME: lo,hi] +#define DEVICE_PID_LO_INDEX (10) +#define DEVICE_PID_HI_INDEX (11) + 0x00, 0x01, // 12,13 bcdDevice 2.00 + 0xFF, // 14 iManufacturer (String Index) [SET AT RUNTIME] +#define DEVICE_MANUFACTURER_STRING_INDEX (14) + 0xFF, // 15 iProduct (String Index) [SET AT RUNTIME] +#define DEVICE_PRODUCT_STRING_INDEX (15) + 0xFF, // 16 iSerialNumber (String Index) [SET AT RUNTIME] +#define DEVICE_SERIAL_NUMBER_STRING_INDEX (16) + 0x01, // 17 bNumConfigurations 1 +}; + +static const uint8_t configuration_descriptor_template[] = { + 0x09, // 0 bLength + 0x02, // 1 bDescriptorType (Configuration) + 0xFF, 0xFF, // 2,3 wTotalLength [SET AT RUNTIME: lo, hi] +#define CONFIG_TOTAL_LENGTH_LO_INDEX (2) +#define CONFIG_TOTAL_LENGTH_HI_INDEX (3) + 0xFF, // 4 bNumInterfaces [SET AT RUNTIME] +#define CONFIG_NUM_INTERFACES_INDEX (4) + 0x01, // 5 bConfigurationValue + 0x00, // 6 iConfiguration (String Index) + 0x80, // 7 bmAttributes + 0x32, // 8 bMaxPower 100mA +}; + +static void usb_build_device_descriptor(uint16_t vid, uint16_t pid) { + device_descriptor_allocation = + allocate_memory(align32_size(sizeof(device_descriptor_template)), + /*high_address*/ false, /*movable*/ false); + uint8_t *device_descriptor = (uint8_t *)device_descriptor_allocation->ptr; + memcpy(device_descriptor, device_descriptor_template, sizeof(device_descriptor_template)); + + device_descriptor[DEVICE_VID_LO_INDEX] = vid & 0xFF; + device_descriptor[DEVICE_VID_HI_INDEX] = vid >> 8; + device_descriptor[DEVICE_PID_LO_INDEX] = pid & 0xFF; + device_descriptor[DEVICE_PID_HI_INDEX] = pid >> 8; + + usb_add_interface_string(current_interface_string, manufacturer_name); + device_descriptor[DEVICE_MANUFACTURER_STRING_INDEX] = current_interface_string; + current_interface_string++; + + usb_add_interface_string(current_interface_string, product_name); + device_descriptor[DEVICE_PRODUCT_STRING_INDEX] = current_interface_string; + current_interface_string++; + + usb_add_interface_string(current_interface_string, serial_number_hex_string); + device_descriptor[DEVICE_SERIAL_NUMBER_STRING_INDEX] = current_interface_string; + current_interface_string++; } -// Invoked when received GET CONFIGURATION DESCRIPTOR +static void usb_build_configuration_descriptor(void) { + size_t total_descriptor_length = sizeof(configuration_descriptor_template); + + // CDC should be first, for compatibility with Adafruit Windows 7 drivers. + // In the past, the order has been CDC, MSC, MIDI, HID, so preserve that order. + #if CIRCUITPY_USB_CDC + if (usb_cdc_console_enabled()) { + total_descriptor_length += usb_cdc_descriptor_length(); + } + if (usb_cdc_data_enabled()) { + total_descriptor_length += usb_cdc_descriptor_length(); + } + #endif + + #if CIRCUITPY_USB_MSC + if (storage_usb_enabled()) { + total_descriptor_length += storage_usb_descriptor_length(); + } + #endif + + #if CIRCUITPY_USB_HID + if (usb_hid_enabled()) { + total_descriptor_length += usb_hid_descriptor_length(); + } + #endif + + #if CIRCUITPY_USB_MIDI + if (usb_midi_enabled()) { + total_descriptor_length += usb_midi_descriptor_length(); + } + #endif + + // Now we now how big the configuration descriptor will be, so we can allocate space for it. + configuration_descriptor_allocation = + allocate_memory(align32_size(total_descriptor_length), + /*high_address*/ false, /*movable*/ false); + uint8_t *configuration_descriptor = (uint8_t *)configuration_descriptor_allocation->ptr; + + // Copy the template, which is the first part of the descriptor, and fix up its length. + + memcpy(configuration_descriptor, configuration_descriptor_template, sizeof(configuration_descriptor_template)); + + configuration_descriptor[CONFIG_TOTAL_LENGTH_LO_INDEX] = total_descriptor_length & 0xFF; + configuration_descriptor[CONFIG_TOTAL_LENGTH_HI_INDEX] = (total_descriptor_length >> 8) & 0xFF; + + // Number interfaces and endpoints. + // Endpoint 0 is already used for USB control, so start with 1. + uint8_t current_interface = 0; + uint8_t current_endpoint = 1; + + uint8_t *descriptor_buf_remaining = configuration_descriptor + sizeof(configuration_descriptor_template); + + #if CIRCUITPY_USB_CDC + if (usb_cdc_console_enabled()) { + // Concatenate and fix up the CDC REPL descriptor. + descriptor_buf_remaining += usb_cdc_add_descriptor( + descriptor_buf_remaining, ¤t_interface, ¤t_endpoint, ¤t_interface_string, true); + } + if (usb_cdc_data_enabled()) { + // Concatenate and fix up the CDC data descriptor. + descriptor_buf_remaining += usb_cdc_add_descriptor( + descriptor_buf_remaining, ¤t_interface, ¤t_endpoint, ¤t_interface_string, false); + } + #endif + + #if CIRCUITPY_USB_MSC + if (storage_usb_enabled()) { + // Concatenate and fix up the MSC descriptor. + descriptor_buf_remaining += storage_usb_add_descriptor( + descriptor_buf_remaining, ¤t_interface, ¤t_endpoint, ¤t_interface_string); + } + #endif + + #if CIRCUITPY_USB_HID + if (usb_hid_enabled()) { + descriptor_buf_remaining += usb_hid_add_descriptor( + descriptor_buf_remaining, ¤t_interface, ¤t_endpoint, ¤t_interface_string, + usb_hid_report_descriptor_length()); + } + #endif + + #if CIRCUITPY_USB_MIDI + if (usb_midi_enabled()) { + // Concatenate and fix up the MIDI descriptor. + descriptor_buf_remaining += usb_midi_add_descriptor( + descriptor_buf_remaining, ¤t_interface, ¤t_endpoint, ¤t_interface_string); + } + #endif + + // Now we know how many interfaces have been used. + configuration_descriptor[CONFIG_NUM_INTERFACES_INDEX] = current_interface; + + // Did we run out of endpoints? + if (current_endpoint - 1 > USB_NUM_EP) { + reset_into_safe_mode(USB_TOO_MANY_ENDPOINTS); + } + +} + +// str must not be on the heap. +void usb_add_interface_string(uint8_t interface_string_index, const char str[]) { + if (interface_string_index > MAX_INTERFACE_STRINGS) { + reset_into_safe_mode(USB_TOO_MANY_INTERFACE_NAMES); + } + + collected_interface_strings[interface_string_index].char_str = str; + collected_interface_strings_length += strlen(str); +} + +static void usb_build_interface_string_table(void) { + // Allocate space for the le16 String descriptors. + // Space needed is 2 bytes for String Descriptor header, then 2 bytes for each character + string_descriptors_allocation = + allocate_memory(align32_size(current_interface_string * 2 + collected_interface_strings_length * 2), + /*high_address*/ false, /*movable*/ false); + uint16_t *string_descriptors = (uint16_t *)string_descriptors_allocation->ptr; + + + uint16_t *string_descriptor = string_descriptors; + + // Language ID is always the 0th string descriptor. + collected_interface_strings[0].descriptor = (uint16_t[]) { + 0x0304, + 0x0409, + }; + + // Build the le16 versions of all the descriptor strings. + // Start at 1 to skip the Language ID. + for (uint8_t string_index = 1; string_index < current_interface_string; string_index++) { + const char *str = collected_interface_strings[string_index].char_str; + const size_t str_len = strlen(str); + uint8_t descriptor_size = 2 + (str_len * 2); + string_descriptor[0] = 0x0300 | descriptor_size; + + // Convert to le16. + for (size_t i = 0; i <= str_len; i++) { + string_descriptor[i + 1] = str[i]; + } + + // Save ptr to string descriptor with le16 str. + collected_interface_strings[string_index].descriptor = string_descriptor; + + // Move to next descriptor slot. + string_descriptor += descriptor_size; + } +} + +// After boot.py runs, the USB devices to be used have been chosen, and the descriptors can be set up. +// This is called after the VM is finished, because it uses storage_allocations. +void usb_build_descriptors(void) { + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; + common_hal_mcu_processor_get_uid(raw_id); + + for (int i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { + for (int j = 0; j < 2; j++) { + uint8_t nibble = (raw_id[i] >> (j * 4)) & 0xf; + serial_number_hex_string[i * 2 + (1 - j)] = nibble_to_hex_upper[nibble]; + } + } + + // Null-terminate the string. + serial_number_hex_string[sizeof(serial_number_hex_string) - 1] = '\0'; + + current_interface_string = 1; + collected_interface_strings_length = 0; + + usb_build_device_descriptor(USB_VID, USB_PID); + usb_build_configuration_descriptor(); + usb_build_interface_string_table(); +} + +// Invoked when GET DEVICE DESCRIPTOR is received. +// Application return pointer to descriptor +uint8_t const *tud_descriptor_device_cb(void) { + return (uint8_t *)device_descriptor_allocation->ptr; +} + +// Invoked when GET CONFIGURATION DESCRIPTOR is received. // Application return pointer to descriptor // Descriptor contents must exist long enough for transfer to complete uint8_t const *tud_descriptor_configuration_cb(uint8_t index) { (void)index; // for multiple configurations - return usb_desc_cfg; + return (uint8_t *)configuration_descriptor_allocation->ptr; } -#if CIRCUITPY_USB_HID -// Invoked when received GET HID REPORT DESCRIPTOR -// Application return pointer to descriptor -// Descriptor contents must exist long enough for transfer to complete -uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) { - (void)itf; - return hid_report_descriptor; -} -#endif - -// Invoked when received GET STRING DESCRIPTOR request +// Invoked when GET STRING DESCRIPTOR request is received. // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) { - uint8_t const max_index = sizeof(string_desc_arr) / sizeof(string_desc_arr[0]); - return (index < max_index) ? string_desc_arr[index] : NULL; + if (index > MAX_INTERFACE_STRINGS) { + return NULL; + } + return collected_interface_strings[index].descriptor; } diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 2577a49180..1ca937cdab 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -7,7 +7,7 @@ SRC_SUPERVISOR = \ supervisor/shared/cpu.c \ supervisor/shared/filesystem.c \ supervisor/shared/flash.c \ - supervisor/shared/memory.c \ + supervisor/shared/memory.c \ supervisor/shared/micropython.c \ supervisor/shared/rgb_led_status.c \ supervisor/shared/safe_mode.c \ @@ -78,7 +78,6 @@ else supervisor/usb.c \ supervisor/shared/usb/usb_desc.c \ supervisor/shared/usb/usb.c \ - $(BUILD)/autogen_usb_descriptor.c \ ifeq ($(CIRCUITPY_USB_CDC), 1) SRC_SUPERVISOR += \ @@ -136,132 +135,38 @@ ifeq ($(CIRCUITPY_DISPLAYIO), 1) endif endif +# Preserve double quotes in these values by single-quoting them. + USB_INTERFACE_NAME ?= "CircuitPython" +CFLAGS += -DUSB_INTERFACE_NAME='$(USB_INTERFACE_NAME)' ifneq ($(USB_VID),) CFLAGS += -DUSB_VID=$(USB_VID) -CFLAGS += -DSUB_PID=$(USB_PID) -CFLAGS += -DUSB_MANUFACTURER=$(USB_MANUFACTURER) -CFLAGS += -DUSB_PRODUCT=$(USB_PRODUCT) +CFLAGS += -DUSB_PID=$(USB_PID) +CFLAGS += -DUSB_MANUFACTURER='$(USB_MANUFACTURER)' +USB_MANUFACTURER_8 := "$(shell echo $(USB_MANUFACTURER) | cut -c 1-8)" +# Length-limited versions of strings for MSC names. +CFLAGS += -DUSB_MANUFACTURER_8='$(USB_MANUFACTURER_8)' +USB_PRODUCT_16 := "$(shell echo $(USB_PRODUCT) | cut -c 1-16)" +CFLAGS += -DUSB_PRODUCT_16='$(USB_PRODUCT_16)' +CFLAGS += -DUSB_PRODUCT='$(USB_PRODUCT)' + endif # In the following URL, don't include the https:// prefix. # It gets added automatically. USB_WEBUSB_URL ?= "circuitpython.org" -ifeq ($(CIRCUITPY_REPL_USB),1) -USB_DEVICES += CDC -endif - -ifeq ($(CIRCUITPY_USB_HID),1) -USB_DEVICES += HID -endif -ifeq ($(CIRCUITPY_USB_MIDI),1) -USB_DEVICES += AUDIO -endif -ifeq ($(CIRCUITPY_USB_MSC),1) -USB_DEVICES += MSC -endif ifeq ($(CIRCUITPY_USB_CDC),1) -# Inform TinyUSB there are two CDC devices. +# Inform TinyUSB there will be up to two CDC devices. CFLAGS += -DCFG_TUD_CDC=2 -USB_DEVICES += CDC2 -endif -ifeq ($(CIRCUITPY_USB_VENDOR),1) -USB_DEVICES += VENDOR -endif - -USB_HID_DEVICES = -ifeq ($(CIRCUITPY_USB_HID_CONSUMER),1) -USB_HID_DEVICES += CONSUMER -endif -ifeq ($(CIRCUITPY_USB_HID_DIGITIZER),1) -USB_HID_DEVICES += DIGITIZER -endif -ifeq ($(CIRCUITPY_USB_HID_GAMEPAD),1) -USB_HID_DEVICES += GAMEPAD -endif -ifeq ($(CIRCUITPY_USB_HID_KEYBOARD),1) -USB_HID_DEVICES += KEYBOARD -endif -ifeq ($(CIRCUITPY_USB_HID_MOUSE),1) -USB_HID_DEVICES += MOUSE -endif -ifeq ($(CIRCUITPY_USB_HID_SYS_CONTROL),1) -USB_HID_DEVICES += SYS_CONTROL -endif -ifeq ($(CIRCUITPY_USB_HID_XAC_COMPATIBLE_GAMEPAD),1) -USB_HID_DEVICES += XAC_COMPATIBLE_GAMEPAD -endif - -# RAW is not compatible with other HID devices. -ifeq ($(CIRCUITPY_USB_HID_RAW),1) - ifneq ($(CIRCUITPY_USB_HID_DEVICES,) - $(error HID RAW must not be combined with other HID devices) -endif -USB_HID_DEVICES += MOUSE endif USB_HIGHSPEED ?= 0 - -USB_CDC_EP_NUM_NOTIFICATION ?= 0 -USB_CDC_EP_NUM_DATA_OUT ?= 0 -USB_CDC_EP_NUM_DATA_IN ?= 0 -USB_MSC_EP_NUM_OUT ?= 0 -USB_MSC_EP_NUM_IN ?= 0 -USB_HID_EP_NUM_OUT ?= 0 -USB_HID_EP_NUM_IN ?= 0 -USB_MIDI_EP_NUM_OUT ?= 0 -USB_MIDI_EP_NUM_IN ?= 0 -USB_NUM_EP ?= 0 - -USB_DESCRIPTOR_ARGS = \ - --manufacturer $(USB_MANUFACTURER)\ - --product $(USB_PRODUCT)\ - --vid $(USB_VID)\ - --pid $(USB_PID)\ - --serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\ - --interface_name $(USB_INTERFACE_NAME)\ - --devices "$(USB_DEVICES)"\ - --hid_devices "$(USB_HID_DEVICES)"\ - --max_ep $(USB_NUM_EP) \ - --cdc_ep_num_notification $(USB_CDC_EP_NUM_NOTIFICATION)\ - --cdc_ep_num_data_out $(USB_CDC_EP_NUM_DATA_OUT)\ - --cdc_ep_num_data_in $(USB_CDC_EP_NUM_DATA_IN)\ - --msc_ep_num_out $(USB_MSC_EP_NUM_OUT)\ - --msc_ep_num_in $(USB_MSC_EP_NUM_IN)\ - --hid_ep_num_out $(USB_HID_EP_NUM_OUT)\ - --hid_ep_num_in $(USB_HID_EP_NUM_IN)\ - --midi_ep_num_out $(USB_MIDI_EP_NUM_OUT)\ - --midi_ep_num_in $(USB_MIDI_EP_NUM_IN)\ - --output_c_file $(BUILD)/autogen_usb_descriptor.c\ - --output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h - -ifeq ($(CIRCUITPY_USB_VENDOR), 1) -USB_DESCRIPTOR_ARGS += \ - --vendor_ep_num_out 0 --vendor_ep_num_in 0 \ - --webusb_url $(USB_WEBUSB_URL) -endif - -ifeq ($(USB_RENUMBER_ENDPOINTS), 0) -USB_DESCRIPTOR_ARGS += --no-renumber_endpoints -endif - -ifeq ($(USB_HIGHSPEED), 1) -USB_DESCRIPTOR_ARGS += --highspeed -endif +CFLAGS += -DUSB_HIGHSPEED=$(USB_HIGHSPEED) $(BUILD)/supervisor/shared/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h -$(BUILD)/autogen_usb_descriptor.c $(BUILD)/genhdr/autogen_usb_descriptor.h: autogen_usb_descriptor.intermediate - -.INTERMEDIATE: autogen_usb_descriptor.intermediate - -autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile | $(HEADER_BUILD) - $(STEPECHO) "GEN $@" - $(Q)install -d $(BUILD)/genhdr - $(Q)$(PYTHON3) ../../tools/gen_usb_descriptor.py $(USB_DESCRIPTOR_ARGS) - CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf" $(BUILD)/autogen_display_resources.c: ../../tools/gen_display_resources.py $(HEADER_BUILD)/qstrdefs.generated.h Makefile | $(HEADER_BUILD) diff --git a/supervisor/usb.h b/supervisor/usb.h index f8fd713715..918da98897 100644 --- a/supervisor/usb.h +++ b/supervisor/usb.h @@ -28,6 +28,8 @@ #define MICROPY_INCLUDED_SUPERVISOR_USB_H #include +#include +#include // Ports must call this as frequently as they can in order to keep the USB // connection alive and responsive. Normally this is called from background @@ -50,8 +52,18 @@ void post_usb_init(void); // Shared implementation. bool usb_enabled(void); -void usb_init(void); +void usb_add_interface_string(uint8_t interface_string_index, const char str[]); +void usb_build_descriptors(void); void usb_disconnect(void); +void usb_init(void); +void usb_set_defaults(void); +size_t usb_boot_py_data_size(void); +void usb_get_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size); +void usb_return_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size); + +// Further initialization that must be done with a VM present. +void usb_setup_with_vm(void); + // Propagate plug/unplug events to the MSC logic. #if CIRCUITPY_USB_MSC diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py deleted file mode 100644 index 121bce6a0e..0000000000 --- a/tools/gen_usb_descriptor.py +++ /dev/null @@ -1,1063 +0,0 @@ -# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) -# -# SPDX-License-Identifier: MIT - -import argparse - -import os -import sys - -sys.path.append("../../tools/usb_descriptor") - -from adafruit_usb_descriptor import audio, audio10, cdc, hid, midi, msc, standard, util -import hid_report_descriptors - -DEFAULT_INTERFACE_NAME = "CircuitPython" -ALL_DEVICES = "CDC CDC2 MSC AUDIO HID VENDOR" -ALL_DEVICES_SET = frozenset(ALL_DEVICES.split()) -DEFAULT_DEVICES = "CDC MSC AUDIO HID" - -# This list is in preferred order. MacOS does not like GAMEPAD coming before MOUSE. -ALL_HID_DEVICES = ( - "KEYBOARD MOUSE CONSUMER SYS_CONTROL GAMEPAD DIGITIZER XAC_COMPATIBLE_GAMEPAD RAW" -) -ALL_HID_DEVICES_ORDER = dict((name, idx) for (idx, name) in enumerate(ALL_HID_DEVICES.split())) -ALL_HID_DEVICES_SET = frozenset(ALL_HID_DEVICES.split()) -# Digitizer works on Linux but conflicts with mouse, so omit it. -DEFAULT_HID_DEVICES = "KEYBOARD MOUSE CONSUMER GAMEPAD" - -# In the following URL, don't include the https:// because that prefix gets added automatically -DEFAULT_WEBUSB_URL = "circuitpython.org" # In the future, this may become a specific landing page - -parser = argparse.ArgumentParser(description="Generate USB descriptors.") -parser.add_argument( - "--highspeed", default=False, action="store_true", help="descriptor for highspeed device" -) -parser.add_argument("--manufacturer", type=str, help="manufacturer of the device") -parser.add_argument("--product", type=str, help="product name of the device") -parser.add_argument("--vid", type=lambda x: int(x, 16), help="vendor id") -parser.add_argument("--pid", type=lambda x: int(x, 16), help="product id") -parser.add_argument( - "--serial_number_length", - type=int, - default=32, - help="length needed for the serial number in digits", -) -parser.add_argument( - "--devices", - type=lambda l: tuple(l.split()), - default=DEFAULT_DEVICES, - help="devices to include in descriptor (AUDIO includes MIDI support)", -) -parser.add_argument( - "--hid_devices", - type=lambda l: tuple(l.split()), - default=DEFAULT_HID_DEVICES, - help="HID devices to include in HID report descriptor", -) -parser.add_argument( - "--interface_name", - type=str, - help="The name/prefix to use in the interface descriptions", - default=DEFAULT_INTERFACE_NAME, -) -parser.add_argument( - "--no-renumber_endpoints", - dest="renumber_endpoints", - action="store_false", - help="use to not renumber endpoint", -) -parser.add_argument( - "--cdc_ep_num_notification", type=int, default=0, help="endpoint number of CDC NOTIFICATION" -) -parser.add_argument( - "--cdc2_ep_num_notification", type=int, default=0, help="endpoint number of CDC2 NOTIFICATION" -) -parser.add_argument( - "--cdc_ep_num_data_out", type=int, default=0, help="endpoint number of CDC DATA OUT" -) -parser.add_argument( - "--cdc_ep_num_data_in", type=int, default=0, help="endpoint number of CDC DATA IN" -) -parser.add_argument( - "--cdc2_ep_num_data_out", type=int, default=0, help="endpoint number of CDC2 DATA OUT" -) -parser.add_argument( - "--cdc2_ep_num_data_in", type=int, default=0, help="endpoint number of CDC2 DATA IN" -) -parser.add_argument("--msc_ep_num_out", type=int, default=0, help="endpoint number of MSC OUT") -parser.add_argument("--msc_ep_num_in", type=int, default=0, help="endpoint number of MSC IN") -parser.add_argument("--hid_ep_num_out", type=int, default=0, help="endpoint number of HID OUT") -parser.add_argument("--hid_ep_num_in", type=int, default=0, help="endpoint number of HID IN") -parser.add_argument("--midi_ep_num_out", type=int, default=0, help="endpoint number of MIDI OUT") -parser.add_argument("--midi_ep_num_in", type=int, default=0, help="endpoint number of MIDI IN") -parser.add_argument("--max_ep", type=int, default=0, help="total number of endpoints available") -parser.add_argument( - "--webusb_url", - type=str, - help="The URL to include in the WebUSB URL Descriptor", - default=DEFAULT_WEBUSB_URL, -) -parser.add_argument( - "--vendor_ep_num_out", type=int, default=0, help="endpoint number of VENDOR OUT" -) -parser.add_argument("--vendor_ep_num_in", type=int, default=0, help="endpoint number of VENDOR IN") -parser.add_argument( - "--output_c_file", type=argparse.FileType("w", encoding="UTF-8"), required=True -) -parser.add_argument( - "--output_h_file", type=argparse.FileType("w", encoding="UTF-8"), required=True -) - -args = parser.parse_args() - -unknown_devices = list(frozenset(args.devices) - ALL_DEVICES_SET) -if unknown_devices: - raise ValueError("Unknown device(s)", unknown_devices) - -unknown_hid_devices = list(frozenset(args.hid_devices) - ALL_HID_DEVICES_SET) -if unknown_hid_devices: - raise ValueError("Unknown HID devices(s)", unknown_hid_devices) - -include_cdc = "CDC" in args.devices -include_cdc2 = "CDC2" in args.devices -include_msc = "MSC" in args.devices -include_hid = "HID" in args.devices -include_audio = "AUDIO" in args.devices -include_vendor = "VENDOR" in args.devices - -if not include_cdc and include_cdc2: - raise ValueError("CDC2 requested without CDC") - -if not args.renumber_endpoints: - if include_cdc: - if args.cdc_ep_num_notification == 0: - raise ValueError("CDC notification endpoint number must not be 0") - if args.cdc_ep_num_data_out == 0: - raise ValueError("CDC data OUT endpoint number must not be 0") - if args.cdc_ep_num_data_in == 0: - raise ValueError("CDC data IN endpoint number must not be 0") - - if include_cdc2: - if args.cdc2_ep_num_notification == 0: - raise ValueError("CDC2 notification endpoint number must not be 0") - if args.cdc2_ep_num_data_out == 0: - raise ValueError("CDC2 data OUT endpoint number must not be 0") - if args.cdc2_ep_num_data_in == 0: - raise ValueError("CDC2 data IN endpoint number must not be 0") - - if include_msc: - if args.msc_ep_num_out == 0: - raise ValueError("MSC endpoint OUT number must not be 0") - if args.msc_ep_num_in == 0: - raise ValueError("MSC endpoint IN number must not be 0") - - if include_hid: - if args.args.hid_ep_num_out == 0: - raise ValueError("HID endpoint OUT number must not be 0") - if args.hid_ep_num_in == 0: - raise ValueError("HID endpoint IN number must not be 0") - - if include_audio: - if args.args.midi_ep_num_out == 0: - raise ValueError("MIDI endpoint OUT number must not be 0") - if args.midi_ep_num_in == 0: - raise ValueError("MIDI endpoint IN number must not be 0") - - if include_vendor: - if args.vendor_ep_num_out == 0: - raise ValueError("VENDOR endpoint OUT number must not be 0") - if args.vendor_ep_num_in == 0: - raise ValueError("VENDOR endpoint IN number must not be 0") - - -class StringIndex: - """Assign a monotonically increasing index to each unique string. Start with 0.""" - - string_to_index = {} - index_to_variable = {} - strings = [] - - @classmethod - def index(cls, string, *, variable_name=None): - if string in cls.string_to_index: - idx = cls.string_to_index[string] - if not cls.index_to_variable[idx]: - cls.index_to_variable[idx] = variable_name - return idx - else: - idx = len(cls.strings) - cls.string_to_index[string] = idx - cls.strings.append(string) - cls.index_to_variable[idx] = variable_name - return idx - - @classmethod - def strings_in_order(cls): - return cls.strings - - -# langid must be the 0th string descriptor -LANGID_INDEX = StringIndex.index("\u0409", variable_name="language_id") -assert LANGID_INDEX == 0 -SERIAL_NUMBER_INDEX = StringIndex.index( - "S" * args.serial_number_length, variable_name="usb_serial_number" -) - -device = standard.DeviceDescriptor( - description="top", - idVendor=args.vid, - idProduct=args.pid, - iManufacturer=StringIndex.index(args.manufacturer), - iProduct=StringIndex.index(args.product), - iSerialNumber=SERIAL_NUMBER_INDEX, -) - -# Interface numbers are interface-set local and endpoints are interface local -# until util.join_interfaces renumbers them. - - -def make_cdc_union(name): - return cdc.Union( - description="{} comm".format(name), - # Set bMasterInterface and bSlaveInterface_list to proper values after interfaces are renumbered. - bMasterInterface=0x00, - bSlaveInterface_list=[0x01], - ) - - -def make_cdc_call_management(name): - # Set bDataInterface to proper value after interfaces are renumbered. - return cdc.CallManagement( - description="{} comm".format(name), bmCapabilities=0x01, bDataInterface=0x01 - ) - - -def make_cdc_comm_interface(name, cdc_union, cdc_call_management, cdc_ep_num_notification): - return standard.InterfaceDescriptor( - description="{} comm".format(name), - bInterfaceClass=cdc.CDC_CLASS_COMM, # Communications Device Class - bInterfaceSubClass=cdc.CDC_SUBCLASS_ACM, # Abstract control model - bInterfaceProtocol=cdc.CDC_PROTOCOL_NONE, - iInterface=StringIndex.index("{} {} control".format(args.interface_name, name)), - subdescriptors=[ - cdc.Header(description="{} comm".format(name), bcdCDC=0x0110), - cdc_call_management, - cdc.AbstractControlManagement(description="{} comm".format(name), bmCapabilities=0x02), - cdc_union, - standard.EndpointDescriptor( - description="{} comm in".format(name), - bEndpointAddress=cdc_ep_num_notification - | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_INTERRUPT, - wMaxPacketSize=0x0040, - bInterval=0x10, - ), - ], - ) - - -def make_cdc_data_interface(name, cdc_ep_num_data_in, cdc_ep_num_data_out): - return standard.InterfaceDescriptor( - description="{} data".format(name), - bInterfaceClass=cdc.CDC_CLASS_DATA, - iInterface=StringIndex.index("{} {} data".format(args.interface_name, name)), - subdescriptors=[ - standard.EndpointDescriptor( - description="{} data out".format(name), - bEndpointAddress=cdc_ep_num_data_out | standard.EndpointDescriptor.DIRECTION_OUT, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - standard.EndpointDescriptor( - description="{} data in".format(name), - bEndpointAddress=cdc_ep_num_data_in | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - ], - ) - - -if include_cdc: - cdc_union = make_cdc_union("CDC") - cdc_call_management = make_cdc_call_management("CDC") - cdc_comm_interface = make_cdc_comm_interface( - "CDC", cdc_union, cdc_call_management, args.cdc_ep_num_notification - ) - cdc_data_interface = make_cdc_data_interface( - "CDC", args.cdc_ep_num_data_in, args.cdc_ep_num_data_out - ) - - cdc_interfaces = [cdc_comm_interface, cdc_data_interface] - -if include_cdc2: - cdc2_union = make_cdc_union("CDC2") - cdc2_call_management = make_cdc_call_management("CDC2") - cdc2_comm_interface = make_cdc_comm_interface( - "CDC2", cdc2_union, cdc2_call_management, args.cdc2_ep_num_notification - ) - cdc2_data_interface = make_cdc_data_interface( - "CDC2", args.cdc2_ep_num_data_in, args.cdc2_ep_num_data_out - ) - - cdc2_interfaces = [cdc2_comm_interface, cdc2_data_interface] - -if include_msc: - msc_interfaces = [ - standard.InterfaceDescriptor( - description="MSC", - bInterfaceClass=msc.MSC_CLASS, - bInterfaceSubClass=msc.MSC_SUBCLASS_TRANSPARENT, - bInterfaceProtocol=msc.MSC_PROTOCOL_BULK, - iInterface=StringIndex.index("{} Mass Storage".format(args.interface_name)), - subdescriptors=[ - standard.EndpointDescriptor( - description="MSC in", - bEndpointAddress=args.msc_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - standard.EndpointDescriptor( - description="MSC out", - bEndpointAddress=( - args.msc_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT - ), - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - ], - ) - ] - - -if include_hid: - # When there's only one hid_device, it shouldn't have a report id. - # Otherwise, report ids are assigned sequentially: - # args.hid_devices[0] has report_id 1 - # args.hid_devices[1] has report_id 2 - # etc. - - report_ids = {} - - if len(args.hid_devices) == 1: - name = args.hid_devices[0] - combined_hid_report_descriptor = hid.ReportDescriptor( - description=name, - report_descriptor=bytes(hid_report_descriptors.REPORT_DESCRIPTOR_FUNCTIONS[name](0)), - ) - report_ids[name] = 0 - else: - report_id = 1 - concatenated_descriptors = bytearray() - # Sort HID devices by preferred order. - for name in sorted(args.hid_devices, key=ALL_HID_DEVICES_ORDER.get): - concatenated_descriptors.extend( - bytes(hid_report_descriptors.REPORT_DESCRIPTOR_FUNCTIONS[name](report_id)) - ) - report_ids[name] = report_id - report_id += 1 - combined_hid_report_descriptor = hid.ReportDescriptor( - description="MULTIDEVICE", report_descriptor=bytes(concatenated_descriptors) - ) - - # ASF4 expects keyboard and generic devices to have both in and out endpoints, - # and will fail (possibly silently) if both are not supplied. - hid_endpoint_in_descriptor = standard.EndpointDescriptor( - description="HID in", - bEndpointAddress=args.hid_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_INTERRUPT, - bInterval=8, - ) - - hid_endpoint_out_descriptor = standard.EndpointDescriptor( - description="HID out", - bEndpointAddress=args.hid_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT, - bmAttributes=standard.EndpointDescriptor.TYPE_INTERRUPT, - bInterval=8, - ) - - hid_interfaces = [ - standard.InterfaceDescriptor( - description="HID Multiple Devices", - bInterfaceClass=hid.HID_CLASS, - bInterfaceSubClass=hid.HID_SUBCLASS_NOBOOT, - bInterfaceProtocol=hid.HID_PROTOCOL_NONE, - iInterface=StringIndex.index("{} HID".format(args.interface_name)), - subdescriptors=[ - hid.HIDDescriptor( - description="HID", wDescriptorLength=len(bytes(combined_hid_report_descriptor)) - ), - hid_endpoint_in_descriptor, - hid_endpoint_out_descriptor, - ], - ) - ] - -if include_audio: - # Audio! - # In and out here are relative to CircuitPython - - # USB OUT -> midi_in_jack_emb -> midi_out_jack_ext -> CircuitPython - midi_in_jack_emb = midi.InJackDescriptor( - description="MIDI PC -> {}".format(args.interface_name), - bJackType=midi.JACK_TYPE_EMBEDDED, - iJack=StringIndex.index("{} usb_midi.ports[0]".format(args.interface_name)), - ) - midi_out_jack_ext = midi.OutJackDescriptor( - description="MIDI data out to user code.", - bJackType=midi.JACK_TYPE_EXTERNAL, - input_pins=[(midi_in_jack_emb, 1)], - iJack=0, - ) - - # USB IN <- midi_out_jack_emb <- midi_in_jack_ext <- CircuitPython - midi_in_jack_ext = midi.InJackDescriptor( - description="MIDI data in from user code.", bJackType=midi.JACK_TYPE_EXTERNAL, iJack=0 - ) - midi_out_jack_emb = midi.OutJackDescriptor( - description="MIDI PC <- {}".format(args.interface_name), - bJackType=midi.JACK_TYPE_EMBEDDED, - input_pins=[(midi_in_jack_ext, 1)], - iJack=StringIndex.index("{} usb_midi.ports[1]".format(args.interface_name)), - ) - - audio_midi_interface = standard.InterfaceDescriptor( - description="Midi goodness", - bInterfaceClass=audio.AUDIO_CLASS_DEVICE, - bInterfaceSubClass=audio.AUDIO_SUBCLASS_MIDI_STREAMING, - bInterfaceProtocol=audio.AUDIO_PROTOCOL_V1, - iInterface=StringIndex.index("{} MIDI".format(args.interface_name)), - subdescriptors=[ - midi.Header( - jacks_and_elements=[ - midi_in_jack_emb, - midi_in_jack_ext, - midi_out_jack_emb, - midi_out_jack_ext, - ] - ), - standard.EndpointDescriptor( - description="MIDI data out to {}".format(args.interface_name), - bEndpointAddress=args.midi_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - midi.DataEndpointDescriptor(baAssocJack=[midi_in_jack_emb]), - standard.EndpointDescriptor( - description="MIDI data in from {}".format(args.interface_name), - bEndpointAddress=args.midi_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=0x0, - wMaxPacketSize=512 if args.highspeed else 64, - ), - midi.DataEndpointDescriptor(baAssocJack=[midi_out_jack_emb]), - ], - ) - - cs_ac_interface = audio10.AudioControlInterface( - description="Empty audio control", - audio_streaming_interfaces=[], - midi_streaming_interfaces=[audio_midi_interface], - ) - - audio_control_interface = standard.InterfaceDescriptor( - description="All the audio", - bInterfaceClass=audio.AUDIO_CLASS_DEVICE, - bInterfaceSubClass=audio.AUDIO_SUBCLASS_CONTROL, - bInterfaceProtocol=audio.AUDIO_PROTOCOL_V1, - iInterface=StringIndex.index("{} Audio".format(args.interface_name)), - subdescriptors=[cs_ac_interface], - ) - - # Audio streaming interfaces must occur before MIDI ones. - audio_interfaces = ( - [audio_control_interface] - + cs_ac_interface.audio_streaming_interfaces - + cs_ac_interface.midi_streaming_interfaces - ) - -if include_vendor: - # Vendor-specific interface, for example WebUSB - vendor_endpoint_in_descriptor = standard.EndpointDescriptor( - description="VENDOR in", - bEndpointAddress=args.vendor_ep_num_in | standard.EndpointDescriptor.DIRECTION_IN, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=16, - ) - - vendor_endpoint_out_descriptor = standard.EndpointDescriptor( - description="VENDOR out", - bEndpointAddress=args.vendor_ep_num_out | standard.EndpointDescriptor.DIRECTION_OUT, - bmAttributes=standard.EndpointDescriptor.TYPE_BULK, - bInterval=16, - ) - - vendor_interface = standard.InterfaceDescriptor( - description="VENDOR", - bInterfaceClass=0xFF, # Vendor-specific - bInterfaceSubClass=0x00, - bInterfaceProtocol=0x00, - iInterface=StringIndex.index("{} VENDOR".format(args.interface_name)), - subdescriptors=[vendor_endpoint_in_descriptor, vendor_endpoint_out_descriptor], - ) - - vendor_interfaces = [vendor_interface] - -interfaces_to_join = [] - -if include_cdc: - interfaces_to_join.append(cdc_interfaces) - -if include_cdc2: - interfaces_to_join.append(cdc2_interfaces) - -if include_msc: - interfaces_to_join.append(msc_interfaces) - -if include_hid: - interfaces_to_join.append(hid_interfaces) - -if include_audio: - interfaces_to_join.append(audio_interfaces) - -if include_vendor: - interfaces_to_join.append(vendor_interfaces) - -# util.join_interfaces() will renumber the endpoints to make them unique across descriptors, -# and renumber the interfaces in order. But we still need to fix up certain -# interface cross-references. -interfaces = util.join_interfaces(interfaces_to_join, renumber_endpoints=args.renumber_endpoints) - -if args.max_ep != 0: - for interface in interfaces: - for subdescriptor in interface.subdescriptors: - endpoint_address = getattr(subdescriptor, "bEndpointAddress", 0) & 0x7F - if endpoint_address >= args.max_ep: - raise ValueError( - "Endpoint address %d of '%s' must be less than %d; you have probably run out of endpoints" - % (endpoint_address & 0x7F, interface.description, args.max_ep) - ) -else: - print("Unable to check whether maximum number of endpoints is respected", file=sys.stderr) - -# Now adjust the CDC interface cross-references. - -if include_cdc: - cdc_union.bMasterInterface = cdc_comm_interface.bInterfaceNumber - cdc_union.bSlaveInterface_list = [cdc_data_interface.bInterfaceNumber] - - cdc_call_management.bDataInterface = cdc_data_interface.bInterfaceNumber - -if include_cdc2: - cdc2_union.bMasterInterface = cdc2_comm_interface.bInterfaceNumber - cdc2_union.bSlaveInterface_list = [cdc2_data_interface.bInterfaceNumber] - - cdc2_call_management.bDataInterface = cdc2_data_interface.bInterfaceNumber - - -def make_cdc_iad(cdc_comm_interface, name): - return standard.InterfaceAssociationDescriptor( - description="{} IAD".format(name), - bFirstInterface=cdc_comm_interface.bInterfaceNumber, - bInterfaceCount=len(cdc_interfaces), - bFunctionClass=cdc.CDC_CLASS_COMM, # Communications Device Class - bFunctionSubClass=cdc.CDC_SUBCLASS_ACM, # Abstract control model - bFunctionProtocol=cdc.CDC_PROTOCOL_NONE, - ) - - -if include_cdc: - cdc_iad = make_cdc_iad(cdc_comm_interface, "CDC") -if include_cdc2: - cdc2_iad = make_cdc_iad(cdc2_comm_interface, "CDC2") - -descriptor_list = [] - -if include_cdc: - # Put the CDC IAD just before the CDC interfaces. - # There appears to be a bug in the Windows composite USB driver that requests the - # HID report descriptor with the wrong interface number if the HID interface is not given - # first. However, it still fetches the descriptor anyway. We could reorder the interfaces but - # the Windows 7 Adafruit_usbser.inf file thinks CDC is at Interface 0, so we'll leave it - # there for backwards compatibility. - descriptor_list.append(cdc_iad) - descriptor_list.extend(cdc_interfaces) - -if include_cdc2: - descriptor_list.append(cdc2_iad) - descriptor_list.extend(cdc2_interfaces) - -if include_msc: - descriptor_list.extend(msc_interfaces) - -if include_hid: - descriptor_list.extend(hid_interfaces) - -if include_audio: - # Only add the control interface because other audio interfaces are managed by it to ensure the - # correct ordering. - descriptor_list.append(audio_control_interface) - -if include_vendor: - descriptor_list.extend(vendor_interfaces) - -# Finally, build the composite descriptor. - -configuration = standard.ConfigurationDescriptor( - description="Composite configuration", - wTotalLength=( - standard.ConfigurationDescriptor.bLength + sum([len(bytes(x)) for x in descriptor_list]) - ), - bNumInterfaces=len(interfaces), - # bus powered (bit 6), remote wakeup (bit 5), - # bit 7 is always 1 and 0-4 are always 0 - # Turn off remote wakeup until we handle it in CircuitPython. - bmAttributes=0x80, -) -descriptor_list.insert(0, configuration) - -string_descriptors = [ - standard.StringDescriptor(string) for string in StringIndex.strings_in_order() -] -serial_number_descriptor = string_descriptors[SERIAL_NUMBER_INDEX] - -c_file = args.output_c_file -h_file = args.output_h_file - - -c_file.write( - """\ -#include - -#include "tusb.h" -#include "py/objtuple.h" -#include "shared-bindings/usb_hid/Device.h" -#include "{H_FILE_NAME}" - -""".format( - H_FILE_NAME=h_file.name - ) -) - -c_file.write( - """\ -// {DESCRIPTION} : {CLASS} -""".format( - DESCRIPTION=device.description, CLASS=device.__class__ - ) -) - -c_file.write( - """\ -const uint8_t usb_desc_dev[] = { -""" -) -for b in bytes(device): - c_file.write("0x{:02x}, ".format(b)) - -c_file.write( - """\ -}; -""" -) - -c_file.write( - """\ -const uint8_t usb_desc_cfg[] = { -""" -) - -# Write out all the regular descriptors as one long array (that's how ASF4 does it). -descriptor_length = 0 -for descriptor in descriptor_list: - c_file.write( - """\ -// {DESCRIPTION} : {CLASS} -""".format( - DESCRIPTION=descriptor.description, CLASS=descriptor.__class__ - ) - ) - - b = bytes(descriptor) - notes = descriptor.notes() - i = 0 - - # This prints each subdescriptor on a separate line. - n = 0 - while i < len(b): - length = b[i] - for j in range(length): - c_file.write("0x{:02x}, ".format(b[i + j])) - c_file.write("// " + notes[n]) - n += 1 - c_file.write("\n") - i += length - descriptor_length += len(b) - -c_file.write( - """\ -}; -""" -) - -pointers_to_strings = [] - -for idx, descriptor in enumerate(string_descriptors): - c_file.write( - """\ -// {DESCRIPTION} : {CLASS} -""".format( - DESCRIPTION=descriptor.description, CLASS=descriptor.__class__ - ) - ) - - b = bytes(descriptor) - notes = descriptor.notes() - i = 0 - - # This prints each subdescriptor on a separate line. - variable_name = StringIndex.index_to_variable[idx] - if not variable_name: - variable_name = "string_descriptor{}".format(idx) - pointers_to_strings.append("{name}".format(name=variable_name)) - - const = "const " - if variable_name == "usb_serial_number": - length = len(b) - c_file.write( - " uint16_t {NAME}[{length}];\n".format(NAME=variable_name, length=length // 2) - ) - else: - c_file.write( - """\ - const uint16_t {NAME}[] = {{ - """.format( - const=const, NAME=variable_name - ) - ) - n = 0 - while i < len(b): - length = b[i] - for j in range(length // 2): - c_file.write("0x{:04x}, ".format(b[i + 2 * j + 1] << 8 | b[i + 2 * j])) - n += 1 - c_file.write("\n") - i += length - c_file.write( - """\ - }; - """ - ) - -c_file.write( - """\ -// array of pointer to string descriptors -uint16_t const * const string_desc_arr [] = -{ -""" -) -c_file.write( - """,\ - -""".join( - pointers_to_strings - ) -) - -c_file.write( - """ -}; -""" -) - -c_file.write("\n") - -if include_hid: - hid_descriptor_length = len(bytes(combined_hid_report_descriptor)) -else: - hid_descriptor_length = 0 - -# Now the values we need for the .h file. -h_file.write( - """\ -#ifndef MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H -#define MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H - -#include - -extern const uint8_t usb_desc_dev[{device_length}]; -extern const uint8_t usb_desc_cfg[{configuration_length}]; -extern uint16_t usb_serial_number[{serial_number_length}]; -extern uint16_t const * const string_desc_arr [{string_descriptor_length}]; - -#define CFG_TUSB_RHPORT0_MODE ({rhport0_mode}) - -// Vendor name included in Inquiry response, max 8 bytes -#define CFG_TUD_MSC_VENDOR "{msc_vendor}" - -// Product name included in Inquiry response, max 16 bytes -#define CFG_TUD_MSC_PRODUCT "{msc_product}" - -""".format( - serial_number_length=len(bytes(serial_number_descriptor)) // 2, - device_length=len(bytes(device)), - configuration_length=descriptor_length, - max_configuration_length=max(hid_descriptor_length, descriptor_length), - string_descriptor_length=len(pointers_to_strings), - rhport0_mode="OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED" - if args.highspeed - else "OPT_MODE_DEVICE", - msc_vendor=args.manufacturer[:8], - msc_product=args.product[:16], - ) -) - -if include_hid: - h_file.write( - """\ -extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}]; - -#define USB_HID_NUM_DEVICES {hid_num_devices} -""".format( - hid_report_descriptor_length=len(bytes(combined_hid_report_descriptor)), - hid_num_devices=len(args.hid_devices), - ) - ) - -if include_vendor: - h_file.write( - """\ -enum -{ - VENDOR_REQUEST_WEBUSB = 1, - VENDOR_REQUEST_MICROSOFT = 2 -}; - -extern uint8_t const desc_ms_os_20[]; - -// Currently getting compile-time errors in files like tusb_fifo.c -// if we try do define this here (TODO figure this out!) -//extern const tusb_desc_webusb_url_t desc_webusb_url; - -""" - ) - -h_file.write( - """\ -#endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H -""" -) - -if include_hid: - # Write out the report descriptor and info - c_file.write( - """\ -const uint8_t hid_report_descriptor[{HID_DESCRIPTOR_LENGTH}] = {{ -""".format( - HID_DESCRIPTOR_LENGTH=hid_descriptor_length - ) - ) - - for b in bytes(combined_hid_report_descriptor): - c_file.write("0x{:02x}, ".format(b)) - - c_file.write( - """\ -}; - -""" - ) - - # Write out USB HID report buffer definitions. - for name in args.hid_devices: - c_file.write( - """\ -static uint8_t {name}_report_buffer[{report_length}]; -""".format( - name=name.lower(), - report_length=hid_report_descriptors.HID_DEVICE_DATA[name].report_length, - ) - ) - - if hid_report_descriptors.HID_DEVICE_DATA[name].out_report_length > 0: - c_file.write( - """\ -static uint8_t {name}_out_report_buffer[{report_length}]; -""".format( - name=name.lower(), - report_length=hid_report_descriptors.HID_DEVICE_DATA[name].out_report_length, - ) - ) - - # Write out table of device objects. - c_file.write( - """\ -usb_hid_device_obj_t usb_hid_devices[] = { -""" - ) - for name in args.hid_devices: - device_data = hid_report_descriptors.HID_DEVICE_DATA[name] - out_report_buffer = ( - "{}_out_report_buffer".format(name.lower()) - if device_data.out_report_length > 0 - else "NULL" - ) - c_file.write( - """\ - {{ - .base = {{ .type = &usb_hid_device_type }}, - .report_buffer = {name}_report_buffer, - .report_id = {report_id}, - .report_length = {report_length}, - .usage_page = {usage_page:#04x}, - .usage = {usage:#04x}, - .out_report_buffer = {out_report_buffer}, - .out_report_length = {out_report_length}, - }}, -""".format( - name=name.lower(), - report_id=report_ids[name], - report_length=device_data.report_length, - usage_page=device_data.usage_page, - usage=device_data.usage, - out_report_buffer=out_report_buffer, - out_report_length=device_data.out_report_length, - ) - ) - c_file.write( - """\ -}; -""" - ) - - # Write out tuple of device objects. - c_file.write( - """ -mp_obj_tuple_t common_hal_usb_hid_devices = {{ - .base = {{ - .type = &mp_type_tuple, - }}, - .len = {num_devices}, - .items = {{ -""".format( - num_devices=len(args.hid_devices) - ) - ) - for idx in range(len(args.hid_devices)): - c_file.write( - """\ - (mp_obj_t) &usb_hid_devices[{idx}], -""".format( - idx=idx - ) - ) - c_file.write( - """\ - }, -}; -""" - ) - -if include_vendor: - # Mimic what the tinyusb webusb demo does in its main.c file - c_file.write( - """ -#define URL "{webusb_url}" - -const tusb_desc_webusb_url_t desc_webusb_url = -{{ - .bLength = 3 + sizeof(URL) - 1, - .bDescriptorType = 3, // WEBUSB URL type - .bScheme = 1, // 0: http, 1: https, 255: "" - .url = URL -}}; - -// These next two hardcoded descriptors were pulled from the usb_descriptor.c file -// of the tinyusb webusb_serial demo. TODO - this is probably something else to -// integrate into the adafruit_usb_descriptors project... - -//--------------------------------------------------------------------+ -// BOS Descriptor -//--------------------------------------------------------------------+ - -/* Microsoft OS 2.0 registry property descriptor -Per MS requirements https://msdn.microsoft.com/en-us/library/windows/hardware/hh450799(v=vs.85).aspx -device should create DeviceInterfaceGUIDs. It can be done by driver and -in case of real PnP solution device should expose MS "Microsoft OS 2.0 -registry property descriptor". Such descriptor can insert any record -into Windows registry per device/configuration/interface. In our case it -will insert "DeviceInterfaceGUIDs" multistring property. - -GUID is freshly generated and should be OK to use. - -https://developers.google.com/web/fundamentals/native-hardware/build-for-webusb/ -(Section Microsoft OS compatibility descriptors) -*/ - -#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) - -#define MS_OS_20_DESC_LEN 0xB2 - -// BOS Descriptor is required for webUSB -uint8_t const desc_bos[] = -{{ - // total length, number of device caps - TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2), - - // Vendor Code, iLandingPage - TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1), - - // Microsoft OS 2.0 descriptor - TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT) -}}; - -uint8_t const * tud_descriptor_bos_cb(void) -{{ - return desc_bos; -}} - - -#define ITF_NUM_VENDOR {webusb_interface} // used in this next descriptor - -uint8_t const desc_ms_os_20[] = -{{ - // Set header: length, type, windows version, total length - U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN), - - // Configuration subset header: length, type, configuration index, reserved, configuration total length - U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A), - - // Function Subset header: length, type, first interface, reserved, subset length - U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), ITF_NUM_VENDOR, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08), - - // MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID - U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible - - // MS OS 2.0 Registry property descriptor: length, type - U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x0A-0x08-0x08-0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), - U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16 - 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, - 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00, - U16_TO_U8S_LE(0x0050), // wPropertyDataLength - //bPropertyData: “{{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}}”. - '{{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00, - '0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00, - '8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00, - '8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}}', 0x00, 0x00, 0x00, 0x00, 0x00 -}}; - -TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size"); - -// End of section about desc_ms_os_20 - -""".format( - webusb_url=args.webusb_url, webusb_interface=vendor_interface.bInterfaceNumber - ) - ) diff --git a/tools/hid_report_descriptors.py b/tools/hid_report_descriptors.py deleted file mode 100644 index 827af3a3f0..0000000000 --- a/tools/hid_report_descriptors.py +++ /dev/null @@ -1,521 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018 Dan Halbert for Adafruit Industries -# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) -# -# SPDX-License-Identifier: MIT - -import struct - -""" -HID specific descriptors -======================== - -* Author(s): Dan Halbert -""" - -from collections import namedtuple - -from adafruit_usb_descriptor import hid - -# Information about each kind of device -# report_length does not include report ID in first byte, if present when sent. -DeviceData = namedtuple( - "DeviceData", ("report_length", "out_report_length", "usage_page", "usage") -) -HID_DEVICE_DATA = { - "KEYBOARD": DeviceData( - report_length=8, out_report_length=1, usage_page=0x01, usage=0x06 - ), # Generic Desktop, Keyboard - "MOUSE": DeviceData( - report_length=4, out_report_length=0, usage_page=0x01, usage=0x02 - ), # Generic Desktop, Mouse - "CONSUMER": DeviceData( - report_length=2, out_report_length=0, usage_page=0x0C, usage=0x01 - ), # Consumer, Consumer Control - "SYS_CONTROL": DeviceData( - report_length=1, out_report_length=0, usage_page=0x01, usage=0x80 - ), # Generic Desktop, Sys Control - "GAMEPAD": DeviceData( - report_length=6, out_report_length=0, usage_page=0x01, usage=0x05 - ), # Generic Desktop, Game Pad - "DIGITIZER": DeviceData( - report_length=5, out_report_length=0, usage_page=0x0D, usage=0x02 - ), # Digitizers, Pen - "XAC_COMPATIBLE_GAMEPAD": DeviceData( - report_length=3, out_report_length=0, usage_page=0x01, usage=0x05 - ), # Generic Desktop, Game Pad - "RAW": DeviceData( - report_length=64, out_report_length=0, usage_page=0xFFAF, usage=0xAF - ), # Vendor 0xFFAF "Adafruit", 0xAF -} - - -def keyboard_hid_descriptor(report_id): - data = HID_DEVICE_DATA["KEYBOARD"] - return hid.ReportDescriptor( - description="KEYBOARD", - report_descriptor=bytes( - # Regular keyboard - ( - 0x05, - data.usage_page, # Usage Page (Generic Desktop) - 0x09, - data.usage, # Usage (Keyboard) - 0xA1, - 0x01, # Collection (Application) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x05, - 0x07, # Usage Page (Keyboard) - 0x19, - 224, # Usage Minimum (224) - 0x29, - 231, # Usage Maximum (231) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0x01, # Logical Maximum (1) - 0x75, - 0x01, # Report Size (1) - 0x95, - 0x08, # Report Count (8) - 0x81, - 0x02, # Input (Data, Variable, Absolute) - 0x81, - 0x01, # Input (Constant) - 0x19, - 0x00, # Usage Minimum (0) - 0x29, - 0xDD, # Usage Maximum (221) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0xDD, # Logical Maximum (221) - 0x75, - 0x08, # Report Size (8) - 0x95, - 0x06, # Report Count (6) - 0x81, - 0x00, # Input (Data, Array) - 0x05, - 0x08, # Usage Page (LED) - 0x19, - 0x01, # Usage Minimum (1) - 0x29, - 0x05, # Usage Maximum (5) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0x01, # Logical Maximum (1) - 0x75, - 0x01, # Report Size (1) - 0x95, - 0x05, # Report Count (5) - 0x91, - 0x02, # Output (Data, Variable, Absolute) - 0x95, - 0x03, # Report Count (3) - 0x91, - 0x01, # Output (Constant) - 0xC0, # End Collection - ) - ), - ) - - -def mouse_hid_descriptor(report_id): - data = HID_DEVICE_DATA["MOUSE"] - return hid.ReportDescriptor( - description="MOUSE", - report_descriptor=bytes( - # Regular mouse - ( - 0x05, - data.usage_page, # Usage Page (Generic Desktop) - 0x09, - data.usage, # Usage (Mouse) - 0xA1, - 0x01, # Collection (Application) - 0x09, - 0x01, # Usage (Pointer) - 0xA1, - 0x00, # Collection (Physical) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x05, - 0x09, # Usage Page (Button) - 0x19, - 0x01, # Usage Minimum (0x01) - 0x29, - 0x05, # Usage Maximum (0x05) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0x01, # Logical Maximum (1) - 0x95, - 0x05, # Report Count (5) - 0x75, - 0x01, # Report Size (1) - 0x81, - 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x95, - 0x01, # Report Count (1) - 0x75, - 0x03, # Report Size (3) - 0x81, - 0x01, # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, - 0x01, # Usage Page (Generic Desktop Ctrls) - 0x09, - 0x30, # Usage (X) - 0x09, - 0x31, # Usage (Y) - 0x15, - 0x81, # Logical Minimum (-127) - 0x25, - 0x7F, # Logical Maximum (127) - 0x75, - 0x08, # Report Size (8) - 0x95, - 0x02, # Report Count (2) - 0x81, - 0x06, # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) - 0x09, - 0x38, # Usage (Wheel) - 0x15, - 0x81, # Logical Minimum (-127) - 0x25, - 0x7F, # Logical Maximum (127) - 0x75, - 0x08, # Report Size (8) - 0x95, - 0x01, # Report Count (1) - 0x81, - 0x06, # Input (Data,Var,Rel,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, # End Collection - 0xC0, # End Collection - ) - ), - ) - - -def consumer_hid_descriptor(report_id): - data = HID_DEVICE_DATA["CONSUMER"] - return hid.ReportDescriptor( - description="CONSUMER", - report_descriptor=bytes( - # Consumer ("multimedia") keys - ( - 0x05, - data.usage_page, # Usage Page (Consumer) - 0x09, - data.usage, # Usage (Consumer Control) - 0xA1, - 0x01, # Collection (Application) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x75, - 0x10, # Report Size (16) - 0x95, - 0x01, # Report Count (1) - 0x15, - 0x01, # Logical Minimum (1) - 0x26, - 0x8C, - 0x02, # Logical Maximum (652) - 0x19, - 0x01, # Usage Minimum (Consumer Control) - 0x2A, - 0x8C, - 0x02, # Usage Maximum (AC Send) - 0x81, - 0x00, # Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, # End Collection - ) - ), - ) - - -def sys_control_hid_descriptor(report_id): - data = HID_DEVICE_DATA["SYS_CONTROL"] - return hid.ReportDescriptor( - description="SYS_CONTROL", - report_descriptor=bytes( - # Power controls - ( - 0x05, - data.usage_page, # Usage Page (Generic Desktop Ctrls) - 0x09, - data.usage, # Usage (Sys Control) - 0xA1, - 0x01, # Collection (Application) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x75, - 0x02, # Report Size (2) - 0x95, - 0x01, # Report Count (1) - 0x15, - 0x01, # Logical Minimum (1) - 0x25, - 0x03, # Logical Maximum (3) - 0x09, - 0x82, # Usage (Sys Sleep) - 0x09, - 0x81, # Usage (Sys Power Down) - 0x09, - 0x83, # Usage (Sys Wake Up) - 0x81, - 0x60, # Input (Data,Array,Abs,No Wrap,Linear,No Preferred State,Null State) - 0x75, - 0x06, # Report Size (6) - 0x81, - 0x03, # Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, # End Collection - ) - ), - ) - - -def gamepad_hid_descriptor(report_id): - data = HID_DEVICE_DATA["GAMEPAD"] - return hid.ReportDescriptor( - description="GAMEPAD", - report_descriptor=bytes( - # Gamepad with 16 buttons and two joysticks - ( - 0x05, - data.usage_page, # Usage Page (Generic Desktop Ctrls) - 0x09, - data.usage, # Usage (Game Pad) - 0xA1, - 0x01, # Collection (Application) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x05, - 0x09, # Usage Page (Button) - 0x19, - 0x01, # Usage Minimum (Button 1) - 0x29, - 0x10, # Usage Maximum (Button 16) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0x01, # Logical Maximum (1) - 0x75, - 0x01, # Report Size (1) - 0x95, - 0x10, # Report Count (16) - 0x81, - 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, - 0x01, # Usage Page (Generic Desktop Ctrls) - 0x15, - 0x81, # Logical Minimum (-127) - 0x25, - 0x7F, # Logical Maximum (127) - 0x09, - 0x30, # Usage (X) - 0x09, - 0x31, # Usage (Y) - 0x09, - 0x32, # Usage (Z) - 0x09, - 0x35, # Usage (Rz) - 0x75, - 0x08, # Report Size (8) - 0x95, - 0x04, # Report Count (4) - 0x81, - 0x02, # Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, # End Collection - ) - ), - ) - - -def digitizer_hid_descriptor(report_id): - data = HID_DEVICE_DATA["DIGITIZER"] - return hid.ReportDescriptor( - description="DIGITIZER", - report_descriptor=bytes( - # Digitizer (used as an absolute pointer) - ( - 0x05, - data.usage_page, # Usage Page (Digitizers) - 0x09, - data.usage, # Usage (Pen) - 0xA1, - 0x01, # Collection (Application) - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x09, - 0x01, # Usage (Stylus) - 0xA1, - 0x00, # Collection (Physical) - 0x09, - 0x32, # Usage (In-Range) - 0x09, - 0x42, # Usage (Tip Switch) - 0x09, - 0x44, # Usage (Barrel Switch) - 0x09, - 0x45, # Usage (Eraser Switch) - 0x15, - 0x00, # Logical Minimum (0) - 0x25, - 0x01, # Logical Maximum (1) - 0x75, - 0x01, # Report Size (1) - 0x95, - 0x04, # Report Count (4) - 0x81, - 0x02, # Input (Data,Var,Abs) - 0x75, - 0x04, # Report Size (4) -- Filler - 0x95, - 0x01, # Report Count (1) -- Filler - 0x81, - 0x01, # Input (Const,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, - 0x01, # Usage Page (Generic Desktop Ctrls) - 0x15, - 0x00, # Logical Minimum (0) - 0x26, - 0xFF, - 0x7F, # Logical Maximum (32767) - 0x09, - 0x30, # Usage (X) - 0x09, - 0x31, # Usage (Y) - 0x75, - 0x10, # Report Size (16) - 0x95, - 0x02, # Report Count (2) - 0x81, - 0x02, # Input (Data,Var,Abs) - 0xC0, # End Collection - 0xC0, # End Collection - ) - ), - ) - - -def xac_compatible_gamepad_hid_descriptor(report_id): - data = HID_DEVICE_DATA["XAC_COMPATIBLE_GAMEPAD"] - return hid.ReportDescriptor( - description="XAC", - report_descriptor=bytes( - # This descriptor mimics the simple joystick from PDP that the XBox likes - ( - 0x05, - data.usage_page, # Usage Page (Desktop), - 0x09, - data.usage, # Usage (Gamepad), - 0xA1, - 0x01, # Collection (Application), - ) - + ((0x85, report_id) if report_id != 0 else ()) - + ( - 0x15, - 0x00, # Logical Minimum (0), - 0x25, - 0x01, # Logical Maximum (1), - 0x35, - 0x00, # Physical Minimum (0), - 0x45, - 0x01, # Physical Maximum (1), - 0x75, - 0x01, # Report Size (1), - 0x95, - 0x08, # Report Count (8), - 0x05, - 0x09, # Usage Page (Button), - 0x19, - 0x01, # Usage Minimum (01h), - 0x29, - 0x08, # Usage Maximum (08h), - 0x81, - 0x02, # Input (Variable), - 0x05, - 0x01, # Usage Page (Desktop), - 0x26, - 0xFF, - 0x00, # Logical Maximum (255), - 0x46, - 0xFF, - 0x00, # Physical Maximum (255), - 0x09, - 0x30, # Usage (X), - 0x09, - 0x31, # Usage (Y), - 0x75, - 0x08, # Report Size (8), - 0x95, - 0x02, # Report Count (2), - 0x81, - 0x02, # Input (Variable), - 0xC0, # End Collection - ) - ), - ) - - -def raw_hid_descriptor(report_id): - if report_id != 0: - raise ValueError("raw hid must not have a report id") - data = HID_DEVICE_DATA["RAW"] - return hid.ReportDescriptor( - description="RAW", - report_descriptor=bytes( - # Provide vendor-defined - # This is a two-byte page value. - ( - 0x06, - data.usage_page & 0xFF, - (data.usage_page >> 8) & 0xFF, # Usage Page (Vendor 0xFFAF "Adafruit"), - 0x09, - data.usage, # Usage (AF), - 0xA1, - 0x01, # Collection (Application), - 0x75, - 0x08, # Report Size (8), - 0x15, - 0x00, # Logical Minimum (0), - 0x26, - 0xFF, - 0x00, # Logical Maximum (255), - 0x95, - 0x08, # Report Count (8), - 0x09, - 0x01, # Usage(xxx) - 0x81, - 0x02, # Input (Variable) - 0x95, - 0x08, # Report Count (8), - 0x09, - 0x02, # Usage(xxx) - 0x91, - 0x02, # Input (Variable) - 0xC0, # End Collection - ) - ), - ) - - -# Function to call for each kind of HID descriptor. -REPORT_DESCRIPTOR_FUNCTIONS = { - "KEYBOARD": keyboard_hid_descriptor, - "MOUSE": mouse_hid_descriptor, - "CONSUMER": consumer_hid_descriptor, - "SYS_CONTROL": sys_control_hid_descriptor, - "GAMEPAD": gamepad_hid_descriptor, - "DIGITIZER": digitizer_hid_descriptor, - "XAC_COMPATIBLE_GAMEPAD": xac_compatible_gamepad_hid_descriptor, - "RAW": raw_hid_descriptor, -}