Skip to content

Commit 8d7b1f9

Browse files
committed
add usb_background_schedule()
unconditionally schedule usb background after background_callback_reset()
1 parent e699a59 commit 8d7b1f9

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ STATIC void stop_mp(void) {
184184
#endif
185185

186186
background_callback_reset();
187+
usb_background_schedule();
187188

188189
gc_deinit();
189190
}

supervisor/shared/background_callback.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ void background_callback_end_critical_section() {
105105
CALLBACK_CRITICAL_END;
106106
}
107107

108-
extern background_callback_t usb_callback;
109-
extern void usb_background_do(void* unused);
110-
111108
void background_callback_reset() {
112109
CALLBACK_CRITICAL_BEGIN;
113110
background_callback_t *cb = (background_callback_t*)callback_head;
@@ -120,8 +117,6 @@ void background_callback_reset() {
120117
callback_tail = NULL;
121118
in_background_callback = false;
122119
CALLBACK_CRITICAL_END;
123-
124-
background_callback_add(&usb_callback, usb_background_do, NULL);
125120
}
126121

127122
void background_callback_gc_collect(void) {

supervisor/shared/usb/usb.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,21 @@ void usb_background(void) {
9393
}
9494
}
9595

96-
/*static*/ background_callback_t usb_callback;
97-
/*static*/ void usb_background_do(void* unused) {
96+
static background_callback_t usb_callback;
97+
static void usb_background_do(void* unused) {
9898
usb_background();
9999
}
100100

101-
void usb_irq_handler(void) {
102-
tud_int_handler(0); \
101+
void usb_background_schedule(void)
102+
{
103103
background_callback_add(&usb_callback, usb_background_do, NULL);
104104
}
105105

106+
void usb_irq_handler(void) {
107+
tud_int_handler(0);
108+
usb_background_schedule();
109+
}
110+
106111
//--------------------------------------------------------------------+
107112
// tinyusb callbacks
108113
//--------------------------------------------------------------------+

supervisor/usb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
// it may be necessary to call it directly.
3636
void usb_background(void);
3737

38+
// Schedule usb background
39+
void usb_background_schedule(void);
40+
3841
// Ports must call this from their particular USB IRQ handler
3942
void usb_irq_handler(void);
4043

0 commit comments

Comments
 (0)