hack to fix 3986

just a proof to show that issue analysis is correct
This commit is contained in:
hathach 2021-02-03 11:01:33 +07:00
parent c1c1a5d036
commit e699a59890
2 changed files with 9 additions and 5 deletions

View File

@ -33,7 +33,7 @@
#include "supervisor/shared/tick.h" #include "supervisor/shared/tick.h"
#include "shared-bindings/microcontroller/__init__.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_BEGIN (common_hal_mcu_disable_interrupts())
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_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; cb->prev = (background_callback_t*)callback_tail;
if (callback_tail) { if (callback_tail) {
callback_tail->next = cb; callback_tail->next = cb;
cb->prev = (background_callback_t*)callback_tail;
} }
if (!callback_head) { if (!callback_head) {
callback_head = cb; callback_head = cb;
@ -106,6 +105,9 @@ 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;
@ -118,6 +120,8 @@ 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,13 +93,13 @@ 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_irq_handler(void) {
tud_int_handler(0); tud_int_handler(0); \
background_callback_add(&usb_callback, usb_background_do, NULL); background_callback_add(&usb_callback, usb_background_do, NULL);
} }