mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
misc: Fix TinyUSB polling.
This commit is contained in:
parent
9dd6e47e06
commit
ba754186f7
@ -82,11 +82,15 @@ void tinyusb_debug_tx_strn(const char *str, mp_uint_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void tinyusb_debug_task(void) {
|
static void tinyusb_debug_task(void) {
|
||||||
tud_task();
|
tud_task_ext(0, false);
|
||||||
|
|
||||||
|
if (!tinyusb_debug_enabled() || !tud_cdc_connected() || tud_cdc_available() < 6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t dbg_buf[DEBUG_MAX_PACKET];
|
uint8_t dbg_buf[DEBUG_MAX_PACKET];
|
||||||
if (tud_cdc_connected() && tud_cdc_available() >= 6) {
|
|
||||||
uint32_t count = tud_cdc_read(dbg_buf, 6);
|
uint32_t count = tud_cdc_read(dbg_buf, 6);
|
||||||
|
|
||||||
if (count < 6 || dbg_buf[0] != 0x30) {
|
if (count < 6 || dbg_buf[0] != 0x30) {
|
||||||
// Maybe we should try to recover from this state
|
// Maybe we should try to recover from this state
|
||||||
// but for now, call __fatal_error which doesn't
|
// but for now, call __fatal_error which doesn't
|
||||||
@ -94,6 +98,7 @@ static void tinyusb_debug_task(void) {
|
|||||||
__fatal_error();
|
__fatal_error();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
usbdbg_cmd_t *cmd = (usbdbg_cmd_t *) dbg_buf;
|
usbdbg_cmd_t *cmd = (usbdbg_cmd_t *) dbg_buf;
|
||||||
uint8_t request = cmd->request;
|
uint8_t request = cmd->request;
|
||||||
uint32_t xfer_length = cmd->xfer_length;
|
uint32_t xfer_length = cmd->xfer_length;
|
||||||
@ -102,7 +107,7 @@ static void tinyusb_debug_task(void) {
|
|||||||
while (xfer_length) {
|
while (xfer_length) {
|
||||||
// && tud_cdc_connected())
|
// && tud_cdc_connected())
|
||||||
if (tud_task_event_ready()) {
|
if (tud_task_event_ready()) {
|
||||||
tud_task();
|
tud_task_ext(0, false);
|
||||||
}
|
}
|
||||||
if (request & 0x80) {
|
if (request & 0x80) {
|
||||||
// Device-to-host data phase
|
// Device-to-host data phase
|
||||||
@ -122,14 +127,13 @@ static void tinyusb_debug_task(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// For the mimxrt, and nrf ports this replaces the weak USB IRQ handlers.
|
// For the mimxrt, and nrf ports this replaces the weak USB IRQ handlers.
|
||||||
// For the RP2 port, this handler is installed in main.c
|
// For the RP2 port, this handler is installed in main.c
|
||||||
void OMV_USB1_IRQ_HANDLER(void) {
|
void OMV_USB1_IRQ_HANDLER(void) {
|
||||||
dcd_int_handler(0);
|
dcd_int_handler(0);
|
||||||
// If there are any event to process, schedule a call to cdc loop.
|
// If there are any event to process, schedule a call to cdc loop.
|
||||||
if (tinyusb_debug_enabled()) {
|
if (tud_task_event_ready()) {
|
||||||
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
|
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +142,7 @@ void OMV_USB1_IRQ_HANDLER(void) {
|
|||||||
void OMV_USB2_IRQ_HANDLER(void) {
|
void OMV_USB2_IRQ_HANDLER(void) {
|
||||||
dcd_int_handler(1);
|
dcd_int_handler(1);
|
||||||
// If there are any event to process, schedule a call to cdc loop.
|
// If there are any event to process, schedule a call to cdc loop.
|
||||||
if (tinyusb_debug_enabled()) {
|
if (tud_task_event_ready()) {
|
||||||
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
|
pendsv_schedule_dispatch(PENDSV_DISPATCH_CDC, tinyusb_debug_task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user