Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3986 background reset remove existing usb callback #4122

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ STATIC void stop_mp(void) {
#endif

background_callback_reset();
usb_background();

gc_deinit();
}
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

SUPEROPT_GC = 0
SUPEROPT_VM = 0
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0

SUPEROPT_GC = 0
SUPEROPT_VM = 0
3 changes: 1 addition & 2 deletions supervisor/shared/background_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
dhalbert marked this conversation as resolved.
Show resolved Hide resolved

#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
Expand All @@ -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;
dhalbert marked this conversation as resolved.
Show resolved Hide resolved
}
if (!callback_head) {
callback_head = cb;
Expand Down
7 changes: 6 additions & 1 deletion supervisor/shared/usb/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,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();
}

//--------------------------------------------------------------------+
Expand Down
3 changes: 3 additions & 0 deletions supervisor/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
// it may be necessary to call it directly.
void usb_background(void);

// Schedule usb background
void usb_background_schedule(void);
dhalbert marked this conversation as resolved.
Show resolved Hide resolved

// Ports must call this from their particular USB IRQ handler
void usb_irq_handler(void);

Expand Down