libjaylink
0.3.1
Library to access J-Link devices
|
Public libjaylink header file to be used by applications. More...
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include "version.h"
Go to the source code of this file.
Data Structures | |
struct | jaylink_speed |
Target interface speed information. More... | |
struct | jaylink_swo_speed |
Serial Wire Output (SWO) speed information. More... | |
struct | jaylink_hardware_version |
Device hardware version. More... | |
struct | jaylink_hardware_status |
Device hardware status. More... | |
struct | jaylink_connection |
Device connection. More... | |
Macros | |
#define | JAYLINK_LOG_DOMAIN_DEFAULT "jaylink: " |
Default libjaylink log domain. More... | |
#define | JAYLINK_LOG_DOMAIN_MAX_LENGTH 32 |
Maximum length of a libjaylink log domain in bytes. More... | |
#define | JAYLINK_SPEED_ADAPTIVE_CLOCKING 0xffff |
Target interface speed value for adaptive clocking. More... | |
#define | JAYLINK_DEV_CONFIG_SIZE 256 |
Size of the device configuration data in bytes. More... | |
#define | JAYLINK_DEV_CAPS_SIZE 4 |
Number of bytes required to store device capabilities. More... | |
#define | JAYLINK_DEV_EXT_CAPS_SIZE 32 |
Number of bytes required to store extended device capabilities. More... | |
#define | JAYLINK_MAX_CONNECTIONS 16 |
Maximum number of connections that can be registered on a device. More... | |
#define | JAYLINK_MAC_ADDRESS_LENGTH 6 |
Media Access Control (MAC) address length in bytes. More... | |
#define | JAYLINK_NICKNAME_MAX_LENGTH 32 |
Maximum length of a device's nickname including trailing null-terminator in bytes. | |
#define | JAYLINK_PRODUCT_NAME_MAX_LENGTH 32 |
Maximum length of a device's product name including trailing null-terminator in bytes. | |
#define | JAYLINK_FILE_NAME_MAX_LENGTH 255 |
Maximum length of a filename in bytes. More... | |
#define | JAYLINK_FILE_MAX_TRANSFER_SIZE 0x100000 |
Maximum transfer size for a file in bytes. More... | |
#define | JAYLINK_EMUCOM_CHANNEL_TIME 0x0 |
EMUCOM channel with the system time of the device in milliseconds. More... | |
#define | JAYLINK_EMUCOM_CHANNEL_USER 0x10000 |
Offset of EMUCOM user channels. More... | |
#define | JAYLINK_C2_MAX_LENGTH 64 |
Maximum length of a 2-wire (C2) interface data transfer. More... | |
#define | JAYLINK_API __attribute__ ((visibility ("default"))) |
Macro to mark public libjaylink API symbol. More... | |
Typedefs | |
typedef int(* | jaylink_log_callback) (const struct jaylink_context *ctx, enum jaylink_log_level level, const char *format, va_list args, void *user_data) |
Log callback function type. More... | |
Functions | |
int | jaylink_init (struct jaylink_context **ctx) |
Initialize libjaylink. More... | |
int | jaylink_exit (struct jaylink_context *ctx) |
Shutdown libjaylink. More... | |
bool | jaylink_library_has_cap (enum jaylink_capability cap) |
Check for a capability of libjaylink. More... | |
int | jaylink_c2_read_address (struct jaylink_device_handle *devh, uint8_t *address) |
Read the C2 address register. More... | |
int | jaylink_c2_write_address (struct jaylink_device_handle *devh, uint8_t address) |
Write to the C2 address register. More... | |
int | jaylink_c2_read_data (struct jaylink_device_handle *devh, uint8_t *data, uint8_t length) |
Read the C2 data register. More... | |
int | jaylink_c2_write_data (struct jaylink_device_handle *devh, const uint8_t *data, uint8_t length) |
Write to the C2 data register. More... | |
int | jaylink_get_devices (struct jaylink_context *ctx, struct jaylink_device ***devs, size_t *count) |
Get available devices. More... | |
void | jaylink_free_devices (struct jaylink_device **devs, bool unref) |
Free devices. More... | |
int | jaylink_device_get_host_interface (const struct jaylink_device *dev, enum jaylink_host_interface *iface) |
Get the host interface of a device. More... | |
int | jaylink_device_get_serial_number (const struct jaylink_device *dev, uint32_t *serial_number) |
Get the serial number of a device. More... | |
int | jaylink_device_get_usb_address (const struct jaylink_device *dev, enum jaylink_usb_address *address) |
Get the USB address of a device. More... | |
int | jaylink_device_get_usb_bus_ports (const struct jaylink_device *dev, uint8_t *bus, uint8_t **ports, size_t *length) |
Get the USB bus and port numbers of a device. More... | |
int | jaylink_device_get_ipv4_address (const struct jaylink_device *dev, char *address) |
Get the IPv4 address string of a device. More... | |
int | jaylink_device_get_mac_address (const struct jaylink_device *dev, uint8_t *address) |
Get the MAC address of a device. More... | |
int | jaylink_device_get_hardware_version (const struct jaylink_device *dev, struct jaylink_hardware_version *version) |
Get the hardware version of a device. More... | |
int | jaylink_device_get_product_name (const struct jaylink_device *dev, char *name) |
Get the product name of a device. More... | |
int | jaylink_device_get_nickname (const struct jaylink_device *dev, char *nickname) |
Get the nickname of a device. More... | |
struct jaylink_device * | jaylink_ref_device (struct jaylink_device *dev) |
Increment the reference count of a device. More... | |
void | jaylink_unref_device (struct jaylink_device *dev) |
Decrement the reference count of a device. More... | |
int | jaylink_open (struct jaylink_device *dev, struct jaylink_device_handle **devh) |
Open a device. More... | |
int | jaylink_close (struct jaylink_device_handle *devh) |
Close a device. More... | |
struct jaylink_device * | jaylink_get_device (struct jaylink_device_handle *devh) |
Get the device instance from a device handle. More... | |
int | jaylink_get_firmware_version (struct jaylink_device_handle *devh, char **version, size_t *length) |
Retrieve the firmware version of a device. More... | |
int | jaylink_get_hardware_info (struct jaylink_device_handle *devh, uint32_t mask, uint32_t *info) |
Retrieve the hardware information of a device. More... | |
int | jaylink_get_counters (struct jaylink_device_handle *devh, uint32_t mask, uint32_t *values) |
Retrieve the counter values of a device. More... | |
int | jaylink_get_hardware_version (struct jaylink_device_handle *devh, struct jaylink_hardware_version *version) |
Retrieve the hardware version of a device. More... | |
int | jaylink_get_hardware_status (struct jaylink_device_handle *devh, struct jaylink_hardware_status *status) |
Retrieve the hardware status of a device. More... | |
int | jaylink_get_caps (struct jaylink_device_handle *devh, uint8_t *caps) |
Retrieve the capabilities of a device. More... | |
int | jaylink_get_extended_caps (struct jaylink_device_handle *devh, uint8_t *caps) |
Retrieve the extended capabilities of a device. More... | |
int | jaylink_get_free_memory (struct jaylink_device_handle *devh, uint32_t *size) |
Retrieve the size of free memory of a device. More... | |
int | jaylink_read_raw_config (struct jaylink_device_handle *devh, uint8_t *config) |
Read the raw configuration data of a device. More... | |
int | jaylink_write_raw_config (struct jaylink_device_handle *devh, const uint8_t *config) |
Write the raw configuration data of a device. More... | |
int | jaylink_register (struct jaylink_device_handle *devh, struct jaylink_connection *connection, struct jaylink_connection *connections, size_t *count) |
Register a connection on a device. More... | |
int | jaylink_unregister (struct jaylink_device_handle *devh, const struct jaylink_connection *connection, struct jaylink_connection *connections, size_t *count) |
Unregister a connection from a device. More... | |
int | jaylink_discovery_scan (struct jaylink_context *ctx, uint32_t ifaces) |
Scan for devices. More... | |
int | jaylink_emucom_read (struct jaylink_device_handle *devh, uint32_t channel, uint8_t *buffer, uint32_t *length) |
Read from an EMUCOM channel. More... | |
int | jaylink_emucom_write (struct jaylink_device_handle *devh, uint32_t channel, const uint8_t *buffer, uint32_t *length) |
Write to an EMUCOM channel. More... | |
const char * | jaylink_strerror (int error_code) |
Return a human-readable description of a libjaylink error code. More... | |
const char * | jaylink_strerror_name (int error_code) |
Return the name of a libjaylink error code. More... | |
int | jaylink_file_read (struct jaylink_device_handle *devh, const char *filename, uint8_t *buffer, uint32_t offset, uint32_t *length) |
Read from a file. More... | |
int | jaylink_file_write (struct jaylink_device_handle *devh, const char *filename, const uint8_t *buffer, uint32_t offset, uint32_t *length) |
Write to a file. More... | |
int | jaylink_file_get_size (struct jaylink_device_handle *devh, const char *filename, uint32_t *size) |
Retrieve the size of a file. More... | |
int | jaylink_file_delete (struct jaylink_device_handle *devh, const char *filename) |
Delete a file. More... | |
int | jaylink_jtag_io (struct jaylink_device_handle *devh, const uint8_t *tms, const uint8_t *tdi, uint8_t *tdo, uint16_t length, enum jaylink_jtag_version version) |
Perform a JTAG I/O operation. More... | |
int | jaylink_jtag_clear_trst (struct jaylink_device_handle *devh) |
Clear the JTAG test reset (TRST) signal. More... | |
int | jaylink_jtag_set_trst (struct jaylink_device_handle *devh) |
Set the JTAG test reset (TRST) signal. More... | |
int | jaylink_jtag_clear_tms (struct jaylink_device_handle *devh) |
Clear the JTAG test mode select (TMS) signal. More... | |
int | jaylink_jtag_set_tms (struct jaylink_device_handle *devh) |
Set the JTAG test mode select (TMS) signal. More... | |
int | jaylink_jtag_clear_tck (struct jaylink_device_handle *devh) |
Clear the JTAG test clock (TCK) signal. More... | |
int | jaylink_jtag_set_tck (struct jaylink_device_handle *devh) |
Set the JTAG test clock (TCK) signal. More... | |
int | jaylink_log_set_level (struct jaylink_context *ctx, enum jaylink_log_level level) |
Set the libjaylink log level. More... | |
int | jaylink_log_get_level (const struct jaylink_context *ctx, enum jaylink_log_level *level) |
Get the libjaylink log level. More... | |
int | jaylink_log_set_callback (struct jaylink_context *ctx, jaylink_log_callback callback, void *user_data) |
Set the libjaylink log callback function. More... | |
int | jaylink_log_set_domain (struct jaylink_context *ctx, const char *domain) |
Set the libjaylink log domain. More... | |
const char * | jaylink_log_get_domain (const struct jaylink_context *ctx) |
Get the libjaylink log domain. More... | |
int | jaylink_spi_io (struct jaylink_device_handle *devh, const uint8_t *mosi, uint8_t *miso, uint32_t length, uint32_t flags) |
Perform SPI I/O operation. More... | |
int | jaylink_parse_serial_number (const char *str, uint32_t *serial_number) |
Convert a string representation of a serial number to an integer. More... | |
const char * | jaylink_hardware_type_string (enum jaylink_hardware_type type) |
Get the string representation of a hardware type. More... | |
const char * | jaylink_target_interface_string (enum jaylink_target_interface iface) |
Get the string representation of a target interface. More... | |
int | jaylink_swd_io (struct jaylink_device_handle *devh, const uint8_t *direction, const uint8_t *out, uint8_t *in, uint16_t length) |
Perform a SWD I/O operation. More... | |
int | jaylink_swo_start (struct jaylink_device_handle *devh, enum jaylink_swo_mode mode, uint32_t baudrate, uint32_t size) |
Start SWO capture. More... | |
int | jaylink_swo_stop (struct jaylink_device_handle *devh) |
Stop SWO capture. More... | |
int | jaylink_swo_read (struct jaylink_device_handle *devh, uint8_t *buffer, uint32_t *length) |
Read SWO trace data. More... | |
int | jaylink_swo_get_speeds (struct jaylink_device_handle *devh, enum jaylink_swo_mode mode, struct jaylink_swo_speed *speed) |
Retrieve SWO speeds. More... | |
int | jaylink_set_speed (struct jaylink_device_handle *devh, uint16_t speed) |
Set the target interface speed. More... | |
int | jaylink_get_speeds (struct jaylink_device_handle *devh, struct jaylink_speed *speed) |
Retrieve target interface speeds. More... | |
int | jaylink_select_interface (struct jaylink_device_handle *devh, enum jaylink_target_interface iface, enum jaylink_target_interface *prev_iface) |
Select the target interface. More... | |
int | jaylink_get_available_interfaces (struct jaylink_device_handle *devh, uint32_t *ifaces) |
Retrieve the available target interfaces. More... | |
int | jaylink_get_selected_interface (struct jaylink_device_handle *devh, enum jaylink_target_interface *iface) |
Retrieve the selected target interface. More... | |
int | jaylink_clear_reset (struct jaylink_device_handle *devh) |
Clear the target reset signal. More... | |
int | jaylink_set_reset (struct jaylink_device_handle *devh) |
Set the target reset signal. More... | |
int | jaylink_set_target_power (struct jaylink_device_handle *devh, bool enable) |
Set the target power supply. More... | |
bool | jaylink_has_cap (const uint8_t *caps, uint32_t cap) |
Check for a capability. More... | |
int | jaylink_version_package_get_major (void) |
Get the major version number of the libjaylink package. More... | |
int | jaylink_version_package_get_minor (void) |
Get the minor version number of the libjaylink package. More... | |
int | jaylink_version_package_get_micro (void) |
Get the micro version number of the libjaylink package. More... | |
const char * | jaylink_version_package_get_string (void) |
Get the version number string of the libjaylink package. More... | |
int | jaylink_version_library_get_current (void) |
Get the current version number of the libjaylink libtool interface. More... | |
int | jaylink_version_library_get_revision (void) |
Get the revision version number of the libjaylink libtool interface. More... | |
int | jaylink_version_library_get_age (void) |
Get the age version number of the libjaylink libtool interface. More... | |
const char * | jaylink_version_library_get_string (void) |
Get the version number string of the libjaylink libtool interface. More... | |
Public libjaylink header file to be used by applications.
#define JAYLINK_API __attribute__ ((visibility ("default"))) |
Macro to mark public libjaylink API symbol.
#define JAYLINK_C2_MAX_LENGTH 64 |
Maximum length of a 2-wire (C2) interface data transfer.
#define JAYLINK_DEV_CAPS_SIZE 4 |
Number of bytes required to store device capabilities.
#define JAYLINK_DEV_CONFIG_SIZE 256 |
Size of the device configuration data in bytes.
#define JAYLINK_DEV_EXT_CAPS_SIZE 32 |
Number of bytes required to store extended device capabilities.
#define JAYLINK_EMUCOM_CHANNEL_TIME 0x0 |
EMUCOM channel with the system time of the device in milliseconds.
The channel is read-only and the time is encoded in 4 bytes. The byte order is little-endian.
#define JAYLINK_EMUCOM_CHANNEL_USER 0x10000 |
Offset of EMUCOM user channels.
User channels are available to implement vendor and/or device specific functionalities. All channels below are reserved.
#define JAYLINK_FILE_MAX_TRANSFER_SIZE 0x100000 |
Maximum transfer size for a file in bytes.
#define JAYLINK_FILE_NAME_MAX_LENGTH 255 |
Maximum length of a filename in bytes.
#define JAYLINK_LOG_DOMAIN_DEFAULT "jaylink: " |
Default libjaylink log domain.
#define JAYLINK_LOG_DOMAIN_MAX_LENGTH 32 |
Maximum length of a libjaylink log domain in bytes.
#define JAYLINK_MAC_ADDRESS_LENGTH 6 |
Media Access Control (MAC) address length in bytes.
#define JAYLINK_MAX_CONNECTIONS 16 |
Maximum number of connections that can be registered on a device.
#define JAYLINK_SPEED_ADAPTIVE_CLOCKING 0xffff |
Target interface speed value for adaptive clocking.
typedef int(* jaylink_log_callback) (const struct jaylink_context *ctx, enum jaylink_log_level level, const char *format, va_list args, void *user_data) |
Log callback function type.
[in] | ctx | libjaylink context. |
[in] | level | Log level. |
[in] | format | Message format in printf()-style. |
[in] | args | Message arguments. |
[in,out] | user_data | User data passed to the callback function. |
enum jaylink_capability |
enum jaylink_counter |
Device capabilities.
enum jaylink_error |
Error codes returned by libjaylink functions.
Hardware information.
Enumerator | |
---|---|
JAYLINK_HW_INFO_TARGET_POWER |
Status of the target power supply. This indicates whether the target power supply on pin 19 of the 20-pin JTAG / SWD connector is enabled or disabled.
|
JAYLINK_HW_INFO_ITARGET |
Current consumption of the target in mA. |
JAYLINK_HW_INFO_ITARGET_PEAK |
Peak current consumption of the target in mA. |
JAYLINK_HW_INFO_IPV4_ADDRESS |
Device's IPv4 address in network byte order. If the address is 0.0.0.0 and DHCP is enabled, no address is assigned (yet).
|
JAYLINK_HW_INFO_IPV4_NETMASK |
IPv4 netmask in network byte order.
|
JAYLINK_HW_INFO_IPV4_GATEWAY |
Gateway IPv4 address in network byte order.
|
JAYLINK_HW_INFO_IPV4_DNS |
DNS server IPv4 address in network byte order.
|
JAYLINK_HW_INFO_VUSB |
USB voltage in mV. |
enum jaylink_jtag_version |
JTAG command versions.
The JTAG command version only affects the device and the communication protocol. The behaviour of a JTAG operation is not affected at all.
Enumerator | |
---|---|
JAYLINK_JTAG_VERSION_2 |
JTAG command version 2. This version is obsolete for major hardware version 5 and above. Use JAYLINK_JTAG_VERSION_3 for these versions instead. |
JAYLINK_JTAG_VERSION_3 |
JTAG command version 3. |
enum jaylink_log_level |
libjaylink log levels.
enum jaylink_spi_flag |
Serial Peripheral Interface (SPI) flags.
enum jaylink_swo_mode |
Target interfaces.
enum jaylink_usb_address |
USB addresses.
The USB address is a way to identify USB devices and is related to the USB Product ID (PID) of a device.
int jaylink_c2_read_address | ( | struct jaylink_device_handle * | devh, |
uint8_t * | address | ||
) |
Read the C2 address register.
[in,out] | devh | Device handle. |
[out] | address | Value read from the address register on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_c2_read_data | ( | struct jaylink_device_handle * | devh, |
uint8_t * | data, | ||
uint8_t | length | ||
) |
Read the C2 data register.
[in,out] | devh | Device handle. |
[out] | data | Buffer to store the read data on success. Its content is undefined on failure. |
[in] | length | Number of bytes to read, but not more than JAYLINK_C2_MAX_LENGTH. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_c2_write_address | ( | struct jaylink_device_handle * | devh, |
uint8_t | address | ||
) |
Write to the C2 address register.
[in,out] | devh | Device handle. |
[in] | address | Value to write into the address register. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_c2_write_data | ( | struct jaylink_device_handle * | devh, |
const uint8_t * | data, | ||
uint8_t | length | ||
) |
Write to the C2 data register.
[in,out] | devh | Device handle. |
[in] | data | Buffer to be written into the data register. |
[in] | length | Number of bytes to write, but not more than JAYLINK_C2_MAX_LENGTH. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_clear_reset | ( | struct jaylink_device_handle * | devh | ) |
Clear the target reset signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_close | ( | struct jaylink_device_handle * | devh | ) |
Close a device.
[in,out] | devh | Device instance. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR | Other error conditions. |
int jaylink_device_get_hardware_version | ( | const struct jaylink_device * | dev, |
struct jaylink_hardware_version * | version | ||
) |
Get the hardware version of a device.
[in] | dev | Device instance. |
[out] | version | Hardware version of the device on success and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_TCP only. |
JAYLINK_ERR_NOT_AVAILABLE | Hardware version is not available. |
int jaylink_device_get_host_interface | ( | const struct jaylink_device * | dev, |
enum jaylink_host_interface * | iface | ||
) |
Get the host interface of a device.
[in] | dev | Device instance. |
[out] | iface | Host interface of the device on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
int jaylink_device_get_ipv4_address | ( | const struct jaylink_device * | dev, |
char * | address | ||
) |
Get the IPv4 address string of a device.
[in] | dev | Device instance. |
[out] | address | IPv4 address string in quad-dotted decimal format of the device on success and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_TCP only. |
int jaylink_device_get_mac_address | ( | const struct jaylink_device * | dev, |
uint8_t * | address | ||
) |
Get the MAC address of a device.
[in] | dev | Device instance. |
[out] | address | MAC address of the device on success and undefined on failure. The length of the MAC address is JAYLINK_MAC_ADDRESS_LENGTH bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_TCP only. |
JAYLINK_ERR_NOT_AVAILABLE | MAC address is not available. |
int jaylink_device_get_nickname | ( | const struct jaylink_device * | dev, |
char * | nickname | ||
) |
Get the nickname of a device.
[in] | dev | Device instance. |
[out] | nickname | Nickname of the device on success and undefined on failure. The maximum length of the nickname is JAYLINK_NICKNAME_MAX_LENGTH bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_TCP only. |
JAYLINK_ERR_NOT_AVAILABLE | Nickname is not available. |
int jaylink_device_get_product_name | ( | const struct jaylink_device * | dev, |
char * | name | ||
) |
Get the product name of a device.
[in] | dev | Device instance. |
[out] | name | Product name of the device on success and undefined on failure. The maximum length of the product name is JAYLINK_PRODUCT_NAME_MAX_LENGTH bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_TCP only. |
JAYLINK_ERR_NOT_AVAILABLE | Product name is not available. |
int jaylink_device_get_serial_number | ( | const struct jaylink_device * | dev, |
uint32_t * | serial_number | ||
) |
Get the serial number of a device.
[in] | dev | Device instance. |
[out] | serial_number | Serial number of the device on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_AVAILABLE | Serial number is not available. |
int jaylink_device_get_usb_address | ( | const struct jaylink_device * | dev, |
enum jaylink_usb_address * | address | ||
) |
Get the USB address of a device.
[in] | dev | Device instance. |
[out] | address | USB address of the device on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_USB only. |
int jaylink_device_get_usb_bus_ports | ( | const struct jaylink_device * | dev, |
uint8_t * | bus, | ||
uint8_t ** | ports, | ||
size_t * | length | ||
) |
Get the USB bus and port numbers of a device.
[in] | dev | Device instance. |
[out] | bus | The bus number of the device on success and undefined on failure. |
[out] | ports | Newly allocated array which contains the port numbers on success and is undefined on failure. The array must be free'd by the caller. |
[out] | length | Length of the port array on success and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_MALLOC | Memory allocation error. |
JAYLINK_ERR_NOT_SUPPORTED | Supported for devices with host interface JAYLINK_HIF_USB only. |
int jaylink_discovery_scan | ( | struct jaylink_context * | ctx, |
uint32_t | ifaces | ||
) |
Scan for devices.
[in,out] | ctx | libjaylink context. |
[in] | ifaces | Host interfaces to scan for devices. Use bitwise OR to specify multiple interfaces, or 0 to use all available interfaces. See jaylink_host_interface for a description of the interfaces. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_emucom_read | ( | struct jaylink_device_handle * | devh, |
uint32_t | channel, | ||
uint8_t * | buffer, | ||
uint32_t * | length | ||
) |
Read from an EMUCOM channel.
[in,out] | devh | Device handle. |
[in] | channel | Channel to read data from. |
[out] | buffer | Buffer to store read data on success. Its content is undefined on failure. |
[in,out] | length | Number of bytes to read. On success, the value gets updated with the actual number of bytes read. Unless otherwise specified, the value is undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV_NOT_SUPPORTED | Channel is not supported by the device. |
JAYLINK_ERR_DEV_NOT_AVAILABLE | Channel is not available for the requested amount of data. length is updated with the number of bytes available on this channel. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_emucom_write | ( | struct jaylink_device_handle * | devh, |
uint32_t | channel, | ||
const uint8_t * | buffer, | ||
uint32_t * | length | ||
) |
Write to an EMUCOM channel.
[in,out] | devh | Device handle. |
[in] | channel | Channel to write data to. |
[in] | buffer | Buffer to write data from. |
[in,out] | length | Number of bytes to write. On success, the value gets updated with the actual number of bytes written. The value is undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV_NOT_SUPPORTED | Channel is not supported by the device. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_exit | ( | struct jaylink_context * | ctx | ) |
Shutdown libjaylink.
[in,out] | ctx | libjaylink context. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
int jaylink_file_delete | ( | struct jaylink_device_handle * | devh, |
const char * | filename | ||
) |
Delete a file.
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to delete. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
int jaylink_file_get_size | ( | struct jaylink_device_handle * | devh, |
const char * | filename, | ||
uint32_t * | size | ||
) |
Retrieve the size of a file.
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to retrieve the size of. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[out] | size | Size of the file in bytes on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
int jaylink_file_read | ( | struct jaylink_device_handle * | devh, |
const char * | filename, | ||
uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t * | length | ||
) |
Read from a file.
The maximum amount of data that can be read from a file at once is JAYLINK_FILE_MAX_TRANSFER_SIZE bytes. Multiple reads in conjunction with the offset
parameter are needed for larger files.
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to read from. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[out] | buffer | Buffer to store read data on success. Its content is undefined on failure |
[in] | offset | Offset in bytes relative to the beginning of the file from where to start reading. |
[in,out] | length | Number of bytes to read. On success, the value gets updated with the actual number of bytes read. The value is undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
int jaylink_file_write | ( | struct jaylink_device_handle * | devh, |
const char * | filename, | ||
const uint8_t * | buffer, | ||
uint32_t | offset, | ||
uint32_t * | length | ||
) |
Write to a file.
If a file does not exist, a new file is created.
The maximum amount of data that can be written to a file at once is JAYLINK_FILE_MAX_TRANSFER_SIZE bytes. Multiple writes in conjunction with the offset
parameter are needed for larger files.
[in,out] | devh | Device handle. |
[in] | filename | Name of the file to write to. The length of the name must not exceed JAYLINK_FILE_NAME_MAX_LENGTH bytes. |
[in] | buffer | Buffer to write data from. |
[in] | offset | Offset in bytes relative to the beginning of the file from where to start writing. |
[in,out] | length | Number of bytes to write. On success, the value gets updated with the actual number of bytes written. The value is undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error, or the file was not found. |
JAYLINK_ERR | Other error conditions. |
void jaylink_free_devices | ( | struct jaylink_device ** | devs, |
bool | unref | ||
) |
Free devices.
[in,out] | devs | Array of device instances. Must be NULL-terminated. |
[in] | unref | Determines whether the device instances should be unreferenced. |
int jaylink_get_available_interfaces | ( | struct jaylink_device_handle * | devh, |
uint32_t * | ifaces | ||
) |
Retrieve the available target interfaces.
The target interfaces are stored in a 32-bit bit field where each individual bit represents a target interface. A set bit indicates an available target interface. See jaylink_target_interface for a description of the target interfaces and their bit positions.
[in,out] | devh | Device handle. |
[out] | ifaces | Target interfaces on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_caps | ( | struct jaylink_device_handle * | devh, |
uint8_t * | caps | ||
) |
Retrieve the capabilities of a device.
The capabilities are stored in a 32-bit bit array consisting of JAYLINK_DEV_CAPS_SIZE bytes where each individual bit represents a capability. The first bit of this array is the least significant bit of the first byte and the following bits are sequentially numbered in order of increasing bit significance and byte index. A set bit indicates a supported capability. See jaylink_device_capability for a description of the capabilities and their bit positions.
[in,out] | devh | Device handle. |
[out] | caps | Buffer to store capabilities on success. Its content is undefined on failure. The buffer must be large enough to contain at least JAYLINK_DEV_CAPS_SIZE bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_counters | ( | struct jaylink_device_handle * | devh, |
uint32_t | mask, | ||
uint32_t * | values | ||
) |
Retrieve the counter values of a device.
[in,out] | devh | Device handle. |
[in] | mask | A bit field where each set bit represents a counter value to request. See jaylink_counter for a description of the counters and their bit positions. |
[out] | values | Array to store the counter values on success. Its content is undefined on failure. The array must be large enough to contain at least as many elements as bits set in mask . |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
struct jaylink_device* jaylink_get_device | ( | struct jaylink_device_handle * | devh | ) |
Get the device instance from a device handle.
[in] | devh | Device handle. |
int jaylink_get_devices | ( | struct jaylink_context * | ctx, |
struct jaylink_device *** | devs, | ||
size_t * | count | ||
) |
Get available devices.
[in,out] | ctx | libjaylink context. |
[out] | devs | Newly allocated array which contains instances of available devices on success, and undefined on failure. The array is NULL-terminated and must be free'd by the caller with jaylink_free_devices(). |
[out] | count | Number of available devices on success, and undefined on failure. Can be NULL. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_MALLOC | Memory allocation error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_extended_caps | ( | struct jaylink_device_handle * | devh, |
uint8_t * | caps | ||
) |
Retrieve the extended capabilities of a device.
The extended capabilities are stored in a 256-bit bit array consisting of JAYLINK_DEV_EXT_CAPS_SIZE bytes. See jaylink_get_caps() for a further description of how the capabilities are represented in this bit array. For a description of the capabilities and their bit positions, see jaylink_device_capability.
[in,out] | devh | Device handle. |
[out] | caps | Buffer to store capabilities on success. Its content is undefined on failure. The buffer must be large enough to contain at least JAYLINK_DEV_EXT_CAPS_SIZE bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_firmware_version | ( | struct jaylink_device_handle * | devh, |
char ** | version, | ||
size_t * | length | ||
) |
Retrieve the firmware version of a device.
[in,out] | devh | Device handle. |
[out] | version | Newly allocated string which contains the firmware version on success, and undefined if length is zero or on failure. The string is null-terminated and must be free'd by the caller. |
[out] | length | Length of the firmware version string including trailing null-terminator on success, and undefined on failure. Zero if no firmware version string is available. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_MALLOC | Memory allocation error. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_free_memory | ( | struct jaylink_device_handle * | devh, |
uint32_t * | size | ||
) |
Retrieve the size of free memory of a device.
[in,out] | devh | Device handle. |
[out] | size | Size of free memory in bytes on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_hardware_info | ( | struct jaylink_device_handle * | devh, |
uint32_t | mask, | ||
uint32_t * | info | ||
) |
Retrieve the hardware information of a device.
[in,out] | devh | Device handle. |
[in] | mask | A bit field where each set bit represents hardware information to request. See jaylink_hardware_info for a description of the hardware information and their bit positions. |
[out] | info | Array to store the hardware information on success. Its content is undefined on failure. The array must be large enough to contain at least as many elements as bits set in mask. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_hardware_status | ( | struct jaylink_device_handle * | devh, |
struct jaylink_hardware_status * | status | ||
) |
Retrieve the hardware status of a device.
[in,out] | devh | Device handle. |
[out] | status | Hardware status on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_hardware_version | ( | struct jaylink_device_handle * | devh, |
struct jaylink_hardware_version * | version | ||
) |
Retrieve the hardware version of a device.
version
where jaylink_hardware_version::type is not covered by jaylink_hardware_type.[in,out] | devh | Device handle. |
[out] | version | Hardware version on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_selected_interface | ( | struct jaylink_device_handle * | devh, |
enum jaylink_target_interface * | iface | ||
) |
Retrieve the selected target interface.
iface
which is not covered by jaylink_target_interface.[in,out] | devh | Device handle. |
[out] | iface | Selected target interface on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_get_speeds | ( | struct jaylink_device_handle * | devh, |
struct jaylink_speed * | speed | ||
) |
Retrieve target interface speeds.
The speeds are applicable for the currently selected target interface only and calculated as follows:
speeds = freq / n
with n >= div
, where n
is an integerAssuming, for example, a base frequency freq of 4 MHz and a minimum divider div of 4 then the highest possible target interface speed is 4 MHz / 4 = 1 MHz. The next highest speed is 800 kHz for a divider of 5, and so on.
[in,out] | devh | Device handle. |
[out] | speed | Speed information on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
const char* jaylink_hardware_type_string | ( | enum jaylink_hardware_type | type | ) |
Get the string representation of a hardware type.
[in] | type | Hardware type. |
bool jaylink_has_cap | ( | const uint8_t * | caps, |
uint32_t | cap | ||
) |
Check for a capability.
The capabilities are expected to be stored in a bit array consisting of one or more bytes where each individual bit represents a capability. The first bit of this array is the least significant bit of the first byte and the following bits are sequentially numbered in order of increasing bit significance and byte index. A set bit indicates a supported capability.
[in] | caps | Buffer with capabilities. |
[in] | cap | Bit position of the capability to check for. |
true | Capability is supported. |
false | Capability is not supported or invalid argument. |
int jaylink_init | ( | struct jaylink_context ** | ctx | ) |
Initialize libjaylink.
This function must be called before any other libjaylink function is called.
[out] | ctx | Newly allocated libjaylink context on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_MALLOC | Memory allocation error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_clear_tck | ( | struct jaylink_device_handle * | devh | ) |
Clear the JTAG test clock (TCK) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_clear_tms | ( | struct jaylink_device_handle * | devh | ) |
Clear the JTAG test mode select (TMS) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_clear_trst | ( | struct jaylink_device_handle * | devh | ) |
Clear the JTAG test reset (TRST) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_io | ( | struct jaylink_device_handle * | devh, |
const uint8_t * | tms, | ||
const uint8_t * | tdi, | ||
uint8_t * | tdo, | ||
uint16_t | length, | ||
enum jaylink_jtag_version | version | ||
) |
Perform a JTAG I/O operation.
[in,out] | devh | Device handle. |
[in] | tms | Buffer to read TMS data from. |
[in] | tdi | Buffer to read TDI data from. |
[out] | tdo | Buffer to store TDO data on success. Its content is undefined on failure. The buffer must be large enough to contain at least the specified number of bits to transfer. |
[in] | length | Number of bits to transfer. |
[in] | version | Version of the JTAG command to use. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV_NO_MEMORY | Not enough memory on the device to perform the operation. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_set_tck | ( | struct jaylink_device_handle * | devh | ) |
Set the JTAG test clock (TCK) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_set_tms | ( | struct jaylink_device_handle * | devh | ) |
Set the JTAG test mode select (TMS) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_jtag_set_trst | ( | struct jaylink_device_handle * | devh | ) |
Set the JTAG test reset (TRST) signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
bool jaylink_library_has_cap | ( | enum jaylink_capability | cap | ) |
Check for a capability of libjaylink.
[in] | cap | Capability to check for. |
true | Capability is supported. |
false | Capability is not supported or invalid argument. |
const char* jaylink_log_get_domain | ( | const struct jaylink_context * | ctx | ) |
Get the libjaylink log domain.
[in] | ctx | libjaylink context. |
int jaylink_log_get_level | ( | const struct jaylink_context * | ctx, |
enum jaylink_log_level * | level | ||
) |
Get the libjaylink log level.
[in] | ctx | libjaylink context. |
[out] | level | Log level on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
int jaylink_log_set_callback | ( | struct jaylink_context * | ctx, |
jaylink_log_callback | callback, | ||
void * | user_data | ||
) |
Set the libjaylink log callback function.
[in,out] | ctx | libjaylink context. |
[in] | callback | Callback function to use, or NULL to use the default log function. |
[in] | user_data | User data to be passed to the callback function. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
int jaylink_log_set_domain | ( | struct jaylink_context * | ctx, |
const char * | domain | ||
) |
Set the libjaylink log domain.
The log domain is a string which is used as prefix for all log messages to differentiate them from messages of other libraries.
The maximum length of the log domain is JAYLINK_LOG_DOMAIN_MAX_LENGTH bytes, excluding the trailing null-terminator. A log domain which exceeds this length will be silently truncated.
[in,out] | ctx | libjaylink context. |
[in] | domain | Log domain to use. To set the default log domain, use JAYLINK_LOG_DOMAIN_DEFAULT. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR | Other error conditions. |
int jaylink_log_set_level | ( | struct jaylink_context * | ctx, |
enum jaylink_log_level | level | ||
) |
Set the libjaylink log level.
[in,out] | ctx | libjaylink context. |
[in] | level | Log level to set. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
int jaylink_open | ( | struct jaylink_device * | dev, |
struct jaylink_device_handle ** | devh | ||
) |
Open a device.
[in,out] | dev | Device instance. |
[out] | devh | Newly allocated handle for the opened device on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_MALLOC | Memory allocation error. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_parse_serial_number | ( | const char * | str, |
uint32_t * | serial_number | ||
) |
Convert a string representation of a serial number to an integer.
The string representation of the serial number must be in decimal form.
[in] | str | String representation to convert. |
[out] | serial_number | Serial number on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR | Conversion error. Serial number is invalid or string representation contains invalid character(s). |
int jaylink_read_raw_config | ( | struct jaylink_device_handle * | devh, |
uint8_t * | config | ||
) |
Read the raw configuration data of a device.
[in,out] | devh | Device handle. |
[out] | config | Buffer to store configuration data on success. Its content is undefined on failure. The buffer must be large enough to contain at least JAYLINK_DEV_CONFIG_SIZE bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
struct jaylink_device* jaylink_ref_device | ( | struct jaylink_device * | dev | ) |
Increment the reference count of a device.
[in,out] | dev | Device instance. |
int jaylink_register | ( | struct jaylink_device_handle * | devh, |
struct jaylink_connection * | connection, | ||
struct jaylink_connection * | connections, | ||
size_t * | count | ||
) |
Register a connection on a device.
A connection can be registered by using 0 as handle. Additional information about the connection can be attached whereby the timestamp is a read-only value and therefore ignored for registration. On success, a new handle greater than 0 is obtained from the device.
However, if an obtained handle does not appear in the list of device connections, the connection was not registered because the maximum number of connections on the device is reached.
Example code:
[in,out] | devh | Device handle. |
[in,out] | connection | Connection to register on the device. |
[out] | connections | Array to store device connections on success. Its content is undefined on failure. The array must be large enough to contain at least JAYLINK_MAX_CONNECTIONS elements. |
[out] | count | Number of device connections on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_select_interface | ( | struct jaylink_device_handle * | devh, |
enum jaylink_target_interface | iface, | ||
enum jaylink_target_interface * | prev_iface | ||
) |
Select the target interface.
prev_iface
which is not covered by jaylink_target_interface.[in,out] | devh | Device handle. |
[in] | iface | Target interface to select. |
[out] | prev_iface | Previously selected target interface on success, and undefined on failure. Can be NULL. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_set_reset | ( | struct jaylink_device_handle * | devh | ) |
Set the target reset signal.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_set_speed | ( | struct jaylink_device_handle * | devh, |
uint16_t | speed | ||
) |
Set the target interface speed.
[in,out] | devh | Device handle. |
[in] | speed | Speed in kHz or JAYLINK_SPEED_ADAPTIVE_CLOCKING for adaptive clocking. Speed of 0 kHz is not allowed and adaptive clocking must only be used if the device has the JAYLINK_DEV_CAP_ADAPTIVE_CLOCKING capability. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_set_target_power | ( | struct jaylink_device_handle * | devh, |
bool | enable | ||
) |
Set the target power supply.
If enabled, the target is supplied with 5 V from pin 19 of the 20-pin JTAG / SWD connector.
[in,out] | devh | Device handle. |
[in] | enable | Determines whether to enable or disable the target power supply. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_spi_io | ( | struct jaylink_device_handle * | devh, |
const uint8_t * | mosi, | ||
uint8_t * | miso, | ||
uint32_t | length, | ||
uint32_t | flags | ||
) |
Perform SPI I/O operation.
The device acts as master and operates in mode 3 (CPOL = 1, CPHA = 1). Data is transferred with the most significant bit (MSB) first.
[in,out] | devh | Device handle. |
[in] | mosi | Buffer to read MOSI data from. Can be NULL. |
[out] | miso | Buffer to store MISO data on success. Its content is undefined on failure. The buffer must be large enough to contain at least the specified number of bytes to transfer. Can be NULL. |
[in] | length | Number of bytes to transfer. |
[in] | flags | Flags, see jaylink_spi_flag for more details. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR | Other error conditions. |
const char* jaylink_strerror | ( | int | error_code | ) |
Return a human-readable description of a libjaylink error code.
[in] | error_code | A libjaylink error code. See jaylink_error for valid values. |
const char* jaylink_strerror_name | ( | int | error_code | ) |
Return the name of a libjaylink error code.
[in] | error_code | A libjaylink error code. See jaylink_error for valid values. |
int jaylink_swd_io | ( | struct jaylink_device_handle * | devh, |
const uint8_t * | direction, | ||
const uint8_t * | out, | ||
uint8_t * | in, | ||
uint16_t | length | ||
) |
Perform a SWD I/O operation.
[in,out] | devh | Device handle. |
[in] | direction | Buffer to read the transfer direction from. |
[in] | out | Buffer to read host-to-target data from. |
[out] | in | Buffer to store target-to-host data on success. Its content is undefined on failure. The buffer must be large enough to contain at least the specified number of bits to transfer. |
[in] | length | Total number of bits to transfer from host to target and vice versa. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV_NO_MEMORY | Not enough memory on the device to perform the operation. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_swo_get_speeds | ( | struct jaylink_device_handle * | devh, |
enum jaylink_swo_mode | mode, | ||
struct jaylink_swo_speed * | speed | ||
) |
Retrieve SWO speeds.
The speeds are calculated as follows:
speeds = freq / n
with n >= min_div
and n <= max_div
, where n
is an integerAssuming, for example, a base frequency freq of 4500 kHz, a minimum divider min_div of 1 and a maximum divider max_div of 8 then the highest possible SWO speed is 4500 kHz / 1 = 4500 kHz. The next highest speed is 2250 kHz for a divider of 2, and so on. Accordingly, the lowest possible speed is 4500 kHz / 8 = 562.5 kHz.
[in,out] | devh | Device handle. |
[in] | mode | Capture mode to retrieve speeds for. |
[out] | speed | Speed information on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_swo_read | ( | struct jaylink_device_handle * | devh, |
uint8_t * | buffer, | ||
uint32_t * | length | ||
) |
Read SWO trace data.
[in,out] | devh | Device handle. |
[out] | buffer | Buffer to store trace data on success. Its content is undefined on failure. |
[in,out] | length | Maximum number of bytes to read. On success, the value gets updated with the actual number of bytes read. The value is undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_swo_start | ( | struct jaylink_device_handle * | devh, |
enum jaylink_swo_mode | mode, | ||
uint32_t | baudrate, | ||
uint32_t | size | ||
) |
Start SWO capture.
[in,out] | devh | Device handle. |
[in] | mode | Mode to capture data with. |
[in] | baudrate | Baudrate to capture data in bit per second. |
[in] | size | Device internal buffer size in bytes to use for capturing. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_swo_stop | ( | struct jaylink_device_handle * | devh | ) |
Stop SWO capture.
[in,out] | devh | Device handle. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR_DEV | Unspecified device error. |
JAYLINK_ERR | Other error conditions. |
const char* jaylink_target_interface_string | ( | enum jaylink_target_interface | iface | ) |
Get the string representation of a target interface.
[in] | iface | Target interface. |
void jaylink_unref_device | ( | struct jaylink_device * | dev | ) |
Decrement the reference count of a device.
[in,out] | dev | Device instance. |
int jaylink_unregister | ( | struct jaylink_device_handle * | devh, |
const struct jaylink_connection * | connection, | ||
struct jaylink_connection * | connections, | ||
size_t * | count | ||
) |
Unregister a connection from a device.
[in,out] | devh | Device handle. |
[in,out] | connection | Connection to unregister from the device. |
[out] | connections | Array to store device connections on success. Its content is undefined on failure. The array must be large enough to contain at least JAYLINK_MAX_CONNECTIONS elements. |
[out] | count | Number of device connections on success, and undefined on failure. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_PROTO | Protocol violation. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |
int jaylink_version_library_get_age | ( | void | ) |
Get the age version number of the libjaylink libtool interface.
int jaylink_version_library_get_current | ( | void | ) |
Get the current version number of the libjaylink libtool interface.
int jaylink_version_library_get_revision | ( | void | ) |
Get the revision version number of the libjaylink libtool interface.
const char* jaylink_version_library_get_string | ( | void | ) |
Get the version number string of the libjaylink libtool interface.
int jaylink_version_package_get_major | ( | void | ) |
Get the major version number of the libjaylink package.
int jaylink_version_package_get_micro | ( | void | ) |
Get the micro version number of the libjaylink package.
int jaylink_version_package_get_minor | ( | void | ) |
Get the minor version number of the libjaylink package.
const char* jaylink_version_package_get_string | ( | void | ) |
Get the version number string of the libjaylink package.
int jaylink_write_raw_config | ( | struct jaylink_device_handle * | devh, |
const uint8_t * | config | ||
) |
Write the raw configuration data of a device.
[in,out] | devh | Device handle. |
[in] | config | Buffer to write configuration data from. The size of the configuration data is expected to be JAYLINK_DEV_CONFIG_SIZE bytes. |
JAYLINK_OK | Success. |
JAYLINK_ERR_ARG | Invalid arguments. |
JAYLINK_ERR_TIMEOUT | A timeout occurred. |
JAYLINK_ERR_IO | Input/output error. |
JAYLINK_ERR | Other error conditions. |