supervisor: factor out, Handle USB via background callback
This commit is contained in:
parent
36b4646516
commit
6160d11c5a
@ -85,7 +85,6 @@ void run_background_tasks(void) {
|
||||
network_module_background();
|
||||
#endif
|
||||
filesystem_background();
|
||||
usb_background();
|
||||
running_background_tasks = false;
|
||||
assert_heap_ok();
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "hpl/gclk/hpl_gclk_base.h"
|
||||
#include "hal_gpio.h"
|
||||
#include "lib/tinyusb/src/device/usbd.h"
|
||||
#include "supervisor/background_callback.h"
|
||||
#include "supervisor/usb.h"
|
||||
|
||||
void init_usb_hardware(void) {
|
||||
#ifdef SAMD21
|
||||
@ -61,24 +63,24 @@ void init_usb_hardware(void) {
|
||||
|
||||
#ifdef SAMD21
|
||||
void USB_Handler(void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SAM_D5X_E5X
|
||||
void USB_0_Handler (void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
||||
void USB_1_Handler (void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
||||
void USB_2_Handler (void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
||||
void USB_3_Handler (void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
#endif
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "py/mphal.h"
|
||||
#include "py/mpstate.h"
|
||||
#include "py/gc.h"
|
||||
#include "supervisor/usb.h"
|
||||
|
||||
#include "csr.h"
|
||||
#include "generated/soc.h"
|
||||
@ -49,7 +50,7 @@ void isr(void) {
|
||||
|
||||
#ifdef CFG_TUSB_MCU
|
||||
if (irqs & (1 << USB_INTERRUPT))
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
#endif
|
||||
if (irqs & (1 << TIMER0_INTERRUPT))
|
||||
SysTick_Handler();
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "fsl_clock.h"
|
||||
#include "tusb.h"
|
||||
#include "supervisor/usb.h"
|
||||
|
||||
void init_usb_hardware(void) {
|
||||
CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
|
||||
@ -56,5 +57,5 @@ void init_usb_hardware(void) {
|
||||
}
|
||||
|
||||
void USB_OTG1_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ void run_background_tasks(void) {
|
||||
}
|
||||
running_background_tasks = true;
|
||||
filesystem_background();
|
||||
usb_background();
|
||||
#if CIRCUITPY_AUDIOPWMIO
|
||||
audiopwmout_background();
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
#include "lib/mp-readline/readline.h"
|
||||
#include "lib/tinyusb/src/device/usbd.h"
|
||||
#include "supervisor/background_callback.h"
|
||||
|
||||
#ifdef SOFTDEVICE_PRESENT
|
||||
#include "nrf_sdm.h"
|
||||
@ -42,7 +43,9 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
|
||||
|
||||
void init_usb_hardware(void) {
|
||||
|
||||
// 2 is max priority (0, 1 are reserved for SD)
|
||||
// 2 is max priority (0, 1, and 4 are reserved for SD)
|
||||
// 5 is max priority that still allows calling SD functions such as
|
||||
// sd_softdevice_is_enabled
|
||||
NVIC_SetPriority(USBD_IRQn, 2);
|
||||
|
||||
// USB power may already be ready at this time -> no event generated
|
||||
@ -89,5 +92,5 @@ void init_usb_hardware(void) {
|
||||
}
|
||||
|
||||
void USBD_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
@ -130,5 +130,5 @@ void init_usb_hardware(void) {
|
||||
}
|
||||
|
||||
void OTG_FS_IRQHandler(void) {
|
||||
tud_int_handler(0);
|
||||
usb_irq_handler();
|
||||
}
|
||||
|
@ -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"
|
||||
@ -82,6 +83,16 @@ void usb_background(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static background_callback_t callback;
|
||||
static void usb_background_do(void* unused) {
|
||||
usb_background();
|
||||
}
|
||||
|
||||
void usb_irq_handler(void) {
|
||||
tud_int_handler(0);
|
||||
background_callback_add(&callback, usb_background_do, NULL);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// tinyusb callbacks
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -33,6 +33,9 @@
|
||||
// alive and responsive.
|
||||
void usb_background(void);
|
||||
|
||||
// Ports must call this from their particular USB IRQ handler
|
||||
void usb_irq_handler(void);
|
||||
|
||||
// Only inits the USB peripheral clocks and pins. The peripheral will be initialized by
|
||||
// TinyUSB.
|
||||
void init_usb_hardware(void);
|
||||
|
Loading…
Reference in New Issue
Block a user