misc/tinyusb_debug: Define IRQ handler names in board config.

This commit is contained in:
iabdalkader 2023-03-07 19:22:14 +01:00
parent 58ee7322fa
commit 6e40c8ee6b
5 changed files with 27 additions and 7 deletions

@ -1 +1 @@
Subproject commit d8e38d0d151bd0786f250cd19c8118dff9ea51a3
Subproject commit c8ea7e65af10ddbe44d416fc2714057107906105

View File

@ -85,6 +85,7 @@ extern unsigned char *OMV_UNIQUE_ID_ADDR; // Unique address.
// USB IRQn.
#define OMV_USB_IRQN (USBCTRL_IRQ_IRQn)
#define OMV_USB1_IRQ_HANDLER (USBD_IRQHandler)
// Jump to bootloader function.
#ifndef LINKER_SCRIPT

View File

@ -76,6 +76,7 @@
// USB IRQn.
#define OMV_USB_IRQN (USBD_IRQn)
#define OMV_USB1_IRQ_HANDLER (USBD_IRQHandler)
// Linker script constants (see the linker script template port/x.ld.S).
#define OMV_FB_MEMORY SRAM // Framebuffer, fb_alloc

View File

@ -83,6 +83,7 @@ extern unsigned char *OMV_UNIQUE_ID_ADDR; // Unique ID address.
// USB IRQn.
#define OMV_USB_IRQN (USBCTRL_IRQ_IRQn)
#define OMV_USB1_IRQ_HANDLER (USBD_IRQHandler)
// Jump to bootloader function.
#ifndef LINKER_SCRIPT

View File

@ -33,8 +33,9 @@ typedef struct __attribute__((packed)) {
uint32_t xfer_length;
} usbdbg_cmd_t;
STATIC uint8_t debug_ringbuf_array[512];
static volatile uint8_t tinyusb_debug_mode = false;
static uint8_t debug_ringbuf_array[512];
static volatile bool tinyusb_debug_scheduled = false;
static volatile bool tinyusb_debug_mode = false;
ringbuf_t debug_ringbuf = { debug_ringbuf_array, sizeof(debug_ringbuf_array) };
uint32_t usb_cdc_buf_len()
@ -96,6 +97,7 @@ static void tinyusb_debug_task(void)
//This shouldn't happen
__fatal_error();
usbdbg_control(NULL, USBDBG_NONE, 0);
tinyusb_debug_scheduled = false;
return;
}
usbdbg_cmd_t *cmd = (usbdbg_cmd_t *) dbg_buf;
@ -127,16 +129,31 @@ static void tinyusb_debug_task(void)
}
}
}
tinyusb_debug_scheduled = false;
}
// For the nRF port, this replaces the default weak USB IRQ handler.
// And for the RP2 port, this handler is installed in main.c
void USBD_IRQHandler(void)
// For the mimxrt, and nrf ports this replaces the weak USB IRQ handlers.
// For the RP2 port, this handler is installed in main.c
void OMV_USB1_IRQ_HANDLER(void)
{
dcd_int_handler(0);
// If there are any event to process, schedule a call to cdc loop.
if (tinyusb_debug_enabled()) { // if (cdc_tx_any() || tud_task_event_ready())
if (tinyusb_debug_enabled() && tinyusb_debug_scheduled == false) { // if (cdc_tx_any() || tud_task_event_ready())
tinyusb_debug_scheduled = true;
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
}
}
#if defined(OMV_USB2_IRQ_HANDLER)
void OMV_USB2_IRQ_HANDLER(void)
{
dcd_int_handler(1);
// If there are any event to process, schedule a call to cdc loop.
if (tinyusb_debug_enabled() && tinyusb_debug_scheduled == false) { // if (cdc_tx_any() || tud_task_event_ready())
tinyusb_debug_scheduled = true;
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
}
}
#endif
#endif //OMV_TINYUSB_DEBUG