1 /* 2 * Copyright (c) 2018-2019 PHYTEC Messtechnik GmbH 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /* 8 * This file is based on DAP.c from CMSIS-DAP Source (Revision: V2.0.0) 9 * https://github.com/ARM-software/CMSIS_5/tree/develop/CMSIS/DAP/Firmware 10 * Copyright (c) 2013-2017 ARM Limited. All rights reserved. 11 * SPDX-License-Identifier: Apache-2.0 12 */ 13 14 /** 15 * @file 16 * @brief DAP controller private header 17 */ 18 19 #ifndef ZEPHYR_INCLUDE_CMSIS_DAP_H_ 20 #define ZEPHYR_INCLUDE_CMSIS_DAP_H_ 21 22 #include <zephyr/kernel.h> 23 24 /* Firmware Version */ 25 #define DAP_FW_VER "2.1.0" 26 27 /* DAP Command IDs */ 28 #define ID_DAP_INFO 0x00U 29 #define ID_DAP_HOST_STATUS 0x01U 30 #define ID_DAP_CONNECT 0x02U 31 #define ID_DAP_DISCONNECT 0x03U 32 #define ID_DAP_TRANSFER_CONFIGURE 0x04U 33 #define ID_DAP_TRANSFER 0x05U 34 #define ID_DAP_TRANSFER_BLOCK 0x06U 35 #define ID_DAP_TRANSFER_ABORT 0x07U 36 #define ID_DAP_WRITE_ABORT 0x08U 37 #define ID_DAP_DELAY 0x09U 38 #define ID_DAP_RESET_TARGET 0x0AU 39 40 #define ID_DAP_SWJ_PINS 0x10U 41 #define ID_DAP_SWJ_CLOCK 0x11U 42 #define ID_DAP_SWJ_SEQUENCE 0x12U 43 44 #define ID_DAP_SWDP_CONFIGURE 0x13U 45 #define ID_DAP_SWDP_SEQUENCE 0x1DU 46 47 #define ID_DAP_JTAG_SEQUENCE 0x14U 48 #define ID_DAP_JTAG_CONFIGURE 0x15U 49 #define ID_DAP_JTAG_IDCODE 0x16U 50 51 #define ID_DAP_SWO_TRANSPORT 0x17U 52 #define ID_DAP_SWO_MODE 0x18U 53 #define ID_DAP_SWO_BAUDRATE 0x19U 54 #define ID_DAP_SWO_CONTROL 0x1AU 55 #define ID_DAP_SWO_STATUS 0x1BU 56 #define ID_DAP_SWO_DATA 0x1CU 57 58 #define ID_DAP_UART_TRANSPORT 0x1FU 59 #define ID_DAP_UART_CONFIGURE 0x20U 60 #define ID_DAP_UART_CONTROL 0x22U 61 #define ID_DAP_UART_STATUS 0x23U 62 #define ID_DAP_UART_TRANSFER 0x21U 63 64 #define ID_DAP_QUEUE_COMMANDS 0x7EU 65 #define ID_DAP_EXECUTE_COMMANDS 0x7FU 66 67 /* DAP Vendor Command IDs */ 68 #define ID_DAP_VENDOR0 0x80U 69 #define ID_DAP_VENDOR31 0x9FU 70 #define ID_DAP_INVALID 0xFFU 71 72 /* DAP Status Code */ 73 #define DAP_OK 0U 74 #define DAP_ERROR 0xFFU 75 76 /* DAP ID */ 77 #define DAP_ID_VENDOR 0x01U 78 #define DAP_ID_PRODUCT 0x02U 79 #define DAP_ID_SER_NUM 0x03U 80 #define DAP_ID_FW_VER 0x04U 81 #define DAP_ID_DEVICE_VENDOR 0x05U 82 #define DAP_ID_DEVICE_NAME 0x06U 83 #define DAP_ID_BOARD_VENDOR 0x07U 84 #define DAP_ID_BOARD_NAME 0x08U 85 #define DAP_ID_PRODUCT_FW_VER 0x09U 86 #define DAP_ID_CAPABILITIES 0xF0U 87 #define DAP_ID_TIMESTAMP_CLOCK 0xF1U 88 #define DAP_ID_UART_RX_BUFFER_SIZE 0xFBU 89 #define DAP_ID_UART_TX_BUFFER_SIZE 0xFCU 90 #define DAP_ID_SWO_BUFFER_SIZE 0xFDU 91 #define DAP_ID_PACKET_COUNT 0xFEU 92 #define DAP_ID_PACKET_SIZE 0xFFU 93 94 /* DAP Host Status */ 95 #define DAP_DEBUGGER_CONNECTED 0U 96 #define DAP_TARGET_RUNNING 1U 97 98 /* DAP Port */ 99 #define DAP_PORT_AUTODETECT 0U 100 #define DAP_PORT_DISABLED 0U 101 #define DAP_PORT_SWD 1U 102 #define DAP_PORT_JTAG 2U 103 104 /* DAP transfer request bits */ 105 #define DAP_TRANSFER_MATCH_VALUE BIT(4) 106 #define DAP_TRANSFER_MATCH_MASK BIT(5) 107 108 /* DAP transfer response bits */ 109 #define DAP_TRANSFER_MISMATCH BIT(4) 110 111 /* DAP controller capabilities */ 112 #define DAP_DP_SUPPORTS_SWD BIT(0) 113 #define DAP_DP_SUPPORTS_JTAG BIT(1) 114 #define DAP_SWO_SUPPORTS_UART BIT(2) 115 #define DAP_SWO_SUPPORTS_MANCHESTER BIT(3) 116 #define DAP_SUPPORTS_ATOMIC_COMMANDS BIT(4) 117 #define DAP_SUPPORTS_TIMESTAMP_CLOCK BIT(5) 118 #define DAP_SWO_SUPPORTS_STREAM BIT(6) 119 120 /* DP Register (DPv1) */ 121 #define DP_IDCODE 0x00U 122 #define DP_ABORT 0x00U 123 #define DP_CTRL_STAT 0x04U 124 #define DP_SELECT 0x08U 125 #define DP_RESEND 0x08U 126 #define DP_RDBUFF 0x0CU 127 128 #define DAP_MBMSG_REGISTER_IFACE 0x0U 129 #define DAP_MBMSG_FROM_IFACE 0x1U 130 #define DAP_MBMSG_FROM_CONTROLLER 0x2U 131 132 /* Keep it internal until an other interface has been implemented. */ 133 int dap_setup(const struct device *const dev); 134 uint32_t dap_execute_cmd(const uint8_t *request, uint8_t *response); 135 136 #endif /* ZEPHYR_INCLUDE_CMSIS_DAP_H_ */ 137