From 7b13bae8dcfbbbd5dc56eb9950aec93c96340cb7 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sat, 12 Nov 2011 13:46:16 +1300 Subject: Don't send anything on USB if not configured or DTR is released. --- src/stm32/gdb_if.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/stm32/gdb_if.c b/src/stm32/gdb_if.c index 2ed8c41..59e9c2b 100644 --- a/src/stm32/gdb_if.c +++ b/src/stm32/gdb_if.c @@ -39,6 +39,12 @@ void gdb_if_putchar(unsigned char c, int flush) { buffer_in[count_in++] = c; if(flush || (count_in == VIRTUAL_COM_PORT_DATA_SIZE)) { + /* Refuse to send if USB isn't configured, and + * don't bother if nobody's listening */ + if((cdcacm_get_config() != 1) || !cdcacm_get_dtr()) { + count_in = 0; + return; + } while(usbd_ep_write_packet(1, buffer_in, count_in) <= 0); count_in = 0; } -- cgit v1.2.3