Skip to content

Commit 553558f

Browse files
flitgaborcsapo
authored andcommitted
DAP: define constants for DAPLink's CMSIS-DAP vendor commands. (ARMmbed#891)
1 parent 2776b21 commit 553558f

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

source/daplink/cmsis-dap/DAP_vendor.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-2020 Arm Limited. All rights reserved.
33
* Copyright 2019, Cypress Semiconductor Corporation
44
* or a subsidiary of Cypress Semiconductor Corporation.
5+
* Copyright (c) 2021 Chris Reed
56
*
67
* SPDX-License-Identifier: Apache-2.0
78
*
@@ -38,7 +39,7 @@
3839
#include "target_family.h"
3940
#include "flash_manager.h"
4041
#include <string.h>
41-
42+
#include "daplink_vendor_commands.h"
4243

4344
#ifdef DRAG_N_DROP_SUPPORT
4445
#include "file_stream.h"
@@ -66,15 +67,15 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
6667
*response++ = *request; // copy Command ID
6768

6869
switch (*request++) { // first byte in request is Command ID
69-
case ID_DAP_Vendor0: {
70+
case ID_DAP_GetUniqueID: {
7071
const char *id_str = info_get_unique_id();
7172
uint8_t len = strlen(id_str);
7273
*response++ = len;
7374
memcpy(response, id_str, len);
7475
num += (len + 1); // increment response count by ID length + length byte
7576
break;
7677
}
77-
case ID_DAP_Vendor1: {
78+
case ID_DAP_UART_GetLineCoding: {
7879
// get line coding
7980
int32_t read_len = sizeof(CDC_LINE_CODING);
8081
CDC_LINE_CODING cdc_line_coding;
@@ -83,7 +84,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
8384
num += (read_len + 1);
8485
break;
8586
}
86-
case ID_DAP_Vendor2: {
87+
case ID_DAP_UART_SetConfiguration: {
8788
// set uart configuration
8889
CDC_LINE_CODING cdc_line_coding;
8990
USBD_CDC_ACM_PortGetLineCoding(&cdc_line_coding);
@@ -97,7 +98,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
9798
num += (sizeof(uint32_t) << 16) | 1;
9899
break;
99100
}
100-
case ID_DAP_Vendor3: {
101+
case ID_DAP_UART_Read: {
101102
// uart read
102103
int32_t read_len = 62;
103104
read_len = uart_read_data(response + 1, read_len);
@@ -109,7 +110,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
109110
num += (read_len + 1);
110111
break;
111112
}
112-
case ID_DAP_Vendor4: {
113+
case ID_DAP_UART_Write: {
113114
// uart write
114115
int32_t write_len = *request;
115116
request++;
@@ -122,7 +123,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
122123
case ID_DAP_Vendor5: break;
123124
case ID_DAP_Vendor6: break;
124125
case ID_DAP_Vendor7: break;
125-
case ID_DAP_Vendor8: {
126+
case ID_DAP_SetUSBTestMode: {
126127
*response = 1;
127128
if (0 == *request) {
128129
main_usb_set_test_mode(false);
@@ -134,7 +135,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
134135
num += (1U << 16) | 1U; // increment request and response count each by 1
135136
break;
136137
}
137-
case ID_DAP_Vendor9: {
138+
case ID_DAP_ResetTargetIfNoAutoReset: {
138139
// reset target
139140
*response = 1;
140141
if (!config_get_auto_rst()) {
@@ -144,19 +145,19 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
144145
break;
145146
}
146147
#ifdef DRAG_N_DROP_SUPPORT
147-
case ID_DAP_Vendor10: {
148+
case ID_DAP_MSD_Open: {
148149
// open mass storage device stream
149150
*response = stream_open((stream_type_t)(*request));
150151
num += (1 << 16) | 1;
151152
break;
152153
}
153-
case ID_DAP_Vendor11: {
154+
case ID_DAP_MSD_Close: {
154155
// close mass storage device stream
155156
*response = stream_close();
156157
num += 1;
157158
break;
158159
}
159-
case ID_DAP_Vendor12: {
160+
case ID_DAP_MSD_Write: {
160161
// write to mass storage device
161162
uint32_t write_len = *request;
162163
request++;
@@ -166,7 +167,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
166167
break;
167168
}
168169
#endif
169-
case ID_DAP_Vendor13: {
170+
case ID_DAP_SelectEraseMode: {
170171
// switching between chip erase and page erase
171172
// COMMAND(OUT Packet)
172173
// BYTE 0 1000 1110 0x8D
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* DAPLink Interface Firmware
3+
* Copyright (c) 2021 Chris Reed
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
/**
19+
* @file
20+
* @brief Vendor-specific CMSIS-DAP command constants.
21+
*/
22+
23+
#include "DAP.h"
24+
25+
//! @name DAPLink vendor-specific CMSIS-DAP command IDs
26+
//@{
27+
#define ID_DAP_GetUniqueID ID_DAP_Vendor0
28+
#define ID_DAP_UART_GetLineCoding ID_DAP_Vendor1
29+
#define ID_DAP_UART_SetConfiguration ID_DAP_Vendor2
30+
#define ID_DAP_UART_Read ID_DAP_Vendor3
31+
#define ID_DAP_UART_Write ID_DAP_Vendor4
32+
#define ID_DAP_SetUSBTestMode ID_DAP_Vendor8
33+
#define ID_DAP_ResetTargetIfNoAutoReset ID_DAP_Vendor9
34+
#define ID_DAP_MSD_Open ID_DAP_Vendor10
35+
#define ID_DAP_MSD_Close ID_DAP_Vendor11
36+
#define ID_DAP_MSD_Write ID_DAP_Vendor12
37+
#define ID_DAP_SelectEraseMode ID_DAP_Vendor13
38+
//@}
39+

0 commit comments

Comments
 (0)