Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxd-nordic committed Aug 30, 2023
1 parent 338a308 commit 00f8c5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
15 changes: 9 additions & 6 deletions samples/subsys/dap/src/cmsis_dap_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

#include "cmsis_dap_usb.h"

#define DAP_USB_EP_IN 0x81
#define DAP_USB_EP_OUT 0x01

uint8_t rx_buf[CONFIG_CMSIS_DAP_PACKET_SIZE];
uint8_t tx_buf[CONFIG_CMSIS_DAP_PACKET_SIZE];

Expand Down Expand Up @@ -40,7 +43,7 @@ LOG_MODULE_REGISTER(cmsis_dap);
#define COMPATIBLE_ID_WINUSB \
'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00

static struct msosv2_descriptor_t {
static struct msosv2_descriptor_type {
struct msosv2_descriptor_set_header header;
#if defined(CONFIG_USB_COMPOSITE_DEVICE)
struct msosv2_function_subset_header cmsis_dap_v2_subset_header;
Expand All @@ -55,7 +58,7 @@ static struct msosv2_descriptor_t {
.wLength = sizeof(struct msosv2_descriptor_set_header),
.wDescriptorType = MS_OS_20_SET_HEADER_DESCRIPTOR,
.dwWindowsVersion = 0x06030000,
.wTotalLength = sizeof(struct msosv2_descriptor_t),
.wTotalLength = sizeof(struct msosv2_descriptor_type),
},
#if defined(CONFIG_USB_COMPOSITE_DEVICE)
.cmsis_dap_v2_subset_header = {
Expand Down Expand Up @@ -245,21 +248,21 @@ USBD_CLASS_DESCR_DEFINE(primary, 0) struct {
struct usb_ep_descriptor if0_in_ep;
} __packed dapusb_desc = {
.if0 = INITIALIZER_IF(2, USB_BCC_VENDOR),
.if0_out_ep = INITIALIZER_IF_EP(AUTO_EP_OUT, USB_DC_EP_BULK,
.if0_out_ep = INITIALIZER_IF_EP(DAP_USB_EP_OUT, USB_DC_EP_BULK,
CONFIG_CMSIS_DAP_PACKET_SIZE, 0),
.if0_in_ep = INITIALIZER_IF_EP(AUTO_EP_IN, USB_DC_EP_BULK,
.if0_in_ep = INITIALIZER_IF_EP(DAP_USB_EP_IN, USB_DC_EP_BULK,
CONFIG_CMSIS_DAP_PACKET_SIZE, 0),
};

/* Describe EndPoints configuration */
static struct usb_ep_cfg_data dapusb_ep_data[] = {
{
.ep_cb = usb_transfer_ep_callback,
.ep_addr = AUTO_EP_OUT
.ep_addr = DAP_USB_EP_OUT
},
{
.ep_cb = usb_transfer_ep_callback,
.ep_addr = AUTO_EP_IN
.ep_addr = DAP_USB_EP_IN
}
};

Expand Down
16 changes: 8 additions & 8 deletions subsys/dap/cmsis_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ static uint16_t dap_info(struct dap_context *const ctx,
case DAP_ID_VENDOR:
LOG_DBG("ID_VENDOR");
memcpy(info, CONFIG_CMSIS_DAP_PROBE_VENDOR, sizeof(CONFIG_CMSIS_DAP_PROBE_VENDOR));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_PROBE_VENDOR);
length = sizeof(CONFIG_CMSIS_DAP_PROBE_VENDOR);
break;
case DAP_ID_PRODUCT:
LOG_DBG("ID_PRODUCT");
memcpy(info, CONFIG_CMSIS_DAP_PROBE_NAME, sizeof(CONFIG_CMSIS_DAP_PROBE_NAME));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_PROBE_NAME);
length = sizeof(CONFIG_CMSIS_DAP_PROBE_NAME);
break;
case DAP_ID_SER_NUM:
/* optional to implement */
Expand All @@ -93,26 +93,26 @@ static uint16_t dap_info(struct dap_context *const ctx,
case DAP_ID_FW_VER:
LOG_DBG("ID_FW_VER");
memcpy(info, DAP_FW_VER, sizeof(DAP_FW_VER));
length = (uint8_t)sizeof(DAP_FW_VER);
length = sizeof(DAP_FW_VER);
break;
case DAP_ID_DEVICE_VENDOR:
LOG_DBG("ID_DEVICE_VENDOR");
memcpy(info, CONFIG_CMSIS_DAP_DEVICE_VENDOR, sizeof(CONFIG_CMSIS_DAP_DEVICE_VENDOR));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_DEVICE_VENDOR);
length = sizeof(CONFIG_CMSIS_DAP_DEVICE_VENDOR);
break;
case DAP_ID_DEVICE_NAME:
LOG_DBG("ID_DEVICE_NAME");
memcpy(info, CONFIG_CMSIS_DAP_DEVICE_NAME, sizeof(CONFIG_CMSIS_DAP_DEVICE_NAME));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_DEVICE_NAME);
length = sizeof(CONFIG_CMSIS_DAP_DEVICE_NAME);
break;
case DAP_ID_BOARD_VENDOR:
LOG_DBG("ID_BOARD_VENDOR");
memcpy(info, CONFIG_CMSIS_DAP_BOARD_VENDOR, sizeof(CONFIG_CMSIS_DAP_BOARD_VENDOR));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_BOARD_VENDOR);
length = sizeof(CONFIG_CMSIS_DAP_BOARD_VENDOR);
break;
case DAP_ID_BOARD_NAME:
memcpy(info, CONFIG_CMSIS_DAP_BOARD_NAME, sizeof(CONFIG_CMSIS_DAP_BOARD_NAME));
length = (uint8_t)sizeof(CONFIG_CMSIS_DAP_BOARD_NAME);
length = sizeof(CONFIG_CMSIS_DAP_BOARD_NAME);
LOG_DBG("ID_BOARD_NAME");
break;
case DAP_ID_PRODUCT_FW_VER:
Expand Down Expand Up @@ -151,7 +151,7 @@ static uint16_t dap_info(struct dap_context *const ctx,
break;
}

response[0] = (uint8_t)length;
response[0] = length;

return length + 1U;
}
Expand Down

0 comments on commit 00f8c5b

Please sign in to comment.