Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAP: add DAP_GetInterfaceCapabilities vendor command #931

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/dap_vendor_commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DAPLink CMSIS-DAP vendor commands
=================================

## DAP_GetInterfaceCapabilities

This command returns a vector of capability bits that indicate the presence or absence of features in DAPLink's interface firmware.

**Command ID**: 0x85 (`ID_DAP_Vendor5`)

**Request**

```
BYTE |
> 0x85 |
******|
```

**Response**

```
BYTE | BYTE | WORD |
< 0x85 | Len | Caps |
******|******|++++++|
```

After the command ID, the response contains () a single `Len` byte with the number of capability words. Following is an array of `Len` 32-bit words encoded as little endian.

**Capability bit definitions**

- [0] `kCapability_FileFormatBinary`: Programming of binary firmware files is supported.
- [1] `kCapability_FileFormatIntelHex`: Programming of Intel hex files is supported.
23 changes: 22 additions & 1 deletion source/daplink/cmsis-dap/DAP_vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,20 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
num += ((write_len + 1) << 16) | 1;
break;
}
case ID_DAP_Vendor5: break;
case ID_DAP_GetInterfaceCapabilities: {
// Response consists of a 1-byte count of capability words, followed by
// that number of 32-bit words encoded as little endian. Currently the
// capability word count will only ever be 1.
uint32_t caps = get_interface_capabilities();
*response++ = 1; // response word count
*response++ = (caps >> 0) & 0xff;
*response++ = (caps >> 8) & 0xff;
*response++ = (caps >> 16) & 0xff;
*response++ = (caps >> 24) & 0xff;
num += (0 << 16) // request bytes consumed
| (1 + sizeof(uint32_t)); // response bytes sent
break;
}
case ID_DAP_Vendor6: break;
case ID_DAP_Vendor7: break;
case ID_DAP_SetUSBTestMode: {
Expand Down Expand Up @@ -211,4 +224,12 @@ uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
return (num);
}

/*!
* @brief Return the DAPLink-specific capabilities of this firmware.
*/
__WEAK uint32_t get_interface_capabilities(void) {
return kCapability_FileFormatBinary
| kCapability_FileFormatIntelHex;
}

///@}
19 changes: 19 additions & 0 deletions source/daplink/cmsis-dap/daplink_vendor_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#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_GetInterfaceCapabilities ID_DAP_Vendor5
#define ID_DAP_SetUSBTestMode ID_DAP_Vendor8
#define ID_DAP_ResetTargetIfNoAutoReset ID_DAP_Vendor9
#define ID_DAP_MSD_Open ID_DAP_Vendor10
Expand All @@ -37,3 +38,21 @@
#define ID_DAP_SelectEraseMode ID_DAP_Vendor13
//@}

//! @brief DAP_GetInterfaceCapabilities capability definitions.
enum _interface_capabilities_definitions {
//! Supports binary file programming.
kCapability_FileFormatBinary = (1 << 0),
//! Supports Intel hex file programming.
kCapability_FileFormatIntelHex = (1 << 1),
};

#if defined(__cplusplus)
extern "C" {
#endif

// Return the interface firmware's capabilities vector.
uint32_t get_interface_capabilities(void);

#if defined(__cplusplus)
}
#endif