nit: more LOG_* \n fixes
[fw/openocd] / src / jtag / drivers / bitbang.c
index 69c17298849007592828bd3d4d58529b0b84fd93..4548cb531ed33683d8155f52c99d53ab77c523a7 100644 (file)
@@ -25,8 +25,8 @@
 #endif
 
 #include "bitbang.h"
-#include "interface.h"
-#include "commands.h"
+#include <jtag/interface.h>
+#include <jtag/commands.h>
 
 /**
  * Function bitbang_stableclocks
@@ -91,6 +91,31 @@ static void bitbang_state_move(int skip)
        tap_set_state(tap_get_end_state());
 }
 
+
+/**
+ * Clock a bunch of TMS (or SWDIO) transitions, to change the JTAG
+ * (or SWD) state machine.
+ */
+static int bitbang_execute_tms(struct jtag_command *cmd)
+{
+       unsigned        num_bits = cmd->cmd.tms->num_bits;
+       const uint8_t   *bits = cmd->cmd.tms->bits;
+
+       DEBUG_JTAG_IO("TMS: %d bits", num_bits);
+
+       int tms = 0;
+       for (unsigned i = 0; i < num_bits; i++)
+       {
+               tms = ((bits[i/8] >> (i % 8)) & 1);
+               bitbang_interface->write(0, tms, 0);
+               bitbang_interface->write(1, tms, 0);
+       }
+       bitbang_interface->write(CLOCK_IDLE(), tms, 0);
+
+       return ERROR_OK;
+}
+
+
 static void bitbang_path_move(struct pathmove_command *cmd)
 {
        int num_states = cmd->num_states;
@@ -279,7 +304,7 @@ int bitbang_execute_queue(void)
                                bitbang_stableclocks(cmd->cmd.stableclocks->num_cycles);
                                break;
 
-                       case JTAG_STATEMOVE:
+                       case JTAG_TLR_RESET:
 #ifdef _DEBUG_JTAG_IO_
                                LOG_DEBUG("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state));
 #endif
@@ -312,6 +337,9 @@ int bitbang_execute_queue(void)
 #endif
                                jtag_sleep(cmd->cmd.sleep->us);
                                break;
+                       case JTAG_TMS:
+                               retval = bitbang_execute_tms(cmd);
+                               break;
                        default:
                                LOG_ERROR("BUG: unknown JTAG command type encountered");
                                exit(-1);