Skip to content

Commit e699a59

Browse files
committed
hack to fix 3986
just a proof to show that issue analysis is correct
1 parent c1c1a5d commit e699a59

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

supervisor/shared/background_callback.c

Lines changed: 6 additions & 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;
@@ -106,6 +105,9 @@ void background_callback_end_critical_section() {
106105
CALLBACK_CRITICAL_END;
107106
}
108107

108+
extern background_callback_t usb_callback;
109+
extern void usb_background_do(void* unused);
110+
109111
void background_callback_reset() {
110112
CALLBACK_CRITICAL_BEGIN;
111113
background_callback_t *cb = (background_callback_t*)callback_head;
@@ -118,6 +120,8 @@ void background_callback_reset() {
118120
callback_tail = NULL;
119121
in_background_callback = false;
120122
CALLBACK_CRITICAL_END;
123+
124+
background_callback_add(&usb_callback, usb_background_do, NULL);
121125
}
122126

123127
void background_callback_gc_collect(void) {

supervisor/shared/usb/usb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ 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

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

0 commit comments

Comments
 (0)