33 #define CMD_JTAG_IO_V2 0xce 34 #define CMD_JTAG_IO_V3 0xcf 35 #define CMD_JTAG_CLEAR_TRST 0xde 36 #define CMD_JTAG_SET_TRST 0xdf 42 #define JTAG_IO_ERR_NO_MEMORY 0x06 76 const uint8_t *tms,
const uint8_t *tdi, uint8_t *tdo,
87 if (!devh || !tms || !tdi || !tdo || !length)
90 num_bytes = (length + 7) / 8;
91 read_length = num_bytes;
111 log_err(ctx,
"transport_start_write_read() failed: %s.",
123 log_err(ctx,
"transport_write() failed: %s.",
131 log_err(ctx,
"transport_write() failed: %s.",
139 log_err(ctx,
"transport_write() failed: %s.",
147 log_err(ctx,
"transport_read() failed: %s.",
158 log_err(ctx,
"transport_read() failed: %s.",
163 if (status == JTAG_IO_ERR_NO_MEMORY) {
165 }
else if (status > 0) {
166 log_err(ctx,
"JTAG I/O operation failed: 0x%x.", status);
199 log_err(ctx,
"transport_start_write() failed: %s.",
204 buf[0] = CMD_JTAG_CLEAR_TRST;
209 log_err(ctx,
"transport_write() failed: %s.",
243 log_err(ctx,
"transport_start_write() failed: %s.",
248 buf[0] = CMD_JTAG_SET_TRST;
253 log_err(ctx,
"transport_write() failed: %s.",
JAYLINK_PRIV int transport_read(struct jaylink_device_handle *devh, uint8_t *buffer, size_t length)
Read data from a device.
JAYLINK_PRIV void log_err(const struct jaylink_context *ctx, const char *format,...)
JAYLINK_API 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.
JAYLINK_PRIV void buffer_set_u16(uint8_t *buffer, uint16_t value, size_t offset)
Write a 16-bit unsigned integer value to a buffer.
JAYLINK_API int jaylink_jtag_set_trst(struct jaylink_device_handle *devh)
Set the JTAG test reset (TRST) signal.
Opaque structure representing a libjaylink context.
Internal libjaylink header file.
struct jaylink_context * ctx
libjaylink context.
Opaque structure representing a handle of a device.
JAYLINK_PRIV int transport_start_write(struct jaylink_device_handle *devh, size_t length, bool has_command)
Start a write operation for a device.
Public libjaylink header file to be used by applications.
JAYLINK_API const char * jaylink_strerror(int error_code)
Return a human-readable description of a libjaylink error code.
static struct jaylink_device_handle * devh
#define JAYLINK_API
Macro to mark public libjaylink API symbol.
JAYLINK_API int jaylink_jtag_clear_trst(struct jaylink_device_handle *devh)
Clear the JTAG test reset (TRST) signal.
Device: not enough memory to perform operation.
struct jaylink_device * dev
Device instance.
JAYLINK_PRIV int transport_start_write_read(struct jaylink_device_handle *devh, size_t write_length, size_t read_length, bool has_command)
Start a write and read operation for a device.
Device: unspecified error.
JAYLINK_PRIV int transport_write(struct jaylink_device_handle *devh, const uint8_t *buffer, size_t length)
Write data to a device.
jaylink_jtag_version
JTAG command versions.