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