Skip to content

Commit

Permalink
feat: 实现CMSIS-DAP的一些接口 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfSweet authored Sep 23, 2024
1 parent 98883bb commit 02aa97e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions projects/HSLink-Pro/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ sdk_app_src(main.c)
sdk_app_src(dp_common.c)

if (CONFIG_BUILD_VERSION)
sdk_compile_definitions(-DDAP_FW_VER="2.1.1")
sdk_compile_definitions(-DCONFIG_BUILD_VERSION="${CONFIG_BUILD_VERSION}")
else ()
sdk_compile_definitions(-DDAP_FW_VER="Debug")
sdk_compile_definitions(-DCONFIG_BUILD_VERSION="Debug")
endif ()

sdk_app_src(USB2UART/usb2uart.c)
Expand All @@ -111,4 +111,4 @@ add_custom_command(
COMMENT "Convert to UF2"
)

#generate_ses_project()
generate_ide_projects()
18 changes: 12 additions & 6 deletions projects/HSLink-Pro/src/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,21 @@ static const char TargetBoardName [] = TARGET_BOARD_NAME;
\return String length (including terminating NULL character) or 0 (no string).
*/
__STATIC_INLINE uint8_t DAP_GetVendorString (char *str) {
(void)str;
return (0U);
const char vendor[] = "CherryUSB";
uint8_t len = (uint8_t)strlen(vendor);
memcpy(str, vendor, len);
return len;
}

/** Get Product Name string.
\param str Pointer to buffer to store the string (max 60 characters).
\return String length (including terminating NULL character) or 0 (no string).
*/
__STATIC_INLINE uint8_t DAP_GetProductString (char *str) {
(void)str;
return (0U);
const char product[] = "Cherry CMSIS-DAP";
uint8_t len = (uint8_t)strlen(product);
memcpy(str, product, len);
return len;
}

/** Get Serial Number string.
Expand Down Expand Up @@ -264,8 +268,10 @@ __STATIC_INLINE uint8_t DAP_GetTargetBoardNameString (char *str) {
\return String length (including terminating NULL character) or 0 (no string).
*/
__STATIC_INLINE uint8_t DAP_GetProductFirmwareVersionString (char *str) {
(void)str;
return (0U);
const char version[] = CONFIG_BUILD_VERSION;
uint8_t len = (uint8_t)strlen(version);
memcpy(str, version, len);
return len;
}

///@}
Expand Down
2 changes: 1 addition & 1 deletion projects/HSLink-Pro/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(void)

SWDIO_DIR_Init();

printf("version: %s\n", DAP_FW_VER);
printf("version: " CONFIG_BUILD_VERSION "\n");
extern char *string_descriptors[];
memcpy(string_descriptors[3], serial_number, 32);

Expand Down

0 comments on commit 02aa97e

Please sign in to comment.