summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHierophect <hierophect@gmail.com>2019-07-26 14:06:27 -0400
committerHierophect <hierophect@gmail.com>2019-07-26 14:06:27 -0400
commit90b1701b6cf5bfdd44e02bff6c6fd7c9061111c0 (patch)
treef42aacea15e1e9c5bbc489effce641bc22fa8655
parent45d1c9f02edddae2fd06ef755ca161595f3d026d (diff)
Add CDC REPL access
-rw-r--r--ports/stm32f4/background.c2
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h2
-rw-r--r--supervisor/shared/usb/usb.c13
-rw-r--r--supervisor/supervisor.mk1
-rw-r--r--tools/gen_usb_descriptor.py6
5 files changed, 14 insertions, 10 deletions
diff --git a/ports/stm32f4/background.c b/ports/stm32f4/background.c
index e9872b045..9c4f3ab27 100644
--- a/ports/stm32f4/background.c
+++ b/ports/stm32f4/background.c
@@ -46,7 +46,7 @@ void run_background_tasks(void) {
}
running_background_tasks = true;
filesystem_background();
- //usb_background();
+ usb_background();
#if CIRCUITPY_DISPLAYIO
displayio_refresh_displays();
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
index 675443282..1b1410aea 100644
--- a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
+++ b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
@@ -33,6 +33,8 @@
#define FLASH_SIZE (0x7D000)
#define FLASH_PAGE_SIZE (0x4000)
+#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
+
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
#define AUTORESET_DELAY_MS 500
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) \ No newline at end of file
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index bccdca622..cfb39d4bb 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -34,14 +34,19 @@
#include "tusb.h"
+#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8
+
// 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] = {1,2,3,4};
+ uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
//common_hal_mcu_processor_get_uid(raw_id);
+ for (int i=0; i<2; i++) {
+ ((uint32_t*) raw_id)[i] = 0;
+ }
static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'};
@@ -60,14 +65,10 @@ bool usb_enabled(void) {
void usb_init(void) {
init_usb_hardware();
- //load_serial_number();
+ load_serial_number();
tusb_init();
- while(1) {
- tud_task();
- }
-
#if MICROPY_KBD_EXCEPTION
// Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received
// This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk
index 2d50e7a8b..42a55243e 100644
--- a/supervisor/supervisor.mk
+++ b/supervisor/supervisor.mk
@@ -78,6 +78,7 @@ else
shared-module/usb_midi/PortIn.c \
shared-module/usb_midi/PortOut.c \
$(BUILD)/autogen_usb_descriptor.c
+
CFLAGS += -DUSB_AVAILABLE
endif
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index 10bbf5066..db17c9766 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -273,17 +273,17 @@ cdc_iad = standard.InterfaceAssociationDescriptor(
descriptor_list = []
descriptor_list.append(cdc_iad)
descriptor_list.extend(cdc_interfaces)
-descriptor_list.extend(msc_interfaces)
+# descriptor_list.extend(msc_interfaces)
# Only add the control interface because other audio interfaces are managed by it to ensure the
# correct ordering.
-descriptor_list.append(audio_control_interface)
+# descriptor_list.append(audio_control_interface)
# 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.extend(hid_interfaces)
+# descriptor_list.extend(hid_interfaces)
configuration = standard.ConfigurationDescriptor(
description="Composite configuration",