summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2021-03-02 15:17:12 -0500
committerDan Halbert <halbert@halwitz.org>2021-03-02 15:17:12 -0500
commitf31b4723093637ebd2566684dc3d1f61944d9e61 (patch)
treeac99e66ee83bfe2be37f2f92288eef555af6fba5 /supervisor
parent9939c59caa4e13011e9d1f63079cb4a7942cfcc4 (diff)
parente4f0e47d9f0bb620f56b93c649197b16105ab5b2 (diff)
Merge remote-tracking branch 'adafruit/main' into rp2040-i2c-short-writes
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/display.c23
-rw-r--r--supervisor/shared/serial.c1
-rw-r--r--supervisor/shared/usb/tusb_config.h9
-rw-r--r--supervisor/shared/usb/usb.c12
-rw-r--r--supervisor/shared/usb/usb_desc.c7
-rw-r--r--supervisor/supervisor.mk270
6 files changed, 179 insertions, 143 deletions
diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c
index 9c9c66cd7..1919cf4a4 100644
--- a/supervisor/shared/display.c
+++ b/supervisor/shared/display.c
@@ -270,15 +270,20 @@ displayio_tilegrid_t blinka_sprite = {
};
#if CIRCUITPY_TERMINALIO
-#define CHILD_COUNT 2
-displayio_group_child_t splash_children[2] = {
- {&blinka_sprite, &blinka_sprite},
- {&supervisor_terminal_text_grid, &supervisor_terminal_text_grid}
+mp_obj_t members[] = { &blinka_sprite, &supervisor_terminal_text_grid, };
+mp_obj_list_t splash_children = {
+ .base = {.type = &mp_type_list },
+ .alloc = 2,
+ .len = 2,
+ .items = members,
};
#else
-#define CHILD_COUNT 1
-displayio_group_child_t splash_children[1] = {
- {&blinka_sprite, &blinka_sprite},
+mp_obj_t members[] = { &blinka_sprite };
+mp_obj_list_t splash_children = {
+ .base = {.type = &mp_type_list },
+ .alloc = 1,
+ .len = 1,
+ .items = members,
};
#endif
@@ -287,9 +292,7 @@ displayio_group_t circuitpython_splash = {
.x = 0,
.y = 0,
.scale = 2,
- .size = CHILD_COUNT,
- .max_size = CHILD_COUNT,
- .children = splash_children,
+ .members = &splash_children,
.item_removed = false,
.in_group = false,
.hidden = false,
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c
index b9feb04f2..9cc12de51 100644
--- a/supervisor/shared/serial.c
+++ b/supervisor/shared/serial.c
@@ -118,7 +118,6 @@ bool serial_bytes_available(void) {
return tud_cdc_available() > 0;
#endif
}
-
void serial_write_substring(const char* text, uint32_t length) {
if (length == 0) {
return;
diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h
index d3a35f537..676810119 100644
--- a/supervisor/shared/usb/tusb_config.h
+++ b/supervisor/shared/usb/tusb_config.h
@@ -61,11 +61,16 @@
// DEVICE CONFIGURATION
//--------------------------------------------------------------------+
-#define CFG_TUD_ENDOINT0_SIZE 64
+#define CFG_TUD_ENDPOINT0_SIZE 64
//------------- CLASS -------------//
+
+// Could be 2 if secondary CDC channel requested.
+#ifndef CFG_TUD_CDC
#define CFG_TUD_CDC 1
-#define CFG_TUD_MSC 1
+#endif
+
+#define CFG_TUD_MSC CIRCUITPY_USB_MSC
#define CFG_TUD_HID CIRCUITPY_USB_HID
#define CFG_TUD_MIDI CIRCUITPY_USB_MIDI
#define CFG_TUD_VENDOR CIRCUITPY_USB_VENDOR
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index 43564d5d5..614bf85e0 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -26,7 +26,6 @@
#include "py/objstr.h"
#include "shared-bindings/microcontroller/Processor.h"
-#include "shared-module/usb_midi/__init__.h"
#include "supervisor/background_callback.h"
#include "supervisor/port.h"
#include "supervisor/serial.h"
@@ -35,6 +34,10 @@
#include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h"
+#if CIRCUITPY_USB_MIDI
+#include "shared-module/usb_midi/__init__.h"
+#endif
+
#include "tusb.h"
#if CIRCUITPY_USB_VENDOR
@@ -59,6 +62,7 @@ void load_serial_number(void) {
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;
@@ -127,12 +131,16 @@ void usb_irq_handler(void) {
// Invoked when device is mounted
void tud_mount_cb(void) {
+#if CIRCUITPY_USB_MSC
usb_msc_mount();
+#endif
}
// Invoked when device is unmounted
void tud_umount_cb(void) {
+#if CIRCUITPY_USB_MSC
usb_msc_umount();
+#endif
}
// Invoked when usb bus is suspended
@@ -216,7 +224,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
return true;
}
-#endif CIRCUITPY_USB_VENDOR
+#endif // CIRCUITPY_USB_VENDOR
#if MICROPY_KBD_EXCEPTION
diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c
index 080187ebc..b08d3b227 100644
--- a/supervisor/shared/usb/usb_desc.c
+++ b/supervisor/shared/usb/usb_desc.c
@@ -43,12 +43,15 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
return usb_desc_cfg;
}
+#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(void) {
- return hid_report_descriptor;
+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
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk
index f559e004e..374b7a72b 100644
--- a/supervisor/supervisor.mk
+++ b/supervisor/supervisor.mk
@@ -14,23 +14,15 @@ SRC_SUPERVISOR = \
supervisor/shared/tick.c \
supervisor/shared/translate.c
-ifndef $(NO_USB)
- NO_USB = $(wildcard supervisor/usb.c)
-endif
+NO_USB ?= $(wildcard supervisor/usb.c)
-ifndef INTERNAL_FLASH_FILESYSTEM
-INTERNAL_FLASH_FILESYSTEM = 0
-endif
+INTERNAL_FLASH_FILESYSTEM ?= 0
CFLAGS += -DINTERNAL_FLASH_FILESYSTEM=$(INTERNAL_FLASH_FILESYSTEM)
-ifndef QSPI_FLASH_FILESYSTEM
-QSPI_FLASH_FILESYSTEM = 0
-endif
+QSPI_FLASH_FILESYSTEM ?= 0
CFLAGS += -DQSPI_FLASH_FILESYSTEM=$(QSPI_FLASH_FILESYSTEM)
-ifndef SPI_FLASH_FILESYSTEM
-SPI_FLASH_FILESYSTEM = 0
-endif
+SPI_FLASH_FILESYSTEM ?= 0
CFLAGS += -DSPI_FLASH_FILESYSTEM=$(SPI_FLASH_FILESYSTEM)
ifeq ($(CIRCUITPY_BLEIO),1)
@@ -41,154 +33,180 @@ endif
# (Right now INTERNAL_FLASH_FILESYSTEM and (Q)SPI_FLASH_FILESYSTEM are mutually exclusive.
# But that might not be true in the future.)
ifdef EXTERNAL_FLASH_DEVICES
- CFLAGS += -DEXTERNAL_FLASH_DEVICES=$(EXTERNAL_FLASH_DEVICES) \
- -DEXTERNAL_FLASH_DEVICE_COUNT=$(EXTERNAL_FLASH_DEVICE_COUNT)
-
- SRC_SUPERVISOR += supervisor/shared/external_flash/external_flash.c
- ifeq ($(SPI_FLASH_FILESYSTEM),1)
- SRC_SUPERVISOR += supervisor/shared/external_flash/spi_flash.c
- else
- endif
- ifeq ($(QSPI_FLASH_FILESYSTEM),1)
- SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c
- endif
+ CFLAGS += -DEXTERNAL_FLASH_DEVICES=$(EXTERNAL_FLASH_DEVICES) \
+ -DEXTERNAL_FLASH_DEVICE_COUNT=$(EXTERNAL_FLASH_DEVICE_COUNT)
+
+ SRC_SUPERVISOR += supervisor/shared/external_flash/external_flash.c
+ ifeq ($(SPI_FLASH_FILESYSTEM),1)
+ SRC_SUPERVISOR += supervisor/shared/external_flash/spi_flash.c
+ endif
+ ifeq ($(QSPI_FLASH_FILESYSTEM),1)
+ SRC_SUPERVISOR += supervisor/qspi_flash.c supervisor/shared/external_flash/qspi_flash.c
+ endif
else
- ifeq ($(DISABLE_FILESYSTEM),1)
- SRC_SUPERVISOR += supervisor/stub/internal_flash.c
- else
- SRC_SUPERVISOR += supervisor/internal_flash.c
- endif
+ ifeq ($(DISABLE_FILESYSTEM),1)
+ SRC_SUPERVISOR += supervisor/stub/internal_flash.c
+ else
+ SRC_SUPERVISOR += supervisor/internal_flash.c
+ endif
endif
ifeq ($(USB),FALSE)
- ifeq ($(wildcard supervisor/serial.c),)
- SRC_SUPERVISOR += supervisor/stub/serial.c
- else
- SRC_SUPERVISOR += supervisor/serial.c
- endif
+ ifeq ($(wildcard supervisor/serial.c),)
+ SRC_SUPERVISOR += supervisor/stub/serial.c
+ else
+ SRC_SUPERVISOR += supervisor/serial.c
+ endif
else
- SRC_SUPERVISOR += \
- lib/tinyusb/src/common/tusb_fifo.c \
- lib/tinyusb/src/device/usbd.c \
- lib/tinyusb/src/device/usbd_control.c \
- lib/tinyusb/src/class/msc/msc_device.c \
- lib/tinyusb/src/class/cdc/cdc_device.c \
- lib/tinyusb/src/tusb.c \
- supervisor/shared/serial.c \
- supervisor/shared/workflow.c \
- supervisor/usb.c \
- supervisor/shared/usb/usb_desc.c \
- supervisor/shared/usb/usb.c \
- supervisor/shared/usb/usb_msc_flash.c \
- $(BUILD)/autogen_usb_descriptor.c
-
- ifeq ($(CIRCUITPY_USB_HID), 1)
- SRC_SUPERVISOR += \
- lib/tinyusb/src/class/hid/hid_device.c \
- shared-bindings/usb_hid/__init__.c \
- shared-bindings/usb_hid/Device.c \
- shared-module/usb_hid/__init__.c \
- shared-module/usb_hid/Device.c
- endif
-
- ifeq ($(CIRCUITPY_USB_MIDI), 1)
- SRC_SUPERVISOR += \
- lib/tinyusb/src/class/midi/midi_device.c \
- shared-bindings/usb_midi/__init__.c \
- shared-bindings/usb_midi/PortIn.c \
- shared-bindings/usb_midi/PortOut.c \
- shared-module/usb_midi/__init__.c \
- shared-module/usb_midi/PortIn.c \
- shared-module/usb_midi/PortOut.c
- endif
-
- ifeq ($(CIRCUITPY_USB_VENDOR), 1)
- SRC_SUPERVISOR += \
- lib/tinyusb/src/class/vendor/vendor_device.c
- endif
-
- CFLAGS += -DUSB_AVAILABLE
+ SRC_SUPERVISOR += \
+ lib/tinyusb/src/class/cdc/cdc_device.c \
+ lib/tinyusb/src/common/tusb_fifo.c \
+ lib/tinyusb/src/device/usbd.c \
+ lib/tinyusb/src/device/usbd_control.c \
+ lib/tinyusb/src/tusb.c \
+ supervisor/shared/serial.c \
+ supervisor/shared/workflow.c \
+ 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 += \
+ shared-bindings/usb_cdc/__init__.c \
+ shared-bindings/usb_cdc/Serial.c \
+ shared-module/usb_cdc/__init__.c \
+ shared-module/usb_cdc/Serial.c \
+
+ endif
+
+ ifeq ($(CIRCUITPY_USB_HID), 1)
+ SRC_SUPERVISOR += \
+ lib/tinyusb/src/class/hid/hid_device.c \
+ shared-bindings/usb_hid/__init__.c \
+ shared-bindings/usb_hid/Device.c \
+ shared-module/usb_hid/__init__.c \
+ shared-module/usb_hid/Device.c \
+
+ endif
+
+ ifeq ($(CIRCUITPY_USB_MIDI), 1)
+ SRC_SUPERVISOR += \
+ lib/tinyusb/src/class/midi/midi_device.c \
+ shared-bindings/usb_midi/__init__.c \
+ shared-bindings/usb_midi/PortIn.c \
+ shared-bindings/usb_midi/PortOut.c \
+ shared-module/usb_midi/__init__.c \
+ shared-module/usb_midi/PortIn.c \
+ shared-module/usb_midi/PortOut.c \
+
+ endif
+
+ ifeq ($(CIRCUITPY_USB_MSC), 1)
+ SRC_SUPERVISOR += \
+ lib/tinyusb/src/class/msc/msc_device.c \
+ supervisor/shared/usb/usb_msc_flash.c \
+
+ endif
+
+ ifeq ($(CIRCUITPY_USB_VENDOR), 1)
+ SRC_SUPERVISOR += \
+ lib/tinyusb/src/class/vendor/vendor_device.c \
+
+ endif
+
+ CFLAGS += -DUSB_AVAILABLE
endif
SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o))
ifeq ($(CIRCUITPY_DISPLAYIO), 1)
- SRC_SUPERVISOR += \
- supervisor/shared/display.c
+ SRC_SUPERVISOR += \
+ supervisor/shared/display.c
- ifeq ($(CIRCUITPY_TERMINALIO), 1)
- SUPERVISOR_O += $(BUILD)/autogen_display_resources.o
- endif
+ ifeq ($(CIRCUITPY_TERMINALIO), 1)
+ SUPERVISOR_O += $(BUILD)/autogen_display_resources.o
+ endif
endif
-ifndef USB_INTERFACE_NAME
-USB_INTERFACE_NAME = "CircuitPython"
+
+USB_INTERFACE_NAME ?= "CircuitPython"
+
+ifneq ($(USB_VID),)
+CFLAGS += -DUSB_VID=$(USB_VID)
+CFLAGS += -DSUB_PID=$(USB_PID)
+CFLAGS += -DUSB_MANUFACTURER=$(USB_MANUFACTURER)
+CFLAGS += -DUSB_PRODUCT=$(USB_PRODUCT)
endif
# In the following URL, don't include the https:// prefix.
# It gets added automatically.
-ifndef USB_WEBUSB_URL
-USB_WEBUSB_URL = "circuitpython.org"
+USB_WEBUSB_URL ?= "circuitpython.org"
+
+ifeq ($(CIRCUITPY_REPL_USB),1)
+USB_DEVICES += CDC
endif
-USB_DEVICES_COMPUTED := CDC,MSC
+ifeq ($(CIRCUITPY_USB_HID),1)
+USB_DEVICES += HID
+endif
ifeq ($(CIRCUITPY_USB_MIDI),1)
-USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),AUDIO
+USB_DEVICES += AUDIO
endif
-ifeq ($(CIRCUITPY_USB_HID),1)
-USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),HID
+ifeq ($(CIRCUITPY_USB_MSC),1)
+USB_DEVICES += MSC
endif
-ifeq ($(CIRCUITPY_USB_VENDOR),1)
-USB_DEVICES_COMPUTED := $(USB_DEVICES_COMPUTED),VENDOR
+ifeq ($(CIRCUITPY_USB_CDC),1)
+# Inform TinyUSB there are two CDC devices.
+CFLAGS += -DCFG_TUD_CDC=2
+USB_DEVICES += CDC2
endif
-USB_DEVICES ?= "$(USB_DEVICES_COMPUTED)"
-
-ifndef USB_HID_DEVICES
-USB_HID_DEVICES = "KEYBOARD,MOUSE,CONSUMER,GAMEPAD"
+ifeq ($(CIRCUITPY_USB_VENDOR),1)
+USB_DEVICES += VENDOR
endif
-ifndef USB_HIGHSPEED
-USB_HIGHSPEED = 0
+USB_HID_DEVICES =
+ifeq ($(CIRCUITPY_USB_HID_CONSUMER),1)
+USB_HID_DEVICES += CONSUMER
endif
-
-ifndef USB_CDC_EP_NUM_NOTIFICATION
-USB_CDC_EP_NUM_NOTIFICATION = 0
+ifeq ($(CIRCUITPY_USB_HID_DIGITIZER),1)
+USB_HID_DEVICES += DIGITIZER
endif
-
-ifndef USB_CDC_EP_NUM_DATA_OUT
-USB_CDC_EP_NUM_DATA_OUT = 0
+ifeq ($(CIRCUITPY_USB_HID_GAMEPAD),1)
+USB_HID_DEVICES += GAMEPAD
endif
-
-ifndef USB_CDC_EP_NUM_DATA_IN
-USB_CDC_EP_NUM_DATA_IN = 0
+ifeq ($(CIRCUITPY_USB_HID_KEYBOARD),1)
+USB_HID_DEVICES += KEYBOARD
endif
-
-ifndef USB_MSC_EP_NUM_OUT
-USB_MSC_EP_NUM_OUT = 0
+ifeq ($(CIRCUITPY_USB_HID_MOUSE),1)
+USB_HID_DEVICES += MOUSE
endif
-
-ifndef USB_MSC_EP_NUM_IN
-USB_MSC_EP_NUM_IN = 0
+ifeq ($(CIRCUITPY_USB_HID_SYS_CONTROL),1)
+USB_HID_DEVICES += SYS_CONTROL
endif
-
-ifndef USB_HID_EP_NUM_OUT
-USB_HID_EP_NUM_OUT = 0
+ifeq ($(CIRCUITPY_USB_HID_XAC_COMPATIBLE_GAMEPAD),1)
+USB_HID_DEVICES += XAC_COMPATIBLE_GAMEPAD
endif
-ifndef USB_HID_EP_NUM_IN
-USB_HID_EP_NUM_IN = 0
+# 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
-
-ifndef USB_MIDI_EP_NUM_OUT
-USB_MIDI_EP_NUM_OUT = 0
+USB_HID_DEVICES += MOUSE
endif
-ifndef USB_MIDI_EP_NUM_IN
-USB_MIDI_EP_NUM_IN = 0
-endif
+USB_HIGHSPEED ?= 0
-ifndef USB_NUM_EP
-USB_NUM_EP = 0
-endif
+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)\
@@ -197,8 +215,8 @@ USB_DESCRIPTOR_ARGS = \
--pid $(USB_PID)\
--serial_number_length $(USB_SERIAL_NUMBER_LENGTH)\
--interface_name $(USB_INTERFACE_NAME)\
- --devices $(USB_DEVICES)\
- --hid_devices $(USB_HID_DEVICES)\
+ --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)\