X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=firmware%2Finclude%2Fjtag.h;h=2d09c2c19bab5dc88a74b01834eed65415afc686;hb=875dc40329fd39cf956d5e0361f7350a01c240a2;hp=17833d66a3bf6784dd9791199242d476697bbccb;hpb=a653ba1562dc444e4be791e22264a89a3c6b4a19;p=goodfet diff --git a/firmware/include/jtag.h b/firmware/include/jtag.h index 17833d6..2d09c2c 100644 --- a/firmware/include/jtag.h +++ b/firmware/include/jtag.h @@ -1,3 +1,10 @@ +/*! \file jtag.h + \author Travis Goodspeed + \brief JTAG handler functions. +*/ + +#ifndef JTAG_H +#define JTAG_H #include #include @@ -6,36 +13,32 @@ // Generic Commands +//! Shift n bytes. +unsigned long jtagtransn(unsigned long word, + unsigned char bitcount, + unsigned char flags); +//! Shift the address width. +unsigned long jtag_dr_shiftadr(unsigned long in); //! Shift 8 bits of the IR. unsigned char jtag_ir_shift8(unsigned char); //! Shift 16 bits of the DR. unsigned int jtag_dr_shift16(unsigned int); +//! Shift 20 bits of the DR, MSP430 specific. +unsigned long jtag_dr_shift20(unsigned long in); //! Stop JTAG, release pins void jtag_stop(); +//! Setup the JTAG pin directions. +void jtagsetup(); -// JTAG430 Commands - -//! Start JTAG, unique to the '430. -void jtag430_start(); -//! Reset the TAP state machine, check the fuse. -void jtag430_resettap(); - -//High-level Macros follow -//! Write data to address. -void jtag430_writemem(unsigned int adr, unsigned int data); -//! Read data from address -unsigned int jtag430_readmem(unsigned int adr); -//! Halt the CPU -void jtag430_haltcpu(); -//! Release the CPU -void jtag430_releasecpu(); -//! Set CPU to Instruction Fetch -void jtag430_setinstrfetch(); -//! Set the program counter. -void jtag430_setpc(unsigned int adr); -//! Write data to address. -void jtag430_writeflash(unsigned int adr, unsigned int data); +//! Ratchet Clock Down and Up +void jtag_tcktock(); +//! Go to SHIFT_IR +void jtag_goto_shift_ir(); +//! Go to SHIFT_DR +void jtag_goto_shift_dr(); +//! TAP RESET +void jtag_resettap(); //Pins. Both SPI and JTAG names are acceptable. //#define SS BIT0 @@ -83,23 +86,39 @@ extern int savedtclk; #define SAVETCLK savedtclk=P5OUT&TCLK; #define RESTORETCLK if(savedtclk) P5OUT|=TCLK; else P5OUT&=~TCLK -//JTAG commands, bit-swapped -#define IR_CNTRL_SIG_16BIT 0xC8 // 0x13 -#define IR_CNTRL_SIG_CAPTURE 0x28 // 0x14 -#define IR_CNTRL_SIG_RELEASE 0xA8 // 0x15 -// Instructions for the JTAG Fuse -#define IR_PREPARE_BLOW 0x44 // 0x22 -#define IR_EX_BLOW 0x24 // 0x24 -// Instructions for the JTAG data register -#define IR_DATA_16BIT 0x82 // 0x41 -#define IR_DATA_QUICK 0xC2 // 0x43 -// Instructions for the JTAG PSA mode -#define IR_DATA_PSA 0x22 // 0x44 -#define IR_SHIFT_OUT_PSA 0x62 // 0x46 -// Instructions for the JTAG address register -#define IR_ADDR_16BIT 0xC1 // 0x83 -#define IR_ADDR_CAPTURE 0x21 // 0x84 -#define IR_DATA_TO_ADDR 0xA1 // 0x85 -// Bypass instruction -#define IR_BYPASS 0xFF // 0xFF - +//Replace every "CLRTCK SETTCK" with this. +#define TCKTOCK CLRTCK,SETTCK + +//JTAG commands +#define JTAG_IR_SHIFT 0x80 +#define JTAG_DR_SHIFT 0x81 +#define JTAG_RESETTAP 0x82 +#define JTAG_RESETTARGET 0x83 +#define JTAG_DR_SHIFT20 0x91 + +#define MSB 0 +#define LSB 1 +#define NOEND 2 +#define NORETIDLE 4 + + +//JTAG430 commands +//#include "jtag430.h" +#define Exit2_DR 0x0 +#define Exit_DR 0x1 +#define Shift_DR 0x2 +#define Pause_DR 0x3 +#define Select_IR 0x4 +#define Update_DR 0x5 +#define Capture_DR 0x6 +#define Select_DR 0x7 +#define Exit2_IR 0x8 +#define Exit_IR 0x9 +#define Shift_IR 0xa +#define Pause_IR 0xb +#define RunTest_Idle 0xc +#define Update_IR 0xd +#define Capture_IR 0xe +#define Test_Reset 0xf + +#endif