libjaylink  0.5.0
Library to access J-Link devices
libjaylink.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 
3 #ifndef LIBJAYLINK_LIBJAYLINK_H
4 #define LIBJAYLINK_LIBJAYLINK_H
5 
6 #include <stddef.h>
7 #include <stdint.h>
8 #include <stdbool.h>
9 #include <stdarg.h>
10 #ifdef _WIN32
11 #include <ws2tcpip.h>
12 #else
13 #include <arpa/inet.h>
14 #endif
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
47  JAYLINK_ERR_DEV = -1000,
54 };
55 
70 };
71 
73 #define JAYLINK_LOG_DOMAIN_DEFAULT "jaylink: "
74 
76 #define JAYLINK_LOG_DOMAIN_MAX_LENGTH 32
77 
82 };
83 
87  JAYLINK_HIF_USB = (1 << 0),
89  JAYLINK_HIF_TCP = (1 << 1)
90 };
91 
107 };
108 
147 };
148 
196  JAYLINK_HW_INFO_VUSB = (1 << 23),
197 };
198 
208 };
209 
218 };
219 
238 };
239 
256 };
257 
262 };
263 
278 };
279 
283  uint32_t freq;
285  uint16_t div;
286 };
287 
291  uint32_t freq;
293  uint32_t min_div;
295  uint32_t max_div;
297  uint32_t min_prescaler;
299  uint32_t max_prescaler;
300 };
301 
307  uint8_t major;
309  uint8_t minor;
311  uint8_t revision;
312 };
313 
317  uint16_t target_voltage;
319  bool tck;
321  bool tdi;
323  bool tdo;
325  bool tms;
327  bool tres;
329  bool trst;
330 };
331 
335  uint16_t handle;
342  uint32_t pid;
350  char hid[INET_ADDRSTRLEN];
352  uint8_t iid;
354  uint8_t cid;
360  uint32_t timestamp;
361 };
362 
364 #define JAYLINK_SPEED_ADAPTIVE_CLOCKING 0xffff
365 
367 #define JAYLINK_DEV_CONFIG_SIZE 256
368 
370 #define JAYLINK_DEV_CAPS_SIZE 4
371 
373 #define JAYLINK_DEV_EXT_CAPS_SIZE 32
374 
376 #define JAYLINK_MAX_CONNECTIONS 16
377 
379 #define JAYLINK_MAC_ADDRESS_LENGTH 6
380 
385 #define JAYLINK_NICKNAME_MAX_LENGTH 32
386 
391 #define JAYLINK_PRODUCT_NAME_MAX_LENGTH 32
392 
394 #define JAYLINK_FILE_NAME_MAX_LENGTH 255
395 
397 #define JAYLINK_FILE_MAX_TRANSFER_SIZE 0x100000
398 
405 #define JAYLINK_EMUCOM_CHANNEL_TIME 0x0
406 
413 #define JAYLINK_EMUCOM_CHANNEL_USER 0x10000
414 
416 #define JAYLINK_C2_MAX_LENGTH 64
417 
424 
431 
437 struct jaylink_device_handle;
438 
440 #if defined(_WIN32) || defined(__MSYS__) || defined(__CYGWIN__)
441 #define JAYLINK_API
442 #else
443 #define JAYLINK_API __attribute__ ((visibility ("default")))
444 #endif
445 
458 typedef int (*jaylink_log_callback)(const struct jaylink_context *ctx,
459  enum jaylink_log_level level, const char *format, va_list args,
460  void *user_data);
461 
462 /*--- core.c ----------------------------------------------------------------*/
463 
464 JAYLINK_API int jaylink_init(struct jaylink_context **ctx);
465 JAYLINK_API int jaylink_exit(struct jaylink_context *ctx);
467 
468 /*--- c2.c ------------------------------------------------------------------*/
469 
471  uint8_t *address);
473  uint8_t address);
475  uint8_t *data, uint8_t length);
477  const uint8_t *data, uint8_t length);
478 
479 /*--- device.c --------------------------------------------------------------*/
480 
482  struct jaylink_device ***devs, size_t *count);
484  bool unref);
486  const struct jaylink_device *dev,
487  enum jaylink_host_interface *iface);
489  const struct jaylink_device *dev, uint32_t *serial_number);
491  const struct jaylink_device *dev,
492  enum jaylink_usb_address *address);
494  const struct jaylink_device *dev, uint8_t *bus,
495  uint8_t **ports, size_t *length);
497  const struct jaylink_device *dev, char *address);
499  const struct jaylink_device *dev, uint8_t *address);
501  const struct jaylink_device *dev,
502  struct jaylink_hardware_version *version);
504  const struct jaylink_device *dev, char *name);
506  char *nickname);
508  struct jaylink_device *dev);
510 JAYLINK_API int jaylink_open(struct jaylink_device *dev,
511  struct jaylink_device_handle **devh);
514  struct jaylink_device_handle *devh);
516  struct jaylink_device_handle *devh, char **version,
517  size_t *length);
519  uint32_t mask, uint32_t *info);
521  uint32_t mask, uint32_t *values);
523  struct jaylink_device_handle *devh,
524  struct jaylink_hardware_version *version);
526  struct jaylink_hardware_status *status);
528  uint8_t *caps);
530  uint8_t *caps);
532  uint32_t *size);
534  uint8_t *config);
536  const uint8_t *config);
538  struct jaylink_connection *connection,
539  struct jaylink_connection *connections, size_t *count);
541  const struct jaylink_connection *connection,
542  struct jaylink_connection *connections, size_t *count);
543 
544 /*--- discovery.c -----------------------------------------------------------*/
545 
547  uint32_t ifaces);
548 
549 /*--- emucom.c --------------------------------------------------------------*/
550 
552  uint32_t channel, uint8_t *buffer, uint32_t *length);
554  uint32_t channel, const uint8_t *buffer, uint32_t *length);
555 
556 /*--- error.c ---------------------------------------------------------------*/
557 
558 JAYLINK_API const char *jaylink_strerror(int error_code);
559 JAYLINK_API const char *jaylink_strerror_name(int error_code);
560 
561 /*--- fileio.c --------------------------------------------------------------*/
562 
564  const char *filename, uint8_t *buffer, uint32_t offset,
565  uint32_t *length);
567  const char *filename, const uint8_t *buffer, uint32_t offset,
568  uint32_t *length);
570  const char *filename, uint32_t *size);
572  const char *filename);
573 
574 /*--- jtag.c ----------------------------------------------------------------*/
575 
577  const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
578  uint16_t length, enum jaylink_jtag_version version);
585 
586 /*--- log.c -----------------------------------------------------------------*/
587 
589  enum jaylink_log_level level);
591  enum jaylink_log_level *level);
593  jaylink_log_callback callback, void *user_data);
595  const char *domain);
597  const struct jaylink_context *ctx);
598 
599 /*--- spi.c -----------------------------------------------------------------*/
600 
602  const uint8_t *mosi, uint8_t *miso, uint32_t length,
603  uint32_t flags);
604 
605 /*--- strutil.c -------------------------------------------------------------*/
606 
607 JAYLINK_API int jaylink_parse_serial_number(const char *str,
608  uint32_t *serial_number);
610  enum jaylink_hardware_type type);
612  enum jaylink_target_interface iface);
613 
614 /*--- swd.c -----------------------------------------------------------------*/
615 
617  const uint8_t *direction, const uint8_t *out, uint8_t *in,
618  uint16_t length);
619 
620 /*--- swo.c -----------------------------------------------------------------*/
621 
623  enum jaylink_swo_mode mode, uint32_t baudrate, uint32_t size);
626  uint8_t *buffer, uint32_t *length);
628  enum jaylink_swo_mode mode, struct jaylink_swo_speed *speed);
629 
630 /*--- target.c --------------------------------------------------------------*/
631 
633  uint16_t speed);
635  struct jaylink_speed *speed);
637  enum jaylink_target_interface iface,
638  enum jaylink_target_interface *prev_iface);
640  struct jaylink_device_handle *devh, uint32_t *ifaces);
642  struct jaylink_device_handle *devh,
643  enum jaylink_target_interface *iface);
647  bool enable);
648 
649 /*--- util.c ----------------------------------------------------------------*/
650 
651 JAYLINK_API bool jaylink_has_cap(const uint8_t *caps, uint32_t cap);
652 
653 /*--- version.c -------------------------------------------------------------*/
654 
663 
664 #ifdef __cplusplus
665 }
666 #endif
667 
668 #include "version.h"
669 
670 #endif /* LIBJAYLINK_LIBJAYLINK_H */
Package and library version macros.