summaryrefslogtreecommitdiffstats
path: root/src/jtag.h
blob: 2bdb32205458f769758a36a4221b9eeb8a996140 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdint.h>
#include <fcntl.h>


class CJTAG {
	public:
		enum JTAG_STATE {
			ST_UNDEFINED,
			ST_TEST_LOGIC_RESET,
			ST_RUN_TEST_IDLE,
			ST_SELECT_DR_SCAN,
			ST_CAPTURE_DR,
			ST_SHIFT_DR,
			ST_EXIT_DR,
			ST_PAUSE_DR,
			ST_EXIT2_DR,
			ST_UPDATE_DR,
			ST_SELECT_IR_SCAN,
			ST_CAPTURE_IR,
			ST_SHIFT_IR,
			ST_EXIT_IR,
			ST_PAUSE_IR,
			ST_EXIT2_IR,
			ST_UPDATE_IR
		} ;
		CJTAG() ;
		~CJTAG() ;

		bool open( char *dev ) ;
		void close() ;

		void selectIR() ;
		void setIR( bool *instruction, int len ) ;
		void exitIR( bool b ) ;

		void selectDR() ;
		void setDR( bool *data, bool *out, int len ) ;			// 'data' is replaced by data that is read.
		bool exitDR( bool data ) ;


		void selectRunTestIdle() ;
		void selectTestLogicReset() ;

		bool execute( bool TMS, bool TDI ) ;

		void setVerbose( bool verbose ) ;

		void printState() ;

		bool isOpen() ;
	private:
		void error( char *str ) ;
		bool step( bool TMS, bool TDI ) ;

		int m_fd ;
		bool m_open ;
		enum JTAG_STATE m_state ;

		bool m_verbose ;

} ;