Add CDC REPL access
This commit is contained in:
parent
45d1c9f02e
commit
90b1701b6c
@ -46,7 +46,7 @@ void run_background_tasks(void) {
|
|||||||
}
|
}
|
||||||
running_background_tasks = true;
|
running_background_tasks = true;
|
||||||
filesystem_background();
|
filesystem_background();
|
||||||
//usb_background();
|
usb_background();
|
||||||
|
|
||||||
#if CIRCUITPY_DISPLAYIO
|
#if CIRCUITPY_DISPLAYIO
|
||||||
displayio_refresh_displays();
|
displayio_refresh_displays();
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#define FLASH_SIZE (0x7D000)
|
#define FLASH_SIZE (0x7D000)
|
||||||
#define FLASH_PAGE_SIZE (0x4000)
|
#define FLASH_PAGE_SIZE (0x4000)
|
||||||
|
|
||||||
|
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
|
||||||
|
|
||||||
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
|
#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
|
||||||
#define AUTORESET_DELAY_MS 500
|
#define AUTORESET_DELAY_MS 500
|
||||||
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
|
#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
|
@ -34,14 +34,19 @@
|
|||||||
|
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
|
||||||
|
#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8
|
||||||
|
|
||||||
// Serial number as hex characters. This writes directly to the USB
|
// Serial number as hex characters. This writes directly to the USB
|
||||||
// descriptor.
|
// descriptor.
|
||||||
extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2];
|
extern uint16_t usb_serial_number[1 + COMMON_HAL_MCU_PROCESSOR_UID_LENGTH * 2];
|
||||||
|
|
||||||
void load_serial_number(void) {
|
void load_serial_number(void) {
|
||||||
// create serial number based on device unique id
|
// 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);
|
//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',
|
static const char nibble_to_hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
'A', 'B', 'C', 'D', 'E', 'F'};
|
'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
@ -60,14 +65,10 @@ bool usb_enabled(void) {
|
|||||||
|
|
||||||
void usb_init(void) {
|
void usb_init(void) {
|
||||||
init_usb_hardware();
|
init_usb_hardware();
|
||||||
//load_serial_number();
|
load_serial_number();
|
||||||
|
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
while(1) {
|
|
||||||
tud_task();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MICROPY_KBD_EXCEPTION
|
#if MICROPY_KBD_EXCEPTION
|
||||||
// Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received
|
// 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
|
// This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
|
||||||
|
@ -78,6 +78,7 @@ else
|
|||||||
shared-module/usb_midi/PortIn.c \
|
shared-module/usb_midi/PortIn.c \
|
||||||
shared-module/usb_midi/PortOut.c \
|
shared-module/usb_midi/PortOut.c \
|
||||||
$(BUILD)/autogen_usb_descriptor.c
|
$(BUILD)/autogen_usb_descriptor.c
|
||||||
|
|
||||||
CFLAGS += -DUSB_AVAILABLE
|
CFLAGS += -DUSB_AVAILABLE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -273,17 +273,17 @@ cdc_iad = standard.InterfaceAssociationDescriptor(
|
|||||||
descriptor_list = []
|
descriptor_list = []
|
||||||
descriptor_list.append(cdc_iad)
|
descriptor_list.append(cdc_iad)
|
||||||
descriptor_list.extend(cdc_interfaces)
|
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
|
# Only add the control interface because other audio interfaces are managed by it to ensure the
|
||||||
# correct ordering.
|
# correct ordering.
|
||||||
descriptor_list.append(audio_control_interface)
|
# descriptor_list.append(audio_control_interface)
|
||||||
# Put the CDC IAD just before the CDC interfaces.
|
# Put the CDC IAD just before the CDC interfaces.
|
||||||
# There appears to be a bug in the Windows composite USB driver that requests the
|
# 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
|
# 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
|
# 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
|
# the Windows 7 Adafruit_usbser.inf file thinks CDC is at Interface 0, so we'll leave it
|
||||||
# there for backwards compatibility.
|
# there for backwards compatibility.
|
||||||
descriptor_list.extend(hid_interfaces)
|
# descriptor_list.extend(hid_interfaces)
|
||||||
|
|
||||||
configuration = standard.ConfigurationDescriptor(
|
configuration = standard.ConfigurationDescriptor(
|
||||||
description="Composite configuration",
|
description="Composite configuration",
|
||||||
|
Loading…
Reference in New Issue
Block a user