summaryrefslogtreecommitdiff
path: root/supervisor/shared/usb
diff options
context:
space:
mode:
authorhierophect <hierophect@gmail.com>2020-07-22 13:59:39 -0400
committerGitHub <noreply@github.com>2020-07-22 13:59:39 -0400
commite232ec10ceb9c78df27cb4b5cee79079efd85d84 (patch)
tree132c5bfbc1db02d29a82021be595eec1a1122ae8 /supervisor/shared/usb
parent138189bad130569ac9a9b3051543b804db54ec6f (diff)
parent05a10f7905bfb77f3d5dff2525c9d10375801329 (diff)
Merge branch 'main' into stm32-timer-allocator
Diffstat (limited to 'supervisor/shared/usb')
-rw-r--r--supervisor/shared/usb/usb.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index edf810118..36b5ec05d 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -27,6 +27,7 @@
#include "py/objstr.h"
#include "shared-bindings/microcontroller/Processor.h"
#include "shared-module/usb_midi/__init__.h"
+#include "supervisor/background_callback.h"
#include "supervisor/port.h"
#include "supervisor/usb.h"
#include "lib/utils/interrupt_char.h"
@@ -63,8 +64,8 @@ void usb_init(void) {
tusb_init();
#if MICROPY_KBD_EXCEPTION
- // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received
- // This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
+ // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received
+ // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
tud_cdc_set_wanted_char(CHAR_CTRL_C);
#endif
@@ -82,6 +83,16 @@ void usb_background(void) {
}
}
+static background_callback_t usb_callback;
+static void usb_background_do(void* unused) {
+ usb_background();
+}
+
+void usb_irq_handler(void) {
+ tud_int_handler(0);
+ background_callback_add(&usb_callback, usb_background_do, NULL);
+}
+
//--------------------------------------------------------------------+
// tinyusb callbacks
//--------------------------------------------------------------------+