33 #define CMD_SWD_IO 0xcf 39 #define SWD_IO_ERR_NO_MEMORY 0x06 72 const uint8_t *
direction,
const uint8_t *out, uint8_t *in,
81 if (!devh || !direction || !out || !in || !length)
85 num_bytes = (length + 7) / 8;
91 log_err(ctx,
"transport_start_write_read() failed: %s.",
103 log_err(ctx,
"transport_write() failed: %s.",
111 log_err(ctx,
"transport_write() failed: %s.",
119 log_err(ctx,
"transport_write() failed: %s.",
127 log_err(ctx,
"transport_read() failed: %s.",
135 log_err(ctx,
"transport_read() failed: %s.",
140 if (status == SWD_IO_ERR_NO_MEMORY) {
142 }
else if (status > 0) {
143 log_err(ctx,
"SWD I/O operation failed: 0x%x.", status);
static uint16_t direction
JAYLINK_PRIV int transport_read(struct jaylink_device_handle *devh, uint8_t *buffer, size_t length)
Read data from a device.
JAYLINK_API 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.
JAYLINK_PRIV void log_err(const struct jaylink_context *ctx, const char *format,...)
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.
Opaque structure representing a libjaylink context.
Internal libjaylink header file.
struct jaylink_context * ctx
libjaylink context.
Opaque structure representing a handle of 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.
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.