aboutsummaryrefslogtreecommitdiff
path: root/src/stm32/gdb_if.c
diff options
context:
space:
mode:
authorGareth McMullin2011-07-02 20:47:39 +1200
committerGareth McMullin2011-07-02 20:47:39 +1200
commitadabaa759296b8f2470d7c562963d4e34dc35b19 (patch)
tree77d4ac2f07cce527a3d65bd7a35d2cc46b2485cb /src/stm32/gdb_if.c
parentbd779aa618fab9ceb47d432d8f31719618fd75a4 (diff)
Halt and detach target if host releases DTR.
Port reads 0x04 (EOF) when DTR is released. GDB loop detaches from target if EOF is read. Fixes bug 3307433.
Diffstat (limited to 'src/stm32/gdb_if.c')
-rw-r--r--src/stm32/gdb_if.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/stm32/gdb_if.c b/src/stm32/gdb_if.c
index 08dfa03..2ed8c41 100644
--- a/src/stm32/gdb_if.c
+++ b/src/stm32/gdb_if.c
@@ -47,6 +47,10 @@ void gdb_if_putchar(unsigned char c, int flush)
unsigned char gdb_if_getchar(void)
{
while(!(out_ptr < count_out)) {
+ /* Detach if port closed */
+ if(!cdcacm_get_dtr())
+ return 0x04;
+
while(cdcacm_get_config() != 1);
count_out = usbd_ep_read_packet(1, buffer_out,
VIRTUAL_COM_PORT_DATA_SIZE);
@@ -61,6 +65,10 @@ unsigned char gdb_if_getchar_to(int timeout)
timeout_counter = timeout/100;
if(!(out_ptr < count_out)) do {
+ /* Detach if port closed */
+ if(!cdcacm_get_dtr())
+ return 0x04;
+
count_out = usbd_ep_read_packet(1, buffer_out,
VIRTUAL_COM_PORT_DATA_SIZE);
out_ptr = 0;