Skip to content

Commit

Permalink
Call swd_init_debug() after reset + fix ACK checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias-arm committed Oct 15, 2021
1 parent 38dbf7f commit ad474ac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions source/daplink/interface/swd_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* Copyright 2019, Cypress Semiconductor Corporation
* Copyright 2019, Cypress Semiconductor Corporation
* or a subsidiary of Cypress Semiconductor Corporation.
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -1052,35 +1052,37 @@ uint8_t swd_set_target_state_sw(target_state_t state)
swd_set_target_reset(0);
osDelay(2);

#ifndef INTERFACE_KL26Z
if (!swd_init_debug()) {
return 0;
}

// Power down
// Per ADIv6 spec. Clear first CSYSPWRUPREQ followed by CDBGPWRUPREQ
if (!swd_read_dp(DP_CTRL_STAT, &val)) {
return 0;
}

if (!swd_write_dp(DP_CTRL_STAT, val & ~CSYSPWRUPREQ)) {
return 0;
}

// Wait until ACK is deasserted
do {
if (!swd_read_dp(DP_CTRL_STAT, &val)) {
return 0;
}
} while ((val & (CSYSPWRUPACK)) == 1);
} while ((val & (CSYSPWRUPACK)) != 0);

if (!swd_write_dp(DP_CTRL_STAT, val & ~CDBGPWRUPREQ)) {
return 0;
}

// Wait until ACK is deasserted
do {
if (!swd_read_dp(DP_CTRL_STAT, &val)) {
return 0;
}
} while ((val & (CDBGPWRUPACK)) == 1);
#endif
} while ((val & (CDBGPWRUPACK)) != 0);

swd_off();
break;
Expand Down

0 comments on commit ad474ac

Please sign in to comment.