aboutsummaryrefslogtreecommitdiff
path: root/src/include/jtagtap.h
diff options
context:
space:
mode:
authorGareth McMullin2011-02-04 20:23:52 +1300
committerGareth McMullin2011-02-04 20:23:52 +1300
commit406617a2a470021d9412e9280feda0d28bdb653b (patch)
tree43b2cb9b562fde0bf5187c31dea77d72318cfc29 /src/include/jtagtap.h
Import of working source tree.
Diffstat (limited to 'src/include/jtagtap.h')
-rw-r--r--src/include/jtagtap.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/include/jtagtap.h b/src/include/jtagtap.h
new file mode 100644
index 0000000..9fe3e0d
--- /dev/null
+++ b/src/include/jtagtap.h
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the Black Magic Debug project.
+ *
+ * Copyright (C) 2011 Black Sphere Technologies Ltd.
+ * Written by Gareth McMullin <gareth@blacksphere.co.nz>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __JTAGTAP_H
+#define __JTAGTAP_H
+
+#include "general.h"
+
+/* Note: Signal names are as for the device under test. */
+
+int jtagtap_init(void);
+
+void jtagtap_reset(void);
+
+void jtagtap_srst(void);
+
+uint8_t jtagtap_next(const uint8_t TMS, const uint8_t TDI);
+/* tap_next executes one state transision in the JTAG TAP state machine:
+ * - Ensure TCK is low
+ * - Assert the values of TMS and TDI
+ * - Assert TCK (TMS and TDO are latched on rising edge
+ * - Caputure the value on TDO
+ * - Release TCK.
+ */
+
+void jtagtap_tms_seq(uint32_t MS, int ticks);
+void jtagtap_tdi_tdo_seq(uint8_t *DO, const uint8_t final_tms, const uint8_t *DI, int ticks);
+void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks);
+/* Shift out a sequence on MS and DI, capture data to DO.
+ * - This is not endian safe: First byte will always be first shifted out.
+ * - DO may be NULL to ignore captured data.
+ * - DO may be point to the same address as DI.
+ */
+
+/* generic soft reset: 1, 1, 1, 1, 1, 0 */
+#define jtagtap_soft_reset() \
+ jtagtap_tms_seq(0x1F, 6)
+
+/* Goto Shift-IR: 1, 1, 0, 0 */
+#define jtagtap_shift_ir() \
+ jtagtap_tms_seq(0x03, 4)
+
+/* Goto Shift-DR: 1, 0, 0 */
+#define jtagtap_shift_dr() \
+ jtagtap_tms_seq(0x01, 3)
+
+/* Goto Run-test/Idle: 1, 1, 0 */
+#define jtagtap_return_idle() \
+ jtagtap_tms_seq(0x01, 2)
+
+#endif
+