diff options
author | Marc Schink <dev@zapb.de> | 2021-03-10 18:14:29 +0100 |
---|---|---|
committer | Marc Schink <dev@zapb.de> | 2021-03-14 10:32:09 +0100 |
commit | 6654e2be5e7a6ae3eb9d66174f965a0db19d1172 (patch) | |
tree | 40701e1c09ba21aa97e41def865000d1464cee30 | |
parent | b102390f60ca70bf8407886092a7051c65fa8ade (diff) | |
download | libjaylink-6654e2be5e7a6ae3eb9d66174f965a0db19d1172.zip libjaylink-6654e2be5e7a6ae3eb9d66174f965a0db19d1172.tar.gz libjaylink-6654e2be5e7a6ae3eb9d66174f965a0db19d1172.tar.bz2 |
jtag: Add functions to set/clear the TCK signal
Signed-off-by: Marc Schink <dev@zapb.de>
-rw-r--r-- | libjaylink/jtag.c | 90 | ||||
-rw-r--r-- | libjaylink/libjaylink.h | 2 |
2 files changed, 92 insertions, 0 deletions
diff --git a/libjaylink/jtag.c b/libjaylink/jtag.c index d51a7c6..d40517c 100644 --- a/libjaylink/jtag.c +++ b/libjaylink/jtag.c @@ -36,6 +36,8 @@ #define CMD_JTAG_SET_TRST 0xdf #define CMD_JTAG_CLEAR_TMS 0xc9 #define CMD_JTAG_SET_TMS 0xca +#define CMD_JTAG_CLEAR_TCK 0xda +#define CMD_JTAG_SET_TCK 0xdb /** * Error code indicating that there is not enough free memory on the device to @@ -347,3 +349,91 @@ JAYLINK_API int jaylink_jtag_set_tms(struct jaylink_device_handle *devh) return JAYLINK_OK; } + +/** + * Clear the JTAG test clock (TCK) signal. + * + * @param[in,out] devh Device handle. + * + * @retval JAYLINK_OK Success. + * @retval JAYLINK_ERR_ARG Invalid arguments. + * @retval JAYLINK_ERR_TIMEOUT A timeout occurred. + * @retval JAYLINK_ERR_IO Input/output error. + * @retval JAYLINK_ERR Other error conditions. + * + * @since 0.3.0 + */ +JAYLINK_API int jaylink_jtag_clear_tck(struct jaylink_device_handle *devh) +{ + int ret; + struct jaylink_context *ctx; + uint8_t buf[1]; + + if (!devh) + return JAYLINK_ERR_ARG; + + ctx = devh->dev->ctx; + ret = transport_start_write(devh, 1, true); + + if (ret != JAYLINK_OK) { + log_err(ctx, "transport_start_write() failed: %s", + jaylink_strerror(ret)); + return ret; + } + + buf[0] = CMD_JTAG_CLEAR_TCK; + + ret = transport_write(devh, buf, 1); + + if (ret != JAYLINK_OK) { + log_err(ctx, "transport_write() failed: %s", + jaylink_strerror(ret)); + return ret; + } + + return JAYLINK_OK; +} + +/** + * Set the JTAG test clock (TCK) signal. + * + * @param[in,out] devh Device handle. + * + * @retval JAYLINK_OK Success. + * @retval JAYLINK_ERR_ARG Invalid arguments. + * @retval JAYLINK_ERR_TIMEOUT A timeout occurred. + * @retval JAYLINK_ERR_IO Input/output error. + * @retval JAYLINK_ERR Other error conditions. + * + * @since 0.3.0 + */ +JAYLINK_API int jaylink_jtag_set_tck(struct jaylink_device_handle *devh) +{ + int ret; + struct jaylink_context *ctx; + uint8_t buf[1]; + + if (!devh) + return JAYLINK_ERR_ARG; + + ctx = devh->dev->ctx; + ret = transport_start_write(devh, 1, true); + + if (ret != JAYLINK_OK) { + log_err(ctx, "transport_start_write() failed: %s", + jaylink_strerror(ret)); + return ret; + } + + buf[0] = CMD_JTAG_SET_TCK; + + ret = transport_write(devh, buf, 1); + + if (ret != JAYLINK_OK) { + log_err(ctx, "transport_write() failed: %s", + jaylink_strerror(ret)); + return ret; + } + + return JAYLINK_OK; +} diff --git a/libjaylink/libjaylink.h b/libjaylink/libjaylink.h index 3553aff..23f759b 100644 --- a/libjaylink/libjaylink.h +++ b/libjaylink/libjaylink.h @@ -577,6 +577,8 @@ JAYLINK_API int jaylink_jtag_clear_trst(struct jaylink_device_handle *devh); JAYLINK_API int jaylink_jtag_set_trst(struct jaylink_device_handle *devh); JAYLINK_API int jaylink_jtag_clear_tms(struct jaylink_device_handle *devh); JAYLINK_API int jaylink_jtag_set_tms(struct jaylink_device_handle *devh); +JAYLINK_API int jaylink_jtag_clear_tck(struct jaylink_device_handle *devh); +JAYLINK_API int jaylink_jtag_set_tck(struct jaylink_device_handle *devh); /*--- log.c -----------------------------------------------------------------*/ |