Skip to content

Commit 82d9b4d

Browse files
authored
DAP: define constants for DAPLink's CMSIS-DAP vendor commands. (ARMmbed#891)
1 parent e58d44b commit 82d9b4d

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"
@@ -67,15 +68,15 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
6768
*response++ = *request; // copy Command ID
6869

6970
switch (*request++) { // first byte in request is Command ID
70-
case ID_DAP_Vendor0: {
71+
case ID_DAP_GetUniqueID: {
7172
const char *id_str = info_get_unique_id();
7273
uint8_t len = strlen(id_str);
7374
*response++ = len;
7475
memcpy(response, id_str, len);
7576
num += (len + 1); // increment response count by ID length + length byte
7677
break;
7778
}
78-
case ID_DAP_Vendor1: {
79+
case ID_DAP_UART_GetLineCoding: {
7980
// get line coding
8081
int32_t read_len = sizeof(CDC_LINE_CODING);
8182
CDC_LINE_CODING cdc_line_coding;
@@ -84,7 +85,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
8485
num += (read_len + 1);
8586
break;
8687
}
87-
case ID_DAP_Vendor2: {
88+
case ID_DAP_UART_SetConfiguration: {
8889
// set uart configuration
8990
CDC_LINE_CODING cdc_line_coding;
9091
USBD_CDC_ACM_PortGetLineCoding(&cdc_line_coding);
@@ -98,7 +99,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
9899
num += (sizeof(uint32_t) << 16) | 1;
99100
break;
100101
}
101-
case ID_DAP_Vendor3: {
102+
case ID_DAP_UART_Read: {
102103
// uart read
103104
int32_t read_len = 62;
104105
read_len = uart_read_data(response + 1, read_len);
@@ -110,7 +111,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
110111
num += (read_len + 1);
111112
break;
112113
}
113-
case ID_DAP_Vendor4: {
114+
case ID_DAP_UART_Write: {
114115
// uart write
115116
int32_t write_len = *request;
116117
request++;
@@ -123,7 +124,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
123124
case ID_DAP_Vendor5: break;
124125
case ID_DAP_Vendor6: break;
125126
case ID_DAP_Vendor7: break;
126-
case ID_DAP_Vendor8: {
127+
case ID_DAP_SetUSBTestMode: {
127128
*response = 1;
128129
if (0 == *request) {
129130
main_usb_set_test_mode(false);
@@ -135,7 +136,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
135136
num += (1U << 16) | 1U; // increment request and response count each by 1
136137
break;
137138
}
138-
case ID_DAP_Vendor9: {
139+
case ID_DAP_ResetTargetIfNoAutoReset: {
139140
// reset target
140141
*response = 1;
141142
if (!config_get_auto_rst()) {
@@ -145,19 +146,19 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
145146
break;
146147
}
147148
#ifdef DRAG_N_DROP_SUPPORT
148-
case ID_DAP_Vendor10: {
149+
case ID_DAP_MSD_Open: {
149150
// open mass storage device stream
150151
*response = stream_open((stream_type_t)(*request));
151152
num += (1 << 16) | 1;
152153
break;
153154
}
154-
case ID_DAP_Vendor11: {
155+
case ID_DAP_MSD_Close: {
155156
// close mass storage device stream
156157
*response = stream_close();
157158
num += 1;
158159
break;
159160
}
160-
case ID_DAP_Vendor12: {
161+
case ID_DAP_MSD_Write: {
161162
// write to mass storage device
162163
uint32_t write_len = *request;
163164
request++;
@@ -167,7 +168,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
167168
break;
168169
}
169170
#endif
170-
case ID_DAP_Vendor13: {
171+
case ID_DAP_SelectEraseMode: {
171172
// switching between chip erase and page erase
172173
// COMMAND(OUT Packet)
173174
// 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)