File tree Expand file tree Collapse file tree 9 files changed +30
-12
lines changed Expand file tree Collapse file tree 9 files changed +30
-12
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ void run_background_tasks(void) {
85
85
network_module_background ();
86
86
#endif
87
87
filesystem_background ();
88
- usb_background ();
89
88
running_background_tasks = false;
90
89
assert_heap_ok ();
91
90
Original file line number Diff line number Diff line change 29
29
#include "hpl/gclk/hpl_gclk_base.h"
30
30
#include "hal_gpio.h"
31
31
#include "lib/tinyusb/src/device/usbd.h"
32
+ #include "supervisor/background_callback.h"
33
+ #include "supervisor/usb.h"
32
34
33
35
void init_usb_hardware (void ) {
34
36
#ifdef SAMD21
@@ -61,24 +63,24 @@ void init_usb_hardware(void) {
61
63
62
64
#ifdef SAMD21
63
65
void USB_Handler (void ) {
64
- tud_int_handler ( 0 );
66
+ usb_irq_handler ( );
65
67
}
66
68
#endif
67
69
68
70
#ifdef SAM_D5X_E5X
69
71
void USB_0_Handler (void ) {
70
- tud_int_handler ( 0 );
72
+ usb_irq_handler ( );
71
73
}
72
74
73
75
void USB_1_Handler (void ) {
74
- tud_int_handler ( 0 );
76
+ usb_irq_handler ( );
75
77
}
76
78
77
79
void USB_2_Handler (void ) {
78
- tud_int_handler ( 0 );
80
+ usb_irq_handler ( );
79
81
}
80
82
81
83
void USB_3_Handler (void ) {
82
- tud_int_handler ( 0 );
84
+ usb_irq_handler ( );
83
85
}
84
86
#endif
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ void isr(void) {
49
49
50
50
#ifdef CFG_TUSB_MCU
51
51
if (irqs & (1 << USB_INTERRUPT ))
52
- tud_int_handler ( 0 );
52
+ usb_irq_handler ( );
53
53
#endif
54
54
if (irqs & (1 << TIMER0_INTERRUPT ))
55
55
SysTick_Handler ();
Original file line number Diff line number Diff line change 27
27
28
28
#include "fsl_clock.h"
29
29
#include "tusb.h"
30
+ #include "supervisor/usb.h"
30
31
31
32
void init_usb_hardware (void ) {
32
33
CLOCK_EnableUsbhs0PhyPllClock (kCLOCK_Usbphy480M , 480000000U );
@@ -56,5 +57,5 @@ void init_usb_hardware(void) {
56
57
}
57
58
58
59
void USB_OTG1_IRQHandler (void ) {
59
- tud_int_handler ( 0 );
60
+ usb_irq_handler ( );
60
61
}
Original file line number Diff line number Diff line change @@ -59,7 +59,6 @@ void run_background_tasks(void) {
59
59
}
60
60
running_background_tasks = true;
61
61
filesystem_background ();
62
- usb_background ();
63
62
#if CIRCUITPY_AUDIOPWMIO
64
63
audiopwmout_background ();
65
64
#endif
Original file line number Diff line number Diff line change 30
30
#include "lib/utils/interrupt_char.h"
31
31
#include "lib/mp-readline/readline.h"
32
32
#include "lib/tinyusb/src/device/usbd.h"
33
+ #include "supervisor/background_callback.h"
33
34
34
35
#ifdef SOFTDEVICE_PRESENT
35
36
#include "nrf_sdm.h"
@@ -42,7 +43,9 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
42
43
43
44
void init_usb_hardware (void ) {
44
45
45
- // 2 is max priority (0, 1 are reserved for SD)
46
+ // 2 is max priority (0, 1, and 4 are reserved for SD)
47
+ // 5 is max priority that still allows calling SD functions such as
48
+ // sd_softdevice_is_enabled
46
49
NVIC_SetPriority (USBD_IRQn , 2 );
47
50
48
51
// USB power may already be ready at this time -> no event generated
@@ -89,5 +92,5 @@ void init_usb_hardware(void) {
89
92
}
90
93
91
94
void USBD_IRQHandler (void ) {
92
- tud_int_handler ( 0 );
95
+ usb_irq_handler ( );
93
96
}
Original file line number Diff line number Diff line change @@ -130,5 +130,5 @@ void init_usb_hardware(void) {
130
130
}
131
131
132
132
void OTG_FS_IRQHandler (void ) {
133
- tud_int_handler ( 0 );
133
+ usb_irq_handler ( );
134
134
}
Original file line number Diff line number Diff line change 27
27
#include "py/objstr.h"
28
28
#include "shared-bindings/microcontroller/Processor.h"
29
29
#include "shared-module/usb_midi/__init__.h"
30
+ #include "supervisor/background_callback.h"
30
31
#include "supervisor/port.h"
31
32
#include "supervisor/usb.h"
32
33
#include "lib/utils/interrupt_char.h"
@@ -82,6 +83,16 @@ void usb_background(void) {
82
83
}
83
84
}
84
85
86
+ static background_callback_t callback ;
87
+ static void usb_background_do (void * unused ) {
88
+ usb_background ();
89
+ }
90
+
91
+ void usb_irq_handler (void ) {
92
+ tud_int_handler (0 );
93
+ background_callback_add (& callback , usb_background_do , NULL );
94
+ }
95
+
85
96
//--------------------------------------------------------------------+
86
97
// tinyusb callbacks
87
98
//--------------------------------------------------------------------+
Original file line number Diff line number Diff line change 33
33
// alive and responsive.
34
34
void usb_background (void );
35
35
36
+ // Ports must call this from their particular USB IRQ handler
37
+ void usb_irq_handler (void );
38
+
36
39
// Only inits the USB peripheral clocks and pins. The peripheral will be initialized by
37
40
// TinyUSB.
38
41
void init_usb_hardware (void );
You can’t perform that action at this time.
0 commit comments