# HG changeset patch # User Thinker K.F. Li # Date 1235283657 -28800 # Node ID 61f27549de575cbbe54b119c15dd934902e3f3d7 # Parent 42dec3428c77d00e870ecd1dc8cc108dd9979a42 Support TRST. diff -r 42dec3428c77 -r 61f27549de57 include/cmd_proto.h --- a/include/cmd_proto.h Sun Feb 22 14:12:29 2009 +0800 +++ b/include/cmd_proto.h Sun Feb 22 14:20:57 2009 +0800 @@ -9,6 +9,7 @@ CPCMD_SHIFT_TDI, CPCMD_SHIFT_TMS, CPCMD_SHIFT_TDI_TDO, + CPCMD_TRST, CPCMD_PONG, CPCMD_DATA, CPCMD_ACK, diff -r 42dec3428c77 -r 61f27549de57 include/jtag.h --- a/include/jtag.h Sun Feb 22 14:12:29 2009 +0800 +++ b/include/jtag.h Sun Feb 22 14:20:57 2009 +0800 @@ -9,8 +9,10 @@ #define JTAG_TMS PINB1 #define JTAG_TDI PINB2 #define JTAG_TDO PINB3 +#define JTAG_TRST PINB4 extern void jtag_init(void); +extern void jtag_trst(void); extern void jtag_tms(char *buf, int nbits); extern void jtag_shift(char *buf, int nbits); extern void jtag_shift_inout(char *ibuf, char *obuf, int nbits); diff -r 42dec3428c77 -r 61f27549de57 py_avrjtag/cmd_proto.py --- a/py_avrjtag/cmd_proto.py Sun Feb 22 14:12:29 2009 +0800 +++ b/py_avrjtag/cmd_proto.py Sun Feb 22 14:20:57 2009 +0800 @@ -4,10 +4,11 @@ CPCMD_SHIFT_TDI = 2 CPCMD_SHIFT_TMS = 3 CPCMD_SHIFT_TDI_TDO = 4 -CPCMD_PONG = 5 -CPCMD_DATA = 6 -CPCMD_ACK = 7 -CPCMD_NAK = 8 +CPCMD_TRST = 5 +CPCMD_PONG = 6 +CPCMD_DATA = 7 +CPCMD_ACK = 8 +CPCMD_NAK = 9 def csum_add(csum, c): return (((csum << 3) | (csum >> 5)) ^ c) & 0xff diff -r 42dec3428c77 -r 61f27549de57 src/avr_jtag.c --- a/src/avr_jtag.c Sun Feb 22 14:12:29 2009 +0800 +++ b/src/avr_jtag.c Sun Feb 22 14:20:57 2009 +0800 @@ -120,6 +120,13 @@ send_client(client_buf, bsz); break; + case CPCMD_TRST: + jtag_trst(); + bsz = cmd_proto_cmd_fill(client_buf, cmd->seq, + CPCMD_ACK, 0); + send_client(client_buf, bsz); + break; + default: sprintf(buf, "CODE 0x%02x", cmd->code); nak(cmd->seq, buf); diff -r 42dec3428c77 -r 61f27549de57 src/jtag.c --- a/src/jtag.c Sun Feb 22 14:12:29 2009 +0800 +++ b/src/jtag.c Sun Feb 22 14:20:57 2009 +0800 @@ -30,6 +30,12 @@ } while(0) #define GET_TDO() (JTAG_PIN & _BV(JTAG_TDO)) +void jtag_trst(void) { + SEND_BIT(JTAG_TRST, 1); + TCK_LO(); + pin_lo(JTAG_PORT, JTAG_TRST); +} + /*! * Before shifting registers, TAP controller must move to last state before * shift state. The state machine transite to shift state when shifting