Merge pull request #4122 from hathach/fix-3986
Fix 3986 background reset remove existing usb callback
This commit is contained in:
commit
5bb722b927
1
main.c
1
main.c
|
@ -184,6 +184,7 @@ STATIC void stop_mp(void) {
|
|||
#endif
|
||||
|
||||
background_callback_reset();
|
||||
usb_background();
|
||||
|
||||
gc_deinit();
|
||||
}
|
||||
|
|
|
@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
|
|||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
SUPEROPT_GC = 0
|
||||
SUPEROPT_VM = 0
|
||||
|
|
|
@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
|
|||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
SUPEROPT_GC = 0
|
||||
SUPEROPT_VM = 0
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue