Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
Hosted Weblate 2021-04-24 16:31:32 +02:00
commit 929485e7ce
15 changed files with 32 additions and 10 deletions

4
main.c
View File

@ -60,6 +60,7 @@
#include "supervisor/shared/translate.h"
#include "supervisor/shared/workflow.h"
#include "supervisor/usb.h"
#include "supervisor/workflow.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h"
@ -188,7 +189,10 @@ STATIC void stop_mp(void) {
#endif
background_callback_reset();
#if CIRCUITPY_USB
usb_background();
#endif
gc_deinit();
}

View File

@ -201,7 +201,7 @@ SRC_C += \
peripherals/rmt.c \
supervisor/shared/memory.c
ifneq ($(USB),FALSE)
ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/espressif/esp32s2/dcd_esp32s2.c
endif

View File

@ -136,7 +136,7 @@ SRC_C += \
lib/utils/sys_stdio_mphal.c \
supervisor/shared/memory.c
ifneq ($(USB),FALSE)
ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/valentyusb/eptri/dcd_eptri.c
endif

View File

@ -310,7 +310,7 @@ mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t n
uint32_t src = lba2addr(block);
memcpy(dest, (uint8_t *)src, FILESYSTEM_BLOCK_SIZE * num_blocks);
#if USB_AVAILABLE
#if CIRCUITPY_USB
usb_background();
#endif
@ -347,7 +347,7 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
src += count * FILESYSTEM_BLOCK_SIZE;
num_blocks -= count;
#if USB_AVAILABLE
#if CIRCUITPY_USB
usb_background();
#endif
}

View File

@ -177,6 +177,7 @@ SRC_C += \
sd_mutex.c \
supervisor/shared/memory.c
ifneq ($(CIRCUITPY_USB),0)
# USB source files for nrf52840
ifeq ($(MCU_SUB_VARIANT),nrf52840)
SRC_C += \
@ -187,6 +188,7 @@ ifeq ($(MCU_SUB_VARIANT),nrf52833)
SRC_C += \
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c
endif
endif # CIRCUITPY_USB
ifeq ($(CIRCUITPY_NETWORK),1)
CFLAGS += -DMICROPY_PY_NETWORK=1

View File

@ -98,6 +98,7 @@ void SD_EVT_IRQHandler(void) {
uint32_t evt_id;
while (sd_evt_get(&evt_id) != NRF_ERROR_NOT_FOUND) {
switch (evt_id) {
#if CIRCUITPY_USB
// usb power event
case NRF_EVT_POWER_USB_DETECTED:
case NRF_EVT_POWER_USB_POWER_READY:
@ -109,6 +110,7 @@ void SD_EVT_IRQHandler(void) {
tusb_hal_nrf_power_event(usbevt);
}
break;
#endif
// Set flag indicating that a flash operation has finished.
case NRF_EVT_FLASH_OPERATION_SUCCESS:

View File

@ -351,8 +351,11 @@ void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enable
} else {
err_code = sd_softdevice_disable();
}
#if CIRCUITPY_USB
// Re-init USB hardware
init_usb_hardware();
#endif
check_nrf_error(err_code);

View File

@ -238,7 +238,7 @@ SRC_C += \
lib/utils/sys_stdio_mphal.c \
supervisor/shared/memory.c
ifneq ($(USB),FALSE)
ifneq ($(CIRCUITPY_USB),0)
SRC_C += lib/tinyusb/src/portable/st/synopsys/dcd_synopsys.c
endif

View File

@ -334,6 +334,9 @@ CFLAGS += -DCIRCUITPY_TOUCHIO=$(CIRCUITPY_TOUCHIO)
CIRCUITPY_UHEAP ?= 0
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.

View File

@ -59,7 +59,11 @@ STATIC supervisor_run_reason_t _run_reason;
//| """Returns the USB enumeration status (read-only)."""
//|
STATIC mp_obj_t supervisor_runtime_get_usb_connected(mp_obj_t self) {
#if CIRCUITPY_USB
return mp_obj_new_bool(tud_ready());
#else
return mp_const_false;
#endif
}
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_usb_connected_obj, supervisor_runtime_get_usb_connected);

View File

@ -160,7 +160,9 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa
}
void common_hal_storage_erase_filesystem(void) {
#if CIRCUITPY_USB
usb_disconnect();
#endif
mp_hal_delay_ms(1000);
filesystem_init(false, true); // Force a re-format.
common_hal_mcu_reset();

View File

@ -26,7 +26,5 @@
#pragma once
extern void supervisor_workflow_reset(void);
extern bool supervisor_workflow_connecting(void);
extern bool supervisor_workflow_active(void);

View File

@ -25,6 +25,7 @@
*/
#include "supervisor/serial.h"
#include "supervisor/workflow.h"
void serial_early_init(void) {
@ -49,3 +50,6 @@ bool serial_bytes_available(void) {
void serial_write(const char *text) {
(void)text;
}
void supervisor_workflow_reset(void) {
}

View File

@ -59,7 +59,7 @@ $(BUILD)/supervisor/shared/external_flash/external_flash.o: $(HEADER_BUILD)/devi
endif
ifeq ($(USB),FALSE)
ifeq ($(CIRCUITPY_USB),0)
ifeq ($(wildcard supervisor/serial.c),)
SRC_SUPERVISOR += supervisor/stub/serial.c
else
@ -122,8 +122,6 @@ else
lib/tinyusb/src/class/vendor/vendor_device.c \
endif
CFLAGS += -DUSB_AVAILABLE
endif
SUPERVISOR_O = $(addprefix $(BUILD)/, $(SRC_SUPERVISOR:.c=.o))

View File

@ -26,5 +26,7 @@
#pragma once
void supervisor_workflow_reset(void);
// True when the user could be actively iterating on their code.
bool workflow_active(void);