8000 port/samd: Switch TinyUSB to schedule task. · micropython/micropython@316b156 · GitHub
[go: up one dir, main page]

Skip to content

Commit 316b156

Browse files
committed
port/samd: Switch TinyUSB to schedule task.
Previously the TinyUSB task was run in the ISR immediately after the interrupt handler. This approach gives very similar performance (no change in CDC throughput tests) but reduces the amount of time spent in the ISR, and allows TinyUSB callbacks to run in thread mode. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 1dfb8c7 commit 316b156

File tree

4 files changed

+7
-35
lines changed

4 files changed

+7
-35
lines changed

ports/samd/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ LIBSTDCPP_FILE_NAME = "$(shell $(CXX) $(CXXFLAGS) -print-file-name=libstdc++.a)"
9393
LDFLAGS += -L"$(shell dirname $(LIBSTDCPP_FILE_NAME))"
9494
endif
9595

96+
LDFLAGS += --wrap=dcd_event_handler
97+
9698
MPY_CROSS_FLAGS += -march=$(MPY_CROSS_MCU_ARCH)
9799

98100
SRC_C += \
@@ -131,6 +133,7 @@ SHARED_SRC_C += \
131133
shared/runtime/sys_stdio_mphal.c \
132134
shared/timeutils/timeutils.c \
133135
shared/tinyusb/mp_cdc_common.c \
136+
shared/tinyusb/mp_usbd.c
134137

135138
ASF4_SRC_C += $(addprefix lib/asf4/$(MCU_SERIES_LOWER)/,\
136139
hal/src/hal_atomic.c \

ports/samd/samd_isr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ const ISR isr_vector[] __attribute__((section(".isr_vector"))) = {
310310
&Sercom7_Handler, // 77 Serial Communication Interface 7 (SERCOM7): SERCOM7_3 - 6
311311
0, // 78 Control Area Network 0 (CAN0)
312312
0, // 79 Control Area Network 1 (CAN1)
313-
&USB_0_Handler_wrapper, // 80 Universal Serial Bus (USB): USB_EORSM_DNRS, ...
314-
&USB_1_Handler_wrapper, // 81 Universal Serial Bus (USB): USB_SOF_HSOF
315-
&USB_2_Handler_wrapper, // 82 Universal Serial Bus (USB): USB_TRCPT0_0 - _7
316-
&USB_3_Handler_wrapper, // 83 Universal Serial Bus (USB): USB_TRCPT1_0 - _7
313+
&USB_Handler_wrapper, // 80 Universal Serial Bus (USB): USB_EORSM_DNRS, ...
314+
&USB_Handler_wrapper, // 81 Universal Serial Bus (USB): USB_SOF_HSOF
315+
&USB_Handler_wrapper, // 82 Universal Serial Bus (USB): USB_TRCPT0_0 - _7
316+
&USB_Handler_wrapper, // 83 Universal Serial Bus (USB): USB_TRCPT1_0 - _7
317317
0, // 84 Ethernet MAC (GMAC)
318318
0, // 85 Timer Counter Control 0 (TCC0): TCC0_CNT_A ...
319319
0, // 86 Timer Counter Control 0 (TCC0): TCC0_MC_0

ports/samd/samd_soc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ void samd_init(void);
3636
void samd_main(void);
3737

3838
void USB_Handler_wrapper(void);
39-
void USB_0_Handler_wrapper(void);
40-
void USB_1_Handler_wrapper(void);
41-
void USB_2_Handler_wrapper(void);
42-
void USB_3_Handler_wrapper(void);
4339

4440
void sercom_enable(Sercom *spi, int state);
4541
void sercom_register_irq(int sercom_id, void (*sercom_irq_handler));

ports/samd/tusb_port.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -117,33 +117,6 @@ const uint16_t *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
117117
return desc_str;
118118
}
119119

120-
#if defined(MCU_SAMD21)
121-
122120
void USB_Handler_wrapper(void) {
123121
tud_int_handler(0);
124-
tud_task();
125-
}
126-
127-
#elif defined(MCU_SAMD51)
128-
129-
void USB_0_Handler_wrapper(void) {
130-
tud_int_handler(0);
131-
tud_task();
132-
}
133-
134-
void USB_1_Handler_wrapper(void) {
135-
tud_int_handler(0);
136-
tud_task();
137122
}
138-
139-
void USB_2_Handler_wrapper(void) {
140-
tud_int_handler(0);
141-
tud_task();
142-
}
143-
144-
void USB_3_Handler_wrapper(void) {
145-
tud_int_handler(0);
146-
tud_task();
147-
}
148-
149-
#endif

0 commit comments

Comments
 (0)
0