aboutsummaryrefslogtreecommitdiff
path: root/src/adiv5_swdp.c
diff options
context:
space:
mode:
authorPaul Fertser2013-05-05 00:46:49 +0400
committerGareth McMullin2013-06-19 19:28:16 +1200
commitd90e10cdbaa05509d1ee78f982d3aa0a2c94e972 (patch)
treeed499187f9ff04ccba9070932c3db2c099ea7183 /src/adiv5_swdp.c
parent27a86e244f6dd913b58fd18d40e470ef20810881 (diff)
adiv5_swdp: avoid dead-loop with a sleeping target
A sleeping target continues to communicate over SWD properly but consistently returns SWDP_ACK_WAIT. It might be nice to be able to wait for the target to wake up on its own but if it's not going to wake up, BMP becomes absolutely unresponsive. Probably the timeout should be made configurable or some other workaround invented. Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'src/adiv5_swdp.c')
-rw-r--r--src/adiv5_swdp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/adiv5_swdp.c b/src/adiv5_swdp.c
index 8a38330..839127d 100644
--- a/src/adiv5_swdp.c
+++ b/src/adiv5_swdp.c
@@ -129,10 +129,14 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW
if((addr == 4) || (addr == 8))
request ^= 0x20;
+ size_t tries = 1000;
do {
swdptap_seq_out(request, 8);
ack = swdptap_seq_in(3);
- } while(ack == SWDP_ACK_WAIT);
+ } while(--tries && ack == SWDP_ACK_WAIT);
+
+ if(!tries)
+ PLATFORM_FATAL_ERROR(1);
if(ack == SWDP_ACK_FAULT) {
dp->fault = 1;