CMSIS-DAP: Run time detect DAP_SWD_SEQUENCE
Some dongles in the making like orbtrace may not yet support.
This commit is contained in:
parent
88e44d1c12
commit
07b4e5726e
@ -251,14 +251,14 @@ int dbg_dap_cmd(uint8_t *data, int size, int rsize)
|
|||||||
}
|
}
|
||||||
res = transferred;
|
res = transferred;
|
||||||
}
|
}
|
||||||
if (buffer[0] != cmd) {
|
|
||||||
DEBUG_WARN("cmd %02x invalid response received %02x\n",
|
|
||||||
cmd, buffer[0]);
|
|
||||||
}
|
|
||||||
DEBUG_WIRE("cmd res:");
|
DEBUG_WIRE("cmd res:");
|
||||||
for(int i = 0; (i < 16) && (i < size + 1); i++)
|
for(int i = 0; (i < 16) && (i < size + 1); i++)
|
||||||
DEBUG_WIRE("%02x.", buffer[i]);
|
DEBUG_WIRE("%02x.", buffer[i]);
|
||||||
DEBUG_WIRE("\n");
|
DEBUG_WIRE("\n");
|
||||||
|
if (buffer[0] != cmd) {
|
||||||
|
DEBUG_WARN("cmd %02x not implemented\n", cmd);
|
||||||
|
buffer[1] = 0xff /*DAP_ERROR*/;
|
||||||
|
}
|
||||||
if (size)
|
if (size)
|
||||||
memcpy(data, &buffer[1], (size < res) ? size : res);
|
memcpy(data, &buffer[1], (size < res) ? size : res);
|
||||||
return res;
|
return res;
|
||||||
@ -453,7 +453,7 @@ int dap_swdptap_init(ADIv5_DP_t *dp)
|
|||||||
dap_connect(false);
|
dap_connect(false);
|
||||||
dap_led(0, 1);
|
dap_led(0, 1);
|
||||||
dap_reset_link(false);
|
dap_reset_link(false);
|
||||||
if (has_swd_sequence) {
|
if ((has_swd_sequence) && dap_sequence_test()) {
|
||||||
/* DAP_SWD_SEQUENCE does not do auto turnaround, use own!*/
|
/* DAP_SWD_SEQUENCE does not do auto turnaround, use own!*/
|
||||||
dp->dp_low_write = dap_dp_low_write;
|
dp->dp_low_write = dap_dp_low_write;
|
||||||
} else {
|
} else {
|
||||||
|
@ -793,6 +793,17 @@ void dap_swdptap_seq_out_parity(uint32_t MS, int ticks)
|
|||||||
DEBUG_WARN("dap_swdptap_seq_out error\n");
|
DEBUG_WARN("dap_swdptap_seq_out error\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dap_sequence_test(void)
|
||||||
|
{
|
||||||
|
uint8_t buf[4] = {
|
||||||
|
ID_DAP_SWD_SEQUENCE,
|
||||||
|
1,
|
||||||
|
0 /* one idle cycle */
|
||||||
|
};
|
||||||
|
dbg_dap_cmd(buf, sizeof(buf), 3);
|
||||||
|
return (buf[0] == DAP_OK);
|
||||||
|
}
|
||||||
|
|
||||||
#define SWD_SEQUENCE_IN 0x80
|
#define SWD_SEQUENCE_IN 0x80
|
||||||
uint32_t dap_swdptap_seq_in(int ticks)
|
uint32_t dap_swdptap_seq_in(int ticks)
|
||||||
{
|
{
|
||||||
|
@ -93,4 +93,5 @@ void dap_jtagtap_tdi_tdo_seq(uint8_t *DO, bool final_tms, const uint8_t *TMS,
|
|||||||
int dap_jtag_configure(void);
|
int dap_jtag_configure(void);
|
||||||
void dap_swdptap_seq_out(uint32_t MS, int ticks);
|
void dap_swdptap_seq_out(uint32_t MS, int ticks);
|
||||||
void dap_swdptap_seq_out_parity(uint32_t MS, int ticks);
|
void dap_swdptap_seq_out_parity(uint32_t MS, int ticks);
|
||||||
|
bool dap_sequence_test(void);
|
||||||
#endif // _DAP_H_
|
#endif // _DAP_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user