Lines Matching +full:long +full:- +full:delay +full:- +full:ms
2 * Copyright (c) 2018-2019 PHYTEC Messtechnik GmbH
5 * SPDX-License-Identifier: Apache-2.0
9 * This file is based on DAP.c from CMSIS-DAP Source (Revision: V2.0.0)
10 * https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DAP/Firmware
11 * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
12 * SPDX-License-Identifier: Apache-2.0
51 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
52 "PROBE_VENDOR string is too long.");
54 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
55 "PROBE_NAME string is too long.");
57 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
58 "BOARD_VENDOR string is too long.");
60 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
61 "BOARD_NAME string is too long.");
63 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
64 "DEVICE_VENDOR string is too long.");
66 MIN(CONFIG_CMSIS_DAP_PACKET_SIZE - 2, UINT8_MAX - 2),
67 "DEVICE_NAME string is too long.");
129 info[0] = ctx->capabilities; in dap_info()
147 sys_put_le16(ctx->pkt_size, &info[0]); in dap_info()
195 const struct swdp_api *api = ctx->swdp_dev->api; in dap_connect()
207 ctx->debug_port = DAP_PORT_SWD; in dap_connect()
209 if (atomic_test_and_set_bit(&ctx->state, in dap_connect()
215 api->swdp_port_on(ctx->swdp_dev); in dap_connect()
235 const struct swdp_api *api = ctx->swdp_dev->api; in dap_disconnect()
239 ctx->debug_port = DAP_PORT_DISABLED; in dap_disconnect()
241 if (atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_disconnect()
242 api->swdp_port_off(ctx->swdp_dev); in dap_disconnect()
248 atomic_clear_bit(&ctx->state, DAP_STATE_CONNECTED); in dap_disconnect()
253 /* Process Delay command and prepare response */
258 uint16_t delay = sys_get_le16(&request[0]); in dap_delay() local
260 LOG_DBG("dap delay %u ms", delay); in dap_delay()
262 k_busy_wait(delay * USEC_PER_MSEC); in dap_delay()
284 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swj_pins()
291 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_swj_pins()
299 api->swdp_set_pins(ctx->swdp_dev, select, value); in dap_swj_pins()
303 api->swdp_get_pins(ctx->swdp_dev, &state); in dap_swj_pins()
322 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swj_clock()
327 if (atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_swj_clock()
329 api->swdp_set_clock(ctx->swdp_dev, clk); in dap_swj_clock()
347 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swj_sequence()
356 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_swj_sequence()
362 api->swdp_output_sequence(ctx->swdp_dev, count, &request[1]); in dap_swj_sequence()
373 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swdp_configure()
377 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_swdp_configure()
383 api->swdp_configure(ctx->swdp_dev, turnaround, data_phase); in dap_swdp_configure()
395 ctx->transfer.idle_cycles = request[0]; in dap_transfer_cfg()
396 ctx->transfer.retry_count = sys_get_le16(&request[1]); in dap_transfer_cfg()
397 ctx->transfer.match_retry = sys_get_le16(&request[3]); in dap_transfer_cfg()
399 ctx->transfer.idle_cycles, in dap_transfer_cfg()
400 ctx->transfer.retry_count, in dap_transfer_cfg()
401 ctx->transfer.match_retry); in dap_transfer_cfg()
411 const struct swdp_api *api = ctx->swdp_dev->api; in do_swdp_transfer()
412 uint32_t retry = ctx->transfer.retry_count; in do_swdp_transfer()
416 api->swdp_transfer(ctx->swdp_dev, in do_swdp_transfer()
419 ctx->transfer.idle_cycles, in do_swdp_transfer()
421 } while ((rspns_val == SWDP_ACK_WAIT) && retry--); in do_swdp_transfer()
430 uint32_t match_retry = ctx->transfer.match_retry; in swdp_transfer_match()
452 } while (((data & ctx->transfer.match_mask) != match_val) && in swdp_transfer_match()
453 match_retry--); in swdp_transfer_match()
455 if ((data & ctx->transfer.match_mask) != match_val) { in swdp_transfer_match()
491 for (; req_cnt; req_cnt--) { in dap_swdp_transfer()
569 ctx->transfer.match_mask = data; in dap_swdp_transfer()
609 return (rspns_buf - response); in dap_swdp_transfer()
619 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_transfer()
625 switch (ctx->debug_port) { in dap_transfer()
643 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swdp_sequence()
651 switch (ctx->debug_port) { in dap_swdp_sequence()
674 api->swdp_input_sequence(ctx->swdp_dev, num_cycles, response_data); in dap_swdp_sequence()
677 api->swdp_output_sequence(ctx->swdp_dev, num_cycles, request_data); in dap_swdp_sequence()
682 return response_data - response; in dap_swdp_sequence()
724 while (req_cnt--) { in dap_swdp_transferblock()
744 while (req_cnt--) { in dap_swdp_transferblock()
765 req_buf - request, in dap_swdp_transferblock()
766 rspns_buf - response, in dap_swdp_transferblock()
769 return (rspns_buf - response); in dap_swdp_transferblock()
779 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_transferblock()
788 switch (ctx->debug_port) { in dap_transferblock()
810 const struct swdp_api *api = ctx->swdp_dev->api; in dap_swdp_writeabort()
815 api->swdp_transfer(ctx->swdp_dev, DP_ABORT, &data, in dap_swdp_writeabort()
816 ctx->transfer.idle_cycles, NULL); in dap_swdp_writeabort()
829 if (!atomic_test_bit(&ctx->state, DAP_STATE_CONNECTED)) { in dap_writeabort()
835 switch (ctx->debug_port) { in dap_writeabort()
999 *(response - 1) = ID_DAP_INVALID; in dap_process_cmd()
1028 while (count--) { in dap_execute_cmd()
1046 return -ENODEV; in dap_setup()