From 5548d54626a658b65f1f963cd5af54ddaf93fbf7 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Tue, 6 Mar 2018 18:52:23 +0100 Subject: [PATCH] common/swdptap: some clean up. Remove superfluous transaction. Use native variable size. --- src/platforms/common/swdptap.c | 4 ++-- src/target/adiv5_swdp.c | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/platforms/common/swdptap.c b/src/platforms/common/swdptap.c index 9a0d89c..46d5a67 100644 --- a/src/platforms/common/swdptap.c +++ b/src/platforms/common/swdptap.c @@ -28,9 +28,9 @@ int swdptap_init(void) return 0; } -static void swdptap_turnaround(uint8_t dir) +static void swdptap_turnaround(int dir) { - static uint8_t olddir = 0; + static int olddir = 0; /* Don't turnaround if direction not changing */ if(dir == olddir) return; diff --git a/src/target/adiv5_swdp.c b/src/target/adiv5_swdp.c index dd03654..dcd46a6 100644 --- a/src/target/adiv5_swdp.c +++ b/src/target/adiv5_swdp.c @@ -44,7 +44,7 @@ static void adiv5_swdp_abort(ADIv5_DP_t *dp, uint32_t abort); int adiv5_swdp_scan(void) { - uint8_t ack; + uint32_t ack; target_list_free(); ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp)); @@ -122,9 +122,9 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, { bool APnDP = addr & ADIV5_APnDP; addr &= 0xff; - uint8_t request = 0x81; + uint32_t request = 0x81; uint32_t response = 0; - uint8_t ack; + uint32_t ack; platform_timeout timeout; if(APnDP && dp->fault) return 0; @@ -141,7 +141,7 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, do { swdptap_seq_out(request, 8); ack = swdptap_seq_in(3); - } while (!platform_timeout_is_expired(&timeout) && ack == SWDP_ACK_WAIT); + } while (ack == SWDP_ACK_WAIT && !platform_timeout_is_expired(&timeout)); if (ack == SWDP_ACK_WAIT) raise_exception(EXCEPTION_TIMEOUT, "SWDP ACK timeout"); @@ -161,9 +161,6 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, swdptap_seq_out_parity(value, 32); } - /* REMOVE THIS */ - swdptap_seq_out(0, 8); - return response; }