9 //! Shift 8 bits of the IR.
10 unsigned char jtag_ir_shift8(unsigned char);
11 //! Shift 16 bits of the DR.
12 unsigned int jtag_dr_shift16(unsigned int);
13 //! Stop JTAG, release pins
19 //! Start JTAG, unique to the '430.
21 //! Reset the TAP state machine, check the fuse.
22 void jtag430_resettap();
24 //High-level Macros follow
25 //! Write data to address.
26 void jtag430_writemem(unsigned int adr, unsigned int data);
27 //! Read data from address
28 unsigned int jtag430_readmem(unsigned int adr);
30 void jtag430_haltcpu();
32 void jtag430_releasecpu();
33 //! Set CPU to Instruction Fetch
34 void jtag430_setinstrfetch();
35 //! Set the program counter.
36 void jtag430_setpc(unsigned int adr);
37 //! Write data to address.
38 void jtag430_writeflash(unsigned int adr, unsigned int data);
40 //Pins. Both SPI and JTAG names are acceptable.
57 //This could be more accurate.
58 //Does it ever need to be?
60 #define JTAGDELAY(x) delay(x)
62 #define SETMOSI P5OUT|=MOSI
63 #define CLRMOSI P5OUT&=~MOSI
64 #define SETCLK P5OUT|=SCK
65 #define CLRCLK P5OUT&=~SCK
66 #define READMISO (P5IN&MISO?1:0)
67 #define SETTMS P5OUT|=TMS
68 #define CLRTMS P5OUT&=~TMS
69 #define SETTCK P5OUT|=TCK
70 #define CLRTCK P5OUT&=~TCK
71 #define SETTDI P5OUT|=TDI
72 #define CLRTDI P5OUT&=~TDI
74 #define SETTST P4OUT|=TST
75 #define CLRTST P4OUT&=~TST
76 #define SETRST P2OUT|=RST
77 #define CLRRST P2OUT&=~RST
79 #define SETTCLK SETTDI
80 #define CLRTCLK CLRTDI
83 #define SAVETCLK savedtclk=P5OUT&TCLK;
84 #define RESTORETCLK if(savedtclk) P5OUT|=TCLK; else P5OUT&=~TCLK
86 //JTAG commands, bit-swapped
87 #define IR_CNTRL_SIG_16BIT 0xC8 // 0x13
88 #define IR_CNTRL_SIG_CAPTURE 0x28 // 0x14
89 #define IR_CNTRL_SIG_RELEASE 0xA8 // 0x15
90 // Instructions for the JTAG Fuse
91 #define IR_PREPARE_BLOW 0x44 // 0x22
92 #define IR_EX_BLOW 0x24 // 0x24
93 // Instructions for the JTAG data register
94 #define IR_DATA_16BIT 0x82 // 0x41
95 #define IR_DATA_QUICK 0xC2 // 0x43
96 // Instructions for the JTAG PSA mode
97 #define IR_DATA_PSA 0x22 // 0x44
98 #define IR_SHIFT_OUT_PSA 0x62 // 0x46
99 // Instructions for the JTAG address register
100 #define IR_ADDR_16BIT 0xC1 // 0x83
101 #define IR_ADDR_CAPTURE 0x21 // 0x84
102 #define IR_DATA_TO_ADDR 0xA1 // 0x85
103 // Bypass instruction
104 #define IR_BYPASS 0xFF // 0xFF