Merge pull request #4122 from hathach/fix-3986

Fix 3986 background reset remove existing usb callback
This commit is contained in:
Dan Halbert 2021-02-05 09:13:28 -05:00 committed by GitHub
commit 5bb722b927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 3 deletions

1
main.c
View File

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

View File

@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
SUPEROPT_GC = 0
SUPEROPT_VM = 0

View File

@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
SUPEROPT_GC = 0
SUPEROPT_VM = 0

View File

@ -33,7 +33,7 @@
#include "supervisor/shared/tick.h"
#include "shared-bindings/microcontroller/__init__.h"
STATIC volatile background_callback_t *callback_head, *callback_tail;
STATIC volatile background_callback_t * volatile callback_head, * volatile callback_tail;
#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
@ -50,7 +50,6 @@ void background_callback_add_core(background_callback_t *cb) {
cb->prev = (background_callback_t*)callback_tail;
if (callback_tail) {
callback_tail->next = cb;
cb->prev = (background_callback_t*)callback_tail;
}
if (!callback_head) {
callback_head = cb;

View File

@ -111,9 +111,14 @@ static void usb_background_do(void* unused) {
usb_background();
}
void usb_background_schedule(void)
{
background_callback_add(&usb_callback, usb_background_do, NULL);
}
void usb_irq_handler(void) {
tud_int_handler(0);
background_callback_add(&usb_callback, usb_background_do, NULL);
usb_background_schedule();
}
//--------------------------------------------------------------------+

View File

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