Skip to content

Commit 05a45a1

Browse files
maxd-nordicaescolar
authored andcommitted
dap: fix timeout handling
Use k_timepoint_t for timeout handling in the swj_pins function. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent 94f48c7 commit 05a45a1

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

subsys/dap/cmsis_dap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static uint16_t dap_swj_pins(struct dap_context *const ctx,
285285
uint8_t value = request[0];
286286
uint8_t select = request[1];
287287
uint32_t wait = sys_get_le32(&request[2]);
288-
int64_t timeout_ticks;
288+
k_timepoint_t end = sys_timepoint_calc(K_USEC(wait));
289289
uint8_t state;
290290

291291
if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) {
@@ -299,8 +299,6 @@ static uint16_t dap_swj_pins(struct dap_context *const ctx,
299299
api->swdp_set_pins(ctx->swdp_dev, select, value);
300300
}
301301

302-
timeout_ticks = k_uptime_ticks() + (CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000000 * wait);
303-
304302
do {
305303
api->swdp_get_pins(ctx->swdp_dev, &state);
306304
LOG_INF("select 0x%02x, value 0x%02x, wait %u, state 0x%02x",
@@ -309,7 +307,7 @@ static uint16_t dap_swj_pins(struct dap_context *const ctx,
309307
LOG_DBG("swdp_get_pins succeeded before timeout");
310308
break;
311309
}
312-
} while (k_uptime_ticks() - timeout_ticks > 0);
310+
} while (!sys_timepoint_expired(end));
313311

314312
response[0] = state;
315313

0 commit comments

Comments
 (0)