X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Fapps%2Fjtag%2Fjtag.c;h=ccddf2f8f3a88efc1509f4317425bedb4d2e4491;hp=b813d5d0ea7c990014723c42ed2ab16cbfe8ff9f;hb=HEAD;hpb=cfbda5b069e5c792b4b3a91911c3fc9844b68fbc diff --git a/firmware/apps/jtag/jtag.c b/firmware/apps/jtag/jtag.c index b813d5d..ccddf2f 100644 --- a/firmware/apps/jtag/jtag.c +++ b/firmware/apps/jtag/jtag.c @@ -74,18 +74,18 @@ int in_state(enum eTAPState state) void jtag_reset_target() { SETRST; - PLEDOUT^=PLEDPIN; + led_toggle(); CLRRST; - PLEDOUT^=PLEDPIN; + led_toggle(); } //! Clock the JTAG clock line void jtag_tcktock() { CLRTCK; - PLEDOUT^=PLEDPIN; + led_toggle(); SETTCK; - PLEDOUT^=PLEDPIN; + led_toggle(); } //! Goes through test-logic-reset and ends in run-test-idle @@ -253,8 +253,8 @@ int savedtclk; // subsystem does not want to return to the RUN-TEST/IDLE state between // setting IR and DR uint32_t jtag_trans_n(uint32_t word, - uint8_t bitcount, - enum eTransFlags flags) + uint8_t bitcount, + enum eTransFlags flags) { uint8_t bit; uint32_t high = (1L << (bitcount - 1)); @@ -325,7 +325,13 @@ uint32_t jtag_trans_n(uint32_t word, word |= (READMISO); } } - + + //This is needed for 20-bit MSP430 chips. + //Might break another 20-bit chip, if one exists. + if(bitcount==20){ + word = ((word << 16) | (word >> 4)) & 0x000FFFFF; + } + RESTORETCLK; if (!(flags & NOEND)) @@ -513,6 +519,10 @@ uint16_t jtag_trans_16(uint16_t in) //! Shift 8 bits of the IR. uint8_t jtag_ir_shift_8(uint8_t in) { + /* Huseby's code, which breaks MSP430 support. + The code is broken because either the invalid jtag state error + causes the client to give up, or because it adds an extra clock edge. + if (!in_run_test_idle()) { debugstr("Not in run-test-idle state"); @@ -522,9 +532,24 @@ uint8_t jtag_ir_shift_8(uint8_t in) // get intot the right state jtag_capture_ir(); jtag_shift_register(); - - // shift IR bits - return jtag_trans_8(in); + */ + + + + // idle + SETTMS; + jtag_tcktock(); + // select DR + jtag_tcktock(); + // select IR + CLRTMS; + jtag_tcktock(); + // capture IR + jtag_tcktock(); + //jtag_state = CAPTURE_IR; + jtag_state = SHIFT_IR; + // shift IR bits + return jtag_trans_8(in); } //! Shift 16 bits of the DR.