+// SPDX-License-Identifier: GPL-2.0-or-later
+
/***************************************************************************
* Copyright (C) 2016-2017 by Nuvoton *
* Zale Yu <cyyu@nuvoton.com> *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
/* project specific includes */
#include <helper/binarybuffer.h>
+#include <jtag/adapter.h>
#include <jtag/interface.h>
#include <jtag/hla/hla_layout.h>
#include <jtag/hla/hla_transport.h>
#include <hidapi.h>
-#define NULINK_READ_TIMEOUT 1000
+#include "libusb_helper.h"
+
+#define NULINK_READ_TIMEOUT LIBUSB_TIMEOUT_MS
#define NULINK_HID_MAX_SIZE (64)
#define NULINK2_HID_MAX_SIZE (1024)
/* the nulink only supports 8/32bit memory read/writes
* honour 32bit, all others will be handled as 8bit access */
if (size == 4) {
- /* When in jtag mode the nulink uses the auto-increment functinality.
+ /* When in jtag mode the nulink uses the auto-increment functionality.
* However it expects us to pass the data correctly, this includes
* alignment and any page boundaries. We already do this as part of the
* adi_v5 implementation, but the nulink is a hla adapter and so this
- * needs implementiong manually.
+ * needs implementing manually.
* currently this only affects jtag mode, they do single
* access in SWD mode - but this may change and so we do it for both modes */
/* the nulink only supports 8/32bit memory read/writes
* honour 32bit, all others will be handled as 8bit access */
if (size == 4) {
- /* When in jtag mode the nulink uses the auto-increment functinality.
+ /* When in jtag mode the nulink uses the auto-increment functionality.
* However it expects us to pass the data correctly, this includes
* alignment and any page boundaries. We already do this as part of the
* adi_v5 implementation, but the nulink is a hla adapter and so this
- * needs implementiong manually.
+ * needs implementing manually.
* currently this only affects jtag mode, do single
* access in SWD mode - but this may change and so we do it for both modes */
goto error_open;
}
- if (param->serial) {
- size_t len = mbstowcs(NULL, param->serial, 0);
+ const char *serial = adapter_get_required_serial();
+ if (serial) {
+ size_t len = mbstowcs(NULL, serial, 0);
target_serial = calloc(len + 1, sizeof(wchar_t));
if (!target_serial) {
goto error_open;
}
- if (mbstowcs(target_serial, param->serial, len + 1) == (size_t)(-1)) {
+ if (mbstowcs(target_serial, serial, len + 1) == (size_t)(-1)) {
LOG_WARNING("unable to convert serial");
free(target_serial);
target_serial = NULL;