Skip to content

Commit 5bb722b

Browse files
authored
Merge pull request #4122 from hathach/fix-3986
Fix 3986 background reset remove existing usb callback
2 parents 0a55cfb + 25d456a commit 5bb722b

File tree

6 files changed

+13
-3
lines changed

6 files changed

+13
-3
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();
187188

188189
gc_deinit();
189190
}

ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

1313
SUPEROPT_GC = 0
14+
SUPEROPT_VM = 0

ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
1111
CIRCUITPY_FULL_BUILD = 0
1212

1313
SUPEROPT_GC = 0
14+
SUPEROPT_VM = 0

supervisor/shared/background_callback.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "supervisor/shared/tick.h"
3434
#include "shared-bindings/microcontroller/__init__.h"
3535

36-
STATIC volatile background_callback_t *callback_head, *callback_tail;
36+
STATIC volatile background_callback_t * volatile callback_head, * volatile callback_tail;
3737

3838
#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
3939
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
@@ -50,7 +50,6 @@ void background_callback_add_core(background_callback_t *cb) {
5050
cb->prev = (background_callback_t*)callback_tail;
5151
if (callback_tail) {
5252
callback_tail->next = cb;
53-
cb->prev = (background_callback_t*)callback_tail;
5453
}
5554
if (!callback_head) {
5655
callback_head = cb;

supervisor/shared/usb/usb.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ static void usb_background_do(void* unused) {
111111
usb_background();
112112
}
113113

114+
void usb_background_schedule(void)
115+
{
116+
background_callback_add(&usb_callback, usb_background_do, NULL);
117+
}
118+
114119
void usb_irq_handler(void) {
115120
tud_int_handler(0);
116-
background_callback_add(&usb_callback, usb_background_do, NULL);
121+
usb_background_schedule();
117122
}
118123

119124
//--------------------------------------------------------------------+

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)