bitq: reduce scope of variables
[openocd.git] / src / jtag / drivers / presto.c
index f4e689c2a527f7eb229ab517c184c362e518b88e..b23d196b9a3aa8edb619d90e3c7fb5732feab6b2 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
+/**
+ * @file
+ * Holds driver for PRESTO programmer from ASIX.
+ * http://tools.asix.net/prg_presto.htm
+ */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 #include "windows.h"
 #endif
 
-#include "interface.h"
-#include "time_support.h"
+#include <jtag/interface.h>
+#include <helper/time_support.h>
 #include "bitq.h"
 
 
 /* PRESTO access library includes */
 #if BUILD_PRESTO_FTD2XX == 1
 #include <ftd2xx.h>
+#include "ftd2xx_common.h"
 #elif BUILD_PRESTO_LIBFTDI == 1
 #include <ftdi.h>
 #else
@@ -96,7 +103,7 @@ static int presto_write(uint8_t *buf, uint32_t size)
        DWORD ftbytes;
        if ((presto->status = FT_Write(presto->handle, buf, size, &ftbytes)) != FT_OK)
        {
-               LOG_ERROR("FT_Write returned: %lu", presto->status);
+               LOG_ERROR("FT_Write returned: %s", ftd2xx_status_string(presto->status));
                return ERROR_JTAG_DEVICE_ERROR;
        }
 
@@ -126,7 +133,7 @@ static int presto_read(uint8_t* buf, uint32_t size)
        DWORD ftbytes;
        if ((presto->status = FT_Read(presto->handle, buf, size, &ftbytes)) != FT_OK)
        {
-               LOG_ERROR("FT_Read returned: %lu", presto->status);
+               LOG_ERROR("FT_Read returned: %s", ftd2xx_status_string(presto->status));
                return ERROR_JTAG_DEVICE_ERROR;
        }
 
@@ -188,17 +195,17 @@ static int presto_open_ftd2xx(char *req_serial)
 
        if ((presto->status = FT_ListDevices(&numdevs, NULL, FT_LIST_NUMBER_ONLY)) != FT_OK)
        {
-               LOG_ERROR("FT_ListDevices failed: %i", (int)presto->status);
+               LOG_ERROR("FT_ListDevices failed: %s", ftd2xx_status_string(presto->status));
                return ERROR_JTAG_DEVICE_ERROR;
        }
 
-       LOG_DEBUG("FTDI devices available: %lu", numdevs);
+       LOG_DEBUG("FTDI devices available: %" PRIu32, (uint32_t)numdevs);
        for (i = 0; i < numdevs; i++)
        {
                if ((presto->status = FT_Open(i, &(presto->handle))) != FT_OK)
                {
                        /* this is not fatal, the device may be legitimately open by other process, hence debug message only */
-                       LOG_DEBUG("FT_Open failed: %i", (int)presto->status);
+                       LOG_DEBUG("FT_Open failed: %s", ftd2xx_status_string(presto->status));
                        continue;
                }
                LOG_DEBUG("FTDI device %i open", (int)i);
@@ -211,7 +218,7 @@ static int presto_open_ftd2xx(char *req_serial)
                                break;
                }
                else
-                       LOG_DEBUG("FT_GetDeviceInfo failed: %lu", presto->status);
+                       LOG_DEBUG("FT_GetDeviceInfo failed: %s", ftd2xx_status_string(presto->status));
 
                LOG_DEBUG("FTDI device %i does not match, closing", (int)i);
                FT_Close(presto->handle);
@@ -398,7 +405,7 @@ static int presto_close(void)
        int result = ERROR_OK;
 
 #if BUILD_PRESTO_FTD2XX == 1
-       unsigned long ftbytes;
+       DWORD ftbytes;
 
        if (presto->handle == (FT_HANDLE)INVALID_HANDLE_VALUE)
                return result;
@@ -674,7 +681,7 @@ static struct bitq_interface presto_bitq = {
 
 /* -------------------------------------------------------------------------- */
 
-static int presto_jtag_khz(int khz, int *jtag_speed)
+static int presto_adapter_khz(int khz, int *jtag_speed)
 {
        if (khz < 0)
        {
@@ -742,10 +749,10 @@ COMMAND_HANDLER(presto_handle_serial_command)
 static const struct command_registration presto_command_handlers[] = {
        {
                .name = "presto_serial",
-               .handler = &presto_handle_serial_command,
+               .handler = presto_handle_serial_command,
                .mode = COMMAND_CONFIG,
-               .help = "configure serial port",
-               .usage = "<devname>",
+               .help = "Configure USB serial number of Presto device.",
+               .usage = "serial_string",
        },
        COMMAND_REGISTRATION_DONE
 };
@@ -763,9 +770,6 @@ static int presto_jtag_init(void)
        }
        LOG_INFO("PRESTO open, serial number '%s'", presto->serial);
 
-       /* use JTAG speed setting from configuration file */
-       presto_jtag_speed(jtag_get_speed());
-
        bitq_interface = &presto_bitq;
        return ERROR_OK;
 }
@@ -786,15 +790,13 @@ static int presto_jtag_quit(void)
 }
 
 struct jtag_interface presto_interface = {
-               .name = "presto",
-
-               .commands = presto_command_handlers,
-
-               .execute_queue = &bitq_execute_queue,
-               .speed = &presto_jtag_speed,
-               .khz = &presto_jtag_khz,
-               .speed_div = &presto_jtag_speed_div,
-
-               .init = &presto_jtag_init,
-               .quit = &presto_jtag_quit,
-       };
+       .name = "presto",
+       .commands = presto_command_handlers,
+
+       .execute_queue = bitq_execute_queue,
+       .speed = presto_jtag_speed,
+       .khz = presto_adapter_khz,
+       .speed_div = presto_jtag_speed_div,
+       .init = presto_jtag_init,
+       .quit = presto_jtag_quit,
+};

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)