cleaning up jtag, jtag430, jtag430x2, jtagarm7tdmi includes
[goodfet] / firmware / include / jtag430.h
1 /*! \file jtag430.h
2   \author Travis Goodspeed
3   \brief JTAG handler functions.
4 */
5
6
7 #include "jtag.h"
8
9 extern unsigned int drwidth;
10
11 #define MSP430MODE 0
12 #define MSP430XMODE 1
13 #define MSP430X2MODE 2
14 extern unsigned int jtag430mode;
15
16 // JTAG430 Commands
17
18 //! Start JTAG, unique to the '430.
19 void jtag430_start();
20 //! Reset the TAP state machine, check the fuse.
21 void jtag430_resettap();
22
23 //! Defined in jtag430asm.S
24 void jtag430_tclk_flashpulses(int);
25
26 //High-level Macros follow
27 //! Write data to address.
28 void jtag430_writemem(unsigned int adr, unsigned int data);
29 //! Read data from address
30 unsigned int jtag430_readmem(unsigned int adr);
31 //! Halt the CPU
32 void jtag430_haltcpu();
33 //! Release the CPU
34 void jtag430_releasecpu();
35 //! Set CPU to Instruction Fetch
36 void jtag430_setinstrfetch();
37 //! Set the program counter.
38 void jtag430_setpc(unsigned int adr);
39 //! Write data to address.
40 void jtag430_writeflash(unsigned int adr, unsigned int data);
41
42
43 //16-bit MSP430 JTAG commands, bit-swapped
44 #define IR_CNTRL_SIG_16BIT         0xC8   // 0x13
45 #define IR_CNTRL_SIG_CAPTURE       0x28   // 0x14
46 #define IR_CNTRL_SIG_RELEASE       0xA8   // 0x15
47 // Instructions for the JTAG Fuse
48 #define IR_PREPARE_BLOW            0x44   // 0x22
49 #define IR_EX_BLOW                 0x24   // 0x24
50 // Instructions for the JTAG data register
51 #define IR_DATA_16BIT              0x82   // 0x41
52 #define IR_DATA_QUICK              0xC2   // 0x43
53 // Instructions for the JTAG PSA mode
54 #define IR_DATA_PSA                0x22   // 0x44
55 #define IR_SHIFT_OUT_PSA           0x62   // 0x46
56 // Instructions for the JTAG address register
57 #define IR_ADDR_16BIT              0xC1   // 0x83
58 #define IR_ADDR_CAPTURE            0x21   // 0x84
59 #define IR_DATA_TO_ADDR            0xA1   // 0x85
60 // Bypass instruction
61 #define IR_BYPASS                  0xFF   // 0xFF
62
63 //MSP430X2 unique
64 #define IR_COREIP_ID               0xE8   // 0x17 
65 #define IR_DEVICE_ID               0xE1   // 0x87
66
67 //MSP430 or MSP430X
68 #define MSP430JTAGID 0x89
69 //MSP430X2 only
70 #define MSP430X2JTAGID 0x91
71
72 //! Syncs a POR.
73 unsigned int jtag430x2_syncpor();
74 //! Executes an MSP430X2 POR
75 unsigned int jtag430x2_por();
76 //! Power-On Reset
77 void jtag430_por();
78
79
80 //JTAG430 commands
81 #define JTAG430_HALTCPU 0xA0
82 #define JTAG430_RELEASECPU 0xA1
83 #define JTAG430_SETINSTRFETCH 0xC1
84 #define JTAG430_SETPC 0xC2
85 #define JTAG430_SETREG 0xD2
86 #define JTAG430_GETREG 0xD3
87
88 #define JTAG430_WRITEMEM 0xE0
89 #define JTAG430_WRITEFLASH 0xE1
90 #define JTAG430_READMEM 0xE2
91 #define JTAG430_ERASEFLASH 0xE3
92 #define JTAG430_ERASECHECK 0xE4
93 #define JTAG430_VERIFYMEM 0xE5
94 #define JTAG430_BLOWFUSE 0xE6
95 #define JTAG430_ISFUSEBLOWN 0xE7
96 #define JTAG430_ERASEINFO 0xE8
97 #define JTAG430_COREIP_ID 0xF0
98 #define JTAG430_DEVICE_ID 0xF1