Skip to content

Commit

Permalink
DAP: define constants for DAPLink's CMSIS-DAP vendor commands. (ARMmb…
Browse files Browse the repository at this point in the history
  • Loading branch information
flit authored and gaborcsapo committed Jun 29, 2022
1 parent 717ecd0 commit 6429a30
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
25 changes: 13 additions & 12 deletions source/daplink/cmsis-dap/DAP_vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (c) 2013-2020 Arm Limited. All rights reserved.
* Copyright 2019, Cypress Semiconductor Corporation
* or a subsidiary of Cypress Semiconductor Corporation.
* Copyright (c) 2021 Chris Reed
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -38,7 +39,7 @@
#include "target_family.h"
#include "flash_manager.h"
#include <string.h>

#include "daplink_vendor_commands.h"

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

switch (*request++) { // first byte in request is Command ID
case ID_DAP_Vendor0: {
case ID_DAP_GetUniqueID: {
const char *id_str = info_get_unique_id();
uint8_t len = strlen(id_str);
*response++ = len;
memcpy(response, id_str, len);
num += (len + 1); // increment response count by ID length + length byte
break;
}
case ID_DAP_Vendor1: {
case ID_DAP_UART_GetLineCoding: {
// get line coding
int32_t read_len = sizeof(CDC_LINE_CODING);
CDC_LINE_CODING cdc_line_coding;
Expand All @@ -83,7 +84,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (read_len + 1);
break;
}
case ID_DAP_Vendor2: {
case ID_DAP_UART_SetConfiguration: {
// set uart configuration
CDC_LINE_CODING cdc_line_coding;
USBD_CDC_ACM_PortGetLineCoding(&cdc_line_coding);
Expand All @@ -97,7 +98,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (sizeof(uint32_t) << 16) | 1;
break;
}
case ID_DAP_Vendor3: {
case ID_DAP_UART_Read: {
// uart read
int32_t read_len = 62;
read_len = uart_read_data(response + 1, read_len);
Expand All @@ -109,7 +110,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (read_len + 1);
break;
}
case ID_DAP_Vendor4: {
case ID_DAP_UART_Write: {
// uart write
int32_t write_len = *request;
request++;
Expand All @@ -122,7 +123,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
case ID_DAP_Vendor5: break;
case ID_DAP_Vendor6: break;
case ID_DAP_Vendor7: break;
case ID_DAP_Vendor8: {
case ID_DAP_SetUSBTestMode: {
*response = 1;
if (0 == *request) {
main_usb_set_test_mode(false);
Expand All @@ -134,7 +135,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += (1U << 16) | 1U; // increment request and response count each by 1
break;
}
case ID_DAP_Vendor9: {
case ID_DAP_ResetTargetIfNoAutoReset: {
// reset target
*response = 1;
if (!config_get_auto_rst()) {
Expand All @@ -144,19 +145,19 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
break;
}
#ifdef DRAG_N_DROP_SUPPORT
case ID_DAP_Vendor10: {
case ID_DAP_MSD_Open: {
// open mass storage device stream
*response = stream_open((stream_type_t)(*request));
num += (1 << 16) | 1;
break;
}
case ID_DAP_Vendor11: {
case ID_DAP_MSD_Close: {
// close mass storage device stream
*response = stream_close();
num += 1;
break;
}
case ID_DAP_Vendor12: {
case ID_DAP_MSD_Write: {
// write to mass storage device
uint32_t write_len = *request;
request++;
Expand All @@ -166,7 +167,7 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
break;
}
#endif
case ID_DAP_Vendor13: {
case ID_DAP_SelectEraseMode: {
// switching between chip erase and page erase
// COMMAND(OUT Packet)
// BYTE 0 1000 1110 0x8D
Expand Down
39 changes: 39 additions & 0 deletions source/daplink/cmsis-dap/daplink_vendor_commands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* DAPLink Interface Firmware
* Copyright (c) 2021 Chris Reed
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Vendor-specific CMSIS-DAP command constants.
*/

#include "DAP.h"

//! @name DAPLink vendor-specific CMSIS-DAP command IDs
//@{
#define ID_DAP_GetUniqueID ID_DAP_Vendor0
#define ID_DAP_UART_GetLineCoding ID_DAP_Vendor1
#define ID_DAP_UART_SetConfiguration ID_DAP_Vendor2
#define ID_DAP_UART_Read ID_DAP_Vendor3
#define ID_DAP_UART_Write ID_DAP_Vendor4
#define ID_DAP_SetUSBTestMode ID_DAP_Vendor8
#define ID_DAP_ResetTargetIfNoAutoReset ID_DAP_Vendor9
#define ID_DAP_MSD_Open ID_DAP_Vendor10
#define ID_DAP_MSD_Close ID_DAP_Vendor11
#define ID_DAP_MSD_Write ID_DAP_Vendor12
#define ID_DAP_SelectEraseMode ID_DAP_Vendor13
//@}

0 comments on commit 6429a30

Please sign in to comment.