diff --git a/src/adiv5_jtagdp.c b/src/adiv5_jtagdp.c index d97bc99..b9e805a 100644 --- a/src/adiv5_jtagdp.c +++ b/src/adiv5_jtagdp.c @@ -44,6 +44,7 @@ static uint32_t adiv5_jtagdp_error(ADIv5_DP_t *dp); static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, uint16_t addr, uint32_t value); +static void adiv5_jtagdp_abort(ADIv5_DP_t *dp, uint32_t abort); void adiv5_jtag_dp_handler(jtag_dev_t *dev) { @@ -55,6 +56,7 @@ void adiv5_jtag_dp_handler(jtag_dev_t *dev) dp->dp_read = adiv5_jtagdp_read; dp->error = adiv5_jtagdp_error; dp->low_access = adiv5_jtagdp_low_access; + dp->abort = adiv5_jtagdp_abort; adiv5_dp_init(dp); } @@ -100,3 +102,10 @@ static uint32_t adiv5_jtagdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, return (uint32_t)(response >> 3); } +static void adiv5_jtagdp_abort(ADIv5_DP_t *dp, uint32_t abort) +{ + uint64_t request = (uint64_t)abort << 3; + jtag_dev_write_ir(dp->dev, IR_ABORT); + jtag_dev_shift_dr(dp->dev, NULL, (const uint8_t*)&request, 35); +} + diff --git a/src/adiv5_swdp.c b/src/adiv5_swdp.c index 44edcb6..63e4eb4 100644 --- a/src/adiv5_swdp.c +++ b/src/adiv5_swdp.c @@ -41,6 +41,7 @@ static uint32_t adiv5_swdp_error(ADIv5_DP_t *dp); static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, uint16_t addr, uint32_t value); +static void adiv5_swdp_abort(ADIv5_DP_t *dp, uint32_t abort); int adiv5_swdp_scan(void) { @@ -65,6 +66,7 @@ int adiv5_swdp_scan(void) dp->dp_read = adiv5_swdp_read; dp->error = adiv5_swdp_error; dp->low_access = adiv5_swdp_low_access; + dp->abort = adiv5_swdp_abort; adiv5_swdp_error(dp); adiv5_dp_init(dp); @@ -158,3 +160,8 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t RnW, return response; } +static void adiv5_swdp_abort(ADIv5_DP_t *dp, uint32_t abort) +{ + adiv5_dp_write(dp, ADIV5_DP_ABORT, abort); +} + diff --git a/src/include/adiv5.h b/src/include/adiv5.h index b6fe30f..6bebd3e 100644 --- a/src/include/adiv5.h +++ b/src/include/adiv5.h @@ -110,6 +110,7 @@ typedef struct ADIv5_DP_s { uint32_t (*error)(struct ADIv5_DP_s *dp); uint32_t (*low_access)(struct ADIv5_DP_s *dp, uint8_t RnW, uint16_t addr, uint32_t value); + void (*abort)(struct ADIv5_DP_s *dp, uint32_t abort); union { jtag_dev_t *dev; @@ -133,6 +134,11 @@ static inline uint32_t adiv5_dp_low_access(struct ADIv5_DP_s *dp, uint8_t RnW, return dp->low_access(dp, RnW, addr, value); } +static inline void adiv5_dp_abort(struct ADIv5_DP_s *dp, uint32_t abort) +{ + return dp->abort(dp, abort); +} + typedef struct ADIv5_AP_s { int refcnt;