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