* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <jtag/stlink/stlink_tcl.h>
#include <jtag/stlink/stlink_layout.h>
+#include <jtag/stlink/stlink_transport.h>
#include <jtag/stlink/stlink_interface.h>
#include <target/target.h>
-static struct stlink_interface_s stlink_if = { {0, 0, 0, 0}, 0, 0 };
+static struct stlink_interface_s stlink_if = { {0, 0, 0, 0, 0, 0}, 0, 0 };
-int stlink_interface_open(void)
+int stlink_interface_open(enum stlink_transports tr)
{
LOG_DEBUG("stlink_interface_open");
+ /* set transport mode */
+ stlink_if.param.transport = tr;
+
return stlink_if.layout->open(&stlink_if);
}
{
int res;
+ LOG_DEBUG("stlink_interface_init_target");
+
/* this is the interface for the current target and we
* can setup the private pointer in the tap structure
* if the interface match the tap idcode
for (ii = 0; ii < limit; ii++) {
uint32_t expected = t->tap->expected_ids[ii];
- if (t->tap->idcode == expected) {
+ /* treat "-expected-id 0" as a "don't-warn" wildcard */
+ if (!expected || (t->tap->idcode == expected)) {
found = 1;
break;
}
}
if (found == 0) {
- LOG_ERROR
- ("stlink_interface_init_target: target not found: idcode: %x ",
- t->tap->idcode);
+ LOG_ERROR("stlink_interface_init_target: target not found: idcode: 0x%08x",
+ t->tap->idcode);
return ERROR_FAIL;
}
return ERROR_OK;
}
+static int stlink_speed_div(int speed, int *khz)
+{
+ *khz = speed;
+ return ERROR_OK;
+}
+
+static int stlink_khz(int khz, int *jtag_speed)
+{
+ *jtag_speed = khz;
+ return ERROR_OK;
+}
+
static int stlink_interface_execute_queue(void)
{
LOG_DEBUG("stlink_interface_execute_queue: ignored");
return ERROR_OK;
}
+COMMAND_HANDLER(stlink_interface_handle_api_command)
+{
+ if (CMD_ARGC != 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ unsigned new_api;
+ COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], new_api);
+ if ((new_api == 0) || (new_api > 2))
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ stlink_if.param.api = new_api;
+
+ return ERROR_OK;
+}
+
static const struct command_registration stlink_interface_command_handlers[] = {
{
.name = "stlink_device_desc",
.help = "the vendor and product ID of the STLINK device",
.usage = "(vid pid)* ",
},
+ {
+ .name = "stlink_api",
+ .handler = &stlink_interface_handle_api_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set the desired stlink api level",
+ .usage = "api version 1 or 2",
+ },
COMMAND_REGISTRATION_DONE
};
.supported = 0,
.commands = stlink_interface_command_handlers,
.transports = stlink_transports,
-
.init = stlink_interface_init,
.quit = stlink_interface_quit,
.speed = stlink_interface_speed,
+ .speed_div = stlink_speed_div,
+ .khz = stlink_khz,
.execute_queue = stlink_interface_execute_queue,
};