OpenOCD
libjaylink.h
Go to the documentation of this file.
1 /*
2  * This file is part of the libjaylink project.
3  *
4  * Copyright (C) 2014-2016 Marc Schink <jaylink-dev@marcschink.de>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBJAYLINK_LIBJAYLINK_H
21 #define LIBJAYLINK_LIBJAYLINK_H
22 
23 #include <stddef.h>
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include <stdarg.h>
27 #ifdef _WIN32
28 #include <ws2tcpip.h>
29 #else
30 #include <arpa/inet.h>
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
64  JAYLINK_ERR_DEV = -1000,
71 };
72 
87 };
88 
90 #define JAYLINK_LOG_DOMAIN_DEFAULT "jaylink: "
91 
93 #define JAYLINK_LOG_DOMAIN_MAX_LENGTH 32
94 
99 };
100 
104  JAYLINK_HIF_USB = (1 << 0),
106  JAYLINK_HIF_TCP = (1 << 1)
107 };
108 
124 };
125 
160 };
161 
208 };
209 
219 };
220 
229 };
230 
243 };
244 
261 };
262 
267 };
268 
272  uint32_t freq;
274  uint16_t div;
275 };
276 
280  uint32_t freq;
282  uint32_t min_div;
284  uint32_t max_div;
286  uint32_t min_prescaler;
288  uint32_t max_prescaler;
289 };
290 
296  uint8_t major;
298  uint8_t minor;
300  uint8_t revision;
301 };
302 
306  uint16_t target_voltage;
308  bool tck;
310  bool tdi;
312  bool tdo;
314  bool tms;
316  bool tres;
318  bool trst;
319 };
320 
324  uint16_t handle;
331  uint32_t pid;
339  char hid[INET_ADDRSTRLEN];
341  uint8_t iid;
343  uint8_t cid;
349  uint32_t timestamp;
350 };
351 
353 #define JAYLINK_SPEED_ADAPTIVE_CLOCKING 0xffff
354 
356 #define JAYLINK_DEV_CONFIG_SIZE 256
357 
359 #define JAYLINK_DEV_CAPS_SIZE 4
360 
362 #define JAYLINK_DEV_EXT_CAPS_SIZE 32
363 
365 #define JAYLINK_MAX_CONNECTIONS 16
366 
368 #define JAYLINK_MAC_ADDRESS_LENGTH 6
369 
374 #define JAYLINK_NICKNAME_MAX_LENGTH 32
375 
380 #define JAYLINK_PRODUCT_NAME_MAX_LENGTH 32
381 
383 #define JAYLINK_FILE_NAME_MAX_LENGTH 255
384 
386 #define JAYLINK_FILE_MAX_TRANSFER_SIZE 0x100000
387 
394 #define JAYLINK_EMUCOM_CHANNEL_TIME 0x0
395 
402 #define JAYLINK_EMUCOM_CHANNEL_USER 0x10000
403 
409 struct jaylink_context;
410 
416 struct jaylink_device;
417 
423 struct jaylink_device_handle;
424 
426 #ifdef _WIN32
427 #define JAYLINK_API
428 #else
429 #define JAYLINK_API __attribute__ ((visibility ("default")))
430 #endif
431 
444 typedef int (*jaylink_log_callback)(const struct jaylink_context *ctx,
445  enum jaylink_log_level level, const char *format, va_list args,
446  void *user_data);
447 
448 /*--- core.c ----------------------------------------------------------------*/
449 
450 JAYLINK_API int jaylink_init(struct jaylink_context **ctx);
451 JAYLINK_API int jaylink_exit(struct jaylink_context *ctx);
453 
454 /*--- device.c --------------------------------------------------------------*/
455 
457  struct jaylink_device ***devs, size_t *count);
459  bool unref);
461  const struct jaylink_device *dev,
464  const struct jaylink_device *dev, uint32_t *serial_number);
466  const struct jaylink_device *dev,
467  enum jaylink_usb_address *address);
469  const struct jaylink_device *dev, uint8_t *bus,
470  uint8_t **ports, size_t *length);
472  const struct jaylink_device *dev, char *address);
474  const struct jaylink_device *dev, uint8_t *address);
476  const struct jaylink_device *dev,
477  struct jaylink_hardware_version *version);
479  const struct jaylink_device *dev, char *name);
481  char *nickname);
483  struct jaylink_device *dev);
485 JAYLINK_API int jaylink_open(struct jaylink_device *dev,
486  struct jaylink_device_handle **devh);
489  struct jaylink_device_handle *devh);
491  struct jaylink_device_handle *devh, char **version,
492  size_t *length);
494  uint32_t mask, uint32_t *info);
496  uint32_t mask, uint32_t *values);
498  struct jaylink_device_handle *devh,
499  struct jaylink_hardware_version *version);
501  struct jaylink_hardware_status *status);
503  uint8_t *caps);
505  uint8_t *caps);
507  uint32_t *size);
509  uint8_t *config);
511  const uint8_t *config);
514  struct jaylink_connection *connections, size_t *count);
516  const struct jaylink_connection *connection,
517  struct jaylink_connection *connections, size_t *count);
518 
519 /*--- discovery.c -----------------------------------------------------------*/
520 
522  uint32_t ifaces);
523 
524 /*--- emucom.c --------------------------------------------------------------*/
525 
527  uint32_t channel, uint8_t *buffer, uint32_t *length);
529  uint32_t channel, const uint8_t *buffer, uint32_t *length);
530 
531 /*--- error.c ---------------------------------------------------------------*/
532 
533 JAYLINK_API const char *jaylink_strerror(int error_code);
534 JAYLINK_API const char *jaylink_strerror_name(int error_code);
535 
536 /*--- fileio.c --------------------------------------------------------------*/
537 
539  const char *filename, uint8_t *buffer, uint32_t offset,
540  uint32_t *length);
542  const char *filename, const uint8_t *buffer, uint32_t offset,
543  uint32_t *length);
545  const char *filename, uint32_t *size);
547  const char *filename);
548 
549 /*--- jtag.c ----------------------------------------------------------------*/
550 
552  const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
553  uint16_t length, enum jaylink_jtag_version version);
556 
557 /*--- log.c -----------------------------------------------------------------*/
558 
560  enum jaylink_log_level level);
562  enum jaylink_log_level *level);
564  jaylink_log_callback callback, void *user_data);
566  const char *domain);
568  const struct jaylink_context *ctx);
569 
570 /*--- strutil.c -------------------------------------------------------------*/
571 
572 JAYLINK_API int jaylink_parse_serial_number(const char *str,
573  uint32_t *serial_number);
574 
575 /*--- swd.c -----------------------------------------------------------------*/
576 
578  const uint8_t *direction, const uint8_t *out, uint8_t *in,
579  uint16_t length);
580 
581 /*--- swo.c -----------------------------------------------------------------*/
582 
584  enum jaylink_swo_mode mode, uint32_t baudrate, uint32_t size);
587  uint8_t *buffer, uint32_t *length);
589  enum jaylink_swo_mode mode, struct jaylink_swo_speed *speed);
590 
591 /*--- target.c --------------------------------------------------------------*/
592 
594  uint16_t speed);
596  struct jaylink_speed *speed);
599  enum jaylink_target_interface *prev_iface);
601  struct jaylink_device_handle *devh, uint32_t *ifaces);
603  struct jaylink_device_handle *devh,
608  bool enable);
609 
610 /*--- util.c ----------------------------------------------------------------*/
611 
612 JAYLINK_API bool jaylink_has_cap(const uint8_t *caps, uint32_t cap);
613 
614 /*--- version.c -------------------------------------------------------------*/
615 
624 
625 #ifdef __cplusplus
626 }
627 #endif
628 
629 #include "version.h"
630 
631 #endif /* LIBJAYLINK_LIBJAYLINK_H */
static uint16_t direction
Definition: ftdi.c:130
int mask
Definition: esirisc.c:1709
const char * name
Definition: armv4_5.c:87
const char * type
Definition: arm_adi_v5.c:1078
static libusb_device ** devs
The usb device list.
Definition: libusb_helper.c:34
uint32_t offset
Definition: arm_cti.c:179
static struct ublast_lowlevel_priv info
enum arm_mode mode
Definition: armv4_5.c:288
Package and library version macros.
size_t size
Size of the control block search area.
Definition: rtt/rtt.c:37
static int count
Definition: helper/log.c:62