Skip to content

hack to fix 3986 #1

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

Closed
wants to merge 2 commits into from
Closed
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_schedule();

gc_deinit();
}
Expand Down
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;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean the pointer is volatile rather than the data it is pointed to. We actually can have it as

STATIC background_callback_t * volatile callback_head, * volatile callback_tail;

But I will leave it as both volatile just in case.


#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;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function seem to be redundant

}
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);

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

Expand Down