From 52381672f3f5a784f11a46007ed5c99f7d6bdb7a Mon Sep 17 00:00:00 2001 From: ALTracer Date: Mon, 27 Nov 2023 22:41:03 +0300 Subject: [PATCH] gdb_if: Allow sleeping on no data for dwc2-using platforms --- src/platforms/common/stm32/gdb_if.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platforms/common/stm32/gdb_if.c b/src/platforms/common/stm32/gdb_if.c index 0bcfed7af5f..e6efa18bf9c 100644 --- a/src/platforms/common/stm32/gdb_if.c +++ b/src/platforms/common/stm32/gdb_if.c @@ -88,7 +88,8 @@ static void gdb_if_update_buf(void) count_out = usbd_ep_read_packet(usbdev, CDCACM_GDB_ENDPOINT, buffer_out, CDCACM_PACKET_SIZE); out_ptr = 0; #else - __asm__ volatile("cpsid i; isb"); + cm_disable_interrupts(); + __asm__ volatile("isb"); if (count_new) { memcpy(buffer_out, double_buffer_out, count_new); count_out = count_new; @@ -96,7 +97,11 @@ static void gdb_if_update_buf(void) out_ptr = 0; usbd_ep_nak_set(usbdev, CDCACM_GDB_ENDPOINT, 0); } - __asm__ volatile("cpsie i; isb"); + cm_enable_interrupts(); + __asm__ volatile("isb"); + if (!count_new) { + __WFI(); + } #endif if (!count_out) __WFI();