Skip to content

Commit

Permalink
gdb_if: Correct sleeping on no data for dwc2
Browse files Browse the repository at this point in the history
* count_new is always 0 by the time of check. Save a copy of it.
* This restores performance but keeps the sleep, affecting STM32F4, STM32F7
  • Loading branch information
ALTracer committed Jul 7, 2024
1 parent ed6e5b8 commit c60e11b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/platforms/common/stm32/gdb_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ static void gdb_if_update_buf(void)
#else
cm_disable_interrupts();
__asm__ volatile("isb");
/* count_new will become 0 by the time of decision to WFI, so save a copy at entry */
const uint32_t count_new_saved = count_new;
if (count_new) {
memcpy(buffer_out, double_buffer_out, count_new);
count_out = count_new;
Expand All @@ -99,7 +101,8 @@ static void gdb_if_update_buf(void)
}
cm_enable_interrupts();
__asm__ volatile("isb");
if (!count_new)
/* Wait for Host OUT packets (count_new is 0 by now, so use the copy saved at entry) */
if (!count_new_saved)
__WFI();
#endif
if (!count_out)
Expand Down

0 comments on commit c60e11b

Please sign in to comment.