libjaylink  0.3.1
Library to access J-Link devices
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 
162 };
163 
211  JAYLINK_HW_INFO_VUSB = (1 << 23),
212 };
213 
223 };
224 
233 };
234 
253 };
254 
271 };
272 
277 };
278 
293 };
294 
298  uint32_t freq;
300  uint16_t div;
301 };
302 
306  uint32_t freq;
308  uint32_t min_div;
310  uint32_t max_div;
312  uint32_t min_prescaler;
314  uint32_t max_prescaler;
315 };
316 
322  uint8_t major;
324  uint8_t minor;
326  uint8_t revision;
327 };
328 
332  uint16_t target_voltage;
334  bool tck;
336  bool tdi;
338  bool tdo;
340  bool tms;
342  bool tres;
344  bool trst;
345 };
346 
350  uint16_t handle;
357  uint32_t pid;
365  char hid[INET_ADDRSTRLEN];
367  uint8_t iid;
369  uint8_t cid;
375  uint32_t timestamp;
376 };
377 
379 #define JAYLINK_SPEED_ADAPTIVE_CLOCKING 0xffff
380 
382 #define JAYLINK_DEV_CONFIG_SIZE 256
383 
385 #define JAYLINK_DEV_CAPS_SIZE 4
386 
388 #define JAYLINK_DEV_EXT_CAPS_SIZE 32
389 
391 #define JAYLINK_MAX_CONNECTIONS 16
392 
394 #define JAYLINK_MAC_ADDRESS_LENGTH 6
395 
400 #define JAYLINK_NICKNAME_MAX_LENGTH 32
401 
406 #define JAYLINK_PRODUCT_NAME_MAX_LENGTH 32
407 
409 #define JAYLINK_FILE_NAME_MAX_LENGTH 255
410 
412 #define JAYLINK_FILE_MAX_TRANSFER_SIZE 0x100000
413 
420 #define JAYLINK_EMUCOM_CHANNEL_TIME 0x0
421 
428 #define JAYLINK_EMUCOM_CHANNEL_USER 0x10000
429 
431 #define JAYLINK_C2_MAX_LENGTH 64
432 
439 
446 
452 struct jaylink_device_handle;
453 
455 #ifdef _WIN32
456 #define JAYLINK_API
457 #else
458 #define JAYLINK_API __attribute__ ((visibility ("default")))
459 #endif
460 
473 typedef int (*jaylink_log_callback)(const struct jaylink_context *ctx,
474  enum jaylink_log_level level, const char *format, va_list args,
475  void *user_data);
476 
477 /*--- core.c ----------------------------------------------------------------*/
478 
479 JAYLINK_API int jaylink_init(struct jaylink_context **ctx);
480 JAYLINK_API int jaylink_exit(struct jaylink_context *ctx);
482 
483 /*--- c2.c ------------------------------------------------------------------*/
484 
486  uint8_t *address);
488  uint8_t address);
490  uint8_t *data, uint8_t length);
492  const uint8_t *data, uint8_t length);
493 
494 /*--- device.c --------------------------------------------------------------*/
495 
497  struct jaylink_device ***devs, size_t *count);
499  bool unref);
501  const struct jaylink_device *dev,
502  enum jaylink_host_interface *iface);
504  const struct jaylink_device *dev, uint32_t *serial_number);
506  const struct jaylink_device *dev,
507  enum jaylink_usb_address *address);
509  const struct jaylink_device *dev, uint8_t *bus,
510  uint8_t **ports, size_t *length);
512  const struct jaylink_device *dev, char *address);
514  const struct jaylink_device *dev, uint8_t *address);
516  const struct jaylink_device *dev,
517  struct jaylink_hardware_version *version);
519  const struct jaylink_device *dev, char *name);
521  char *nickname);
523  struct jaylink_device *dev);
525 JAYLINK_API int jaylink_open(struct jaylink_device *dev,
526  struct jaylink_device_handle **devh);
529  struct jaylink_device_handle *devh);
531  struct jaylink_device_handle *devh, char **version,
532  size_t *length);
534  uint32_t mask, uint32_t *info);
536  uint32_t mask, uint32_t *values);
538  struct jaylink_device_handle *devh,
539  struct jaylink_hardware_version *version);
541  struct jaylink_hardware_status *status);
543  uint8_t *caps);
545  uint8_t *caps);
547  uint32_t *size);
549  uint8_t *config);
551  const uint8_t *config);
553  struct jaylink_connection *connection,
554  struct jaylink_connection *connections, size_t *count);
556  const struct jaylink_connection *connection,
557  struct jaylink_connection *connections, size_t *count);
558 
559 /*--- discovery.c -----------------------------------------------------------*/
560 
562  uint32_t ifaces);
563 
564 /*--- emucom.c --------------------------------------------------------------*/
565 
567  uint32_t channel, uint8_t *buffer, uint32_t *length);
569  uint32_t channel, const uint8_t *buffer, uint32_t *length);
570 
571 /*--- error.c ---------------------------------------------------------------*/
572 
573 JAYLINK_API const char *jaylink_strerror(int error_code);
574 JAYLINK_API const char *jaylink_strerror_name(int error_code);
575 
576 /*--- fileio.c --------------------------------------------------------------*/
577 
579  const char *filename, uint8_t *buffer, uint32_t offset,
580  uint32_t *length);
582  const char *filename, const uint8_t *buffer, uint32_t offset,
583  uint32_t *length);
585  const char *filename, uint32_t *size);
587  const char *filename);
588 
589 /*--- jtag.c ----------------------------------------------------------------*/
590 
592  const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo,
593  uint16_t length, enum jaylink_jtag_version version);
600 
601 /*--- log.c -----------------------------------------------------------------*/
602 
604  enum jaylink_log_level level);
606  enum jaylink_log_level *level);
608  jaylink_log_callback callback, void *user_data);
610  const char *domain);
612  const struct jaylink_context *ctx);
613 
614 /*--- spi.c -----------------------------------------------------------------*/
615 
617  const uint8_t *mosi, uint8_t *miso, uint32_t length,
618  uint32_t flags);
619 
620 /*--- strutil.c -------------------------------------------------------------*/
621 
622 JAYLINK_API int jaylink_parse_serial_number(const char *str,
623  uint32_t *serial_number);
625  enum jaylink_hardware_type type);
627  enum jaylink_target_interface iface);
628 
629 /*--- swd.c -----------------------------------------------------------------*/
630 
632  const uint8_t *direction, const uint8_t *out, uint8_t *in,
633  uint16_t length);
634 
635 /*--- swo.c -----------------------------------------------------------------*/
636 
638  enum jaylink_swo_mode mode, uint32_t baudrate, uint32_t size);
641  uint8_t *buffer, uint32_t *length);
643  enum jaylink_swo_mode mode, struct jaylink_swo_speed *speed);
644 
645 /*--- target.c --------------------------------------------------------------*/
646 
648  uint16_t speed);
650  struct jaylink_speed *speed);
652  enum jaylink_target_interface iface,
653  enum jaylink_target_interface *prev_iface);
655  struct jaylink_device_handle *devh, uint32_t *ifaces);
657  struct jaylink_device_handle *devh,
658  enum jaylink_target_interface *iface);
662  bool enable);
663 
664 /*--- util.c ----------------------------------------------------------------*/
665 
666 JAYLINK_API bool jaylink_has_cap(const uint8_t *caps, uint32_t cap);
667 
668 /*--- version.c -------------------------------------------------------------*/
669 
678 
679 #ifdef __cplusplus
680 }
681 #endif
682 
683 #include "version.h"
684 
685 #endif /* LIBJAYLINK_LIBJAYLINK_H */
Package and library version macros.