hosted/dap: Fixed the definiiton of dap_info, adding const-correctness
This commit is contained in:
parent
2f9d280e2a
commit
50ff4a2dbe
|
@ -67,15 +67,15 @@ static bool has_swd_sequence = false;
|
|||
int dap_init(bmp_info_t *info)
|
||||
{
|
||||
type = (info->in_ep && info->out_ep) ? CMSIS_TYPE_BULK : CMSIS_TYPE_HID;
|
||||
int size;
|
||||
|
||||
if (type == CMSIS_TYPE_HID) {
|
||||
DEBUG_INFO("Using hid transfer\n");
|
||||
if (hid_init())
|
||||
return -1;
|
||||
size = strlen(info->serial);
|
||||
|
||||
const size_t size = strlen(info->serial);
|
||||
wchar_t serial[64] = {0}, *wc = serial;
|
||||
for (int i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
*wc++ = info->serial[i];
|
||||
*wc = 0;
|
||||
/* Blacklist devices that do not work with 513 byte report length
|
||||
|
@ -105,7 +105,7 @@ int dap_init(bmp_info_t *info)
|
|||
out_ep = info->out_ep;
|
||||
}
|
||||
dap_disconnect();
|
||||
size = dap_info(DAP_INFO_FW_VER, buffer, sizeof(buffer));
|
||||
size_t size = dap_info(DAP_INFO_FW_VER, buffer, sizeof(buffer));
|
||||
if (size) {
|
||||
DEBUG_INFO("Ver %s, ", buffer);
|
||||
int major = -1, minor = -1, sub = -1;
|
||||
|
|
|
@ -252,16 +252,16 @@ void dap_swd_configure(uint8_t cfg)
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int dap_info(int info, uint8_t *data, int size)
|
||||
size_t dap_info(const dap_info_t info, uint8_t *const data, const size_t size)
|
||||
{
|
||||
uint8_t buf[256];
|
||||
int rsize;
|
||||
size_t rsize;
|
||||
|
||||
buf[0] = ID_DAP_INFO;
|
||||
buf[1] = info;
|
||||
dbg_dap_cmd(buf, sizeof(buf), 2);
|
||||
|
||||
rsize = (size < buf[0]) ? size : buf[0];
|
||||
rsize = size < buf[0] ? size : buf[0];
|
||||
memcpy(data, &buf[1], rsize);
|
||||
|
||||
if (rsize < size)
|
||||
|
|
|
@ -63,7 +63,7 @@ void dap_connect(bool jtag);
|
|||
void dap_disconnect(void);
|
||||
void dap_transfer_configure(uint8_t idle, uint16_t count, uint16_t retry);
|
||||
void dap_swd_configure(uint8_t cfg);
|
||||
int dap_info(int info, uint8_t *data, int size);
|
||||
size_t dap_info(dap_info_t info, uint8_t *data, size_t size);
|
||||
void dap_reset_target(void);
|
||||
void dap_nrst_set_val(bool assert);
|
||||
void dap_trst_reset(void);
|
||||
|
|
Loading…
Reference in New Issue