Add CDC REPL access

This commit is contained in:
Hierophect 2019-07-26 14:06:27 -04:00
parent 45d1c9f02e
commit 90b1701b6c
5 changed files with 14 additions and 10 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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",