Skip to content

Commit

Permalink
Add verbose debug option for SWDP ACK values
Browse files Browse the repository at this point in the history
  • Loading branch information
navado committed Dec 20, 2018
1 parent 374bee3 commit a54ec9b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/platforms/native/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR tim3_isr

#undef VERBOSE_DEBUG
#ifdef ENABLE_DEBUG
extern bool debug_bmp;
int usbuart_debug_write(const char *buf, size_t len);
Expand Down
27 changes: 18 additions & 9 deletions src/target/adiv5_swdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,26 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW,
ack = swdptap_seq_in(3);
} while (ack == SWDP_ACK_WAIT && !platform_timeout_is_expired(&timeout));

if (ack == SWDP_ACK_WAIT)
raise_exception(EXCEPTION_TIMEOUT, "SWDP ACK timeout");

if(ack == SWDP_ACK_FAULT) {
dp->fault = 1;
return 0;
switch(ack){
case SWDP_ACK_OK:
#ifdef VERBOSE_DEBUG
DEBUG("adiv5_swdp_low_access: SWDP_ACK_OK\n");
#endif
break;
case SWDP_ACK_WAIT:
DEBUG("adiv5_swdp_low_access: SWDP_ACK_WAIT\n");
raise_exception(EXCEPTION_TIMEOUT, "SWDP ACK timeout");
break;
case SWDP_ACK_FAULT:
DEBUG("adiv5_swdp_low_access: SWDP_ACK_FAULT\n");
dp->fault = 1;
return 0;
default:
DEBUG("adiv5_swdp_low_access: SWDP invalid ACK 0x%01" PRIx32 "\n",ack);
raise_exception(EXCEPTION_ERROR, "SWDP invalid ACK");
break;
}

if(ack != SWDP_ACK_OK)
raise_exception(EXCEPTION_ERROR, "SWDP invalid ACK");

if(RnW) {
if(swdptap_seq_in_parity(&response, 32)) /* Give up on parity error */
raise_exception(EXCEPTION_ERROR, "SWDP Parity error");
Expand Down

0 comments on commit a54ec9b

Please sign in to comment.