added filterForPacket method, as discussed with Hoder
[goodfet] / firmware / include / jtag430.h
1 /*! \file jtag430.h
2   \author Travis Goodspeed
3   \brief JTAG handler functions.
4 */
5
6 #ifndef JTAG430_H
7 #define JTAG430_H
8
9 #include "app.h"
10 #include "jtag.h"
11
12 #define JTAG430 0x16
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.  Deprecated.
24 void jtag430_start();
25 //! Same thing, but also for '430X2.
26 unsigned char jtag430x2_start();
27 //! Reset the TAP state machine, check the fuse.
28 void jtag430_resettap();
29
30 //! Defined in jtag430asm.S
31 void jtag430_tclk_flashpulses(int);
32
33 //High-level Macros follow
34 //! Write data to address.
35 void jtag430_writemem(unsigned int adr, unsigned int data);
36 //! Read data from address
37 unsigned int jtag430_readmem(unsigned int adr);
38 //! Halt the CPU
39 void jtag430_haltcpu();
40 //! Release the CPU
41 void jtag430_releasecpu();
42 //! Set CPU to Instruction Fetch
43 void jtag430_setinstrfetch();
44 //! Set the program counter.
45 void jtag430_setpc(unsigned int adr);
46 //! Write data to address.
47 void jtag430_writeflash(unsigned int adr, unsigned int data);
48 //! Shift an address width of data
49 uint32_t jtag430_shift_addr( uint32_t addr );
50
51
52 //16-bit MSP430 JTAG commands, bit-swapped
53 #define IR_CNTRL_SIG_16BIT         0xC8   // 0x13
54 #define IR_CNTRL_SIG_CAPTURE       0x28   // 0x14
55 #define IR_CNTRL_SIG_RELEASE       0xA8   // 0x15
56 // Instructions for the JTAG Fuse
57 #define IR_PREPARE_BLOW            0x44   // 0x22
58 #define IR_EX_BLOW                 0x24   // 0x24
59 // Instructions for the JTAG data register
60 #define IR_DATA_16BIT              0x82   // 0x41
61 #define IR_DATA_QUICK              0xC2   // 0x43
62 // Instructions for the JTAG PSA mode
63 #define IR_DATA_PSA                0x22   // 0x44
64 #define IR_SHIFT_OUT_PSA           0x62   // 0x46
65 // Instructions for the JTAG address register
66 #define IR_ADDR_16BIT              0xC1   // 0x83
67 #define IR_ADDR_CAPTURE            0x21   // 0x84
68 #define IR_DATA_TO_ADDR            0xA1   // 0x85
69 // Bypass instruction
70 #define IR_BYPASS                  0xFF   // 0xFF
71
72 //MSP430X2 unique
73 #define IR_COREIP_ID               0xE8   // 0x17 
74 #define IR_DEVICE_ID               0xE1   // 0x87
75
76 //MSP430 or MSP430X
77 #define MSP430JTAGID 0x89
78 //MSP430X2 only
79 #define MSP430X2JTAGID 0x91
80
81 //! Syncs a POR.
82 unsigned int jtag430x2_syncpor();
83 //! Executes an MSP430X2 POR
84 unsigned int jtag430x2_por();
85 //! Power-On Reset
86 void jtag430_por();
87
88
89 //JTAG430 commands
90 #define JTAG430_HALTCPU 0xA0
91 #define JTAG430_RELEASECPU 0xA1
92 #define JTAG430_SETINSTRFETCH 0xC1
93 #define JTAG430_SETPC 0xC2
94 #define JTAG430_SETREG 0xD2
95 #define JTAG430_GETREG 0xD3
96
97 #define JTAG430_WRITEMEM 0xE0
98 #define JTAG430_WRITEFLASH 0xE1
99 #define JTAG430_READMEM 0xE2
100 #define JTAG430_ERASEFLASH 0xE3
101 #define JTAG430_ERASECHECK 0xE4
102 #define JTAG430_VERIFYMEM 0xE5
103 #define JTAG430_BLOWFUSE 0xE6
104 #define JTAG430_ISFUSEBLOWN 0xE7
105 #define JTAG430_ERASEINFO 0xE8
106 #define JTAG430_COREIP_ID 0xF0
107 #define JTAG430_DEVICE_ID 0xF1
108
109 extern app_t const jtag430_app;
110
111 #endif // JTAG430_H