add usb_background_schedule()

unconditionally schedule usb background after
background_callback_reset()
This commit is contained in:
hathach 2021-02-04 16:00:14 +07:00
parent e699a59890
commit 8d7b1f9e8c
4 changed files with 13 additions and 9 deletions

1
main.c
View File

@ -184,6 +184,7 @@ STATIC void stop_mp(void) {
#endif #endif
background_callback_reset(); background_callback_reset();
usb_background_schedule();
gc_deinit(); gc_deinit();
} }

View File

@ -105,9 +105,6 @@ void background_callback_end_critical_section() {
CALLBACK_CRITICAL_END; CALLBACK_CRITICAL_END;
} }
extern background_callback_t usb_callback;
extern void usb_background_do(void* unused);
void background_callback_reset() { void background_callback_reset() {
CALLBACK_CRITICAL_BEGIN; CALLBACK_CRITICAL_BEGIN;
background_callback_t *cb = (background_callback_t*)callback_head; background_callback_t *cb = (background_callback_t*)callback_head;
@ -120,8 +117,6 @@ void background_callback_reset() {
callback_tail = NULL; callback_tail = NULL;
in_background_callback = false; in_background_callback = false;
CALLBACK_CRITICAL_END; CALLBACK_CRITICAL_END;
background_callback_add(&usb_callback, usb_background_do, NULL);
} }
void background_callback_gc_collect(void) { void background_callback_gc_collect(void) {

View File

@ -93,16 +93,21 @@ void usb_background(void) {
} }
} }
/*static*/ background_callback_t usb_callback; static background_callback_t usb_callback;
/*static*/ void usb_background_do(void* unused) { static void usb_background_do(void* unused) {
usb_background(); usb_background();
} }
void usb_irq_handler(void) { void usb_background_schedule(void)
tud_int_handler(0); \ {
background_callback_add(&usb_callback, usb_background_do, NULL); background_callback_add(&usb_callback, usb_background_do, NULL);
} }
void usb_irq_handler(void) {
tud_int_handler(0);
usb_background_schedule();
}
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// tinyusb callbacks // tinyusb callbacks
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -35,6 +35,9 @@
// it may be necessary to call it directly. // it may be necessary to call it directly.
void usb_background(void); void usb_background(void);
// Schedule usb background
void usb_background_schedule(void);
// Ports must call this from their particular USB IRQ handler // Ports must call this from their particular USB IRQ handler
void usb_irq_handler(void); void usb_irq_handler(void);