forked from ddk/ddk-arm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jtag_1149.h
145 lines (117 loc) · 4.51 KB
/
jtag_1149.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2013, The DDK Project
* Dmitry Nedospasov <dmitry at nedos dot net>
* Thorsten Schroeder <ths at modzero dot ch>
*
* All rights reserved.
*
* This file is part of Die Datenkrake (DDK).
*
* "THE BEER-WARE LICENSE" (Revision 42):
* <dmitry at nedos dot net> and <ths at modzero dot ch> wrote this file. As
* long as you retain this notice you can do whatever you want with this stuff.
* If we meet some day, and you think this stuff is worth it, you can buy us a
* beer in return. Die Datenkrake Project.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE DDK PROJECT BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* File: jtag_1149.h
* Description: Header & definitions of JTAG related functions (for programming the FPGA).
*
*/
#ifndef _JTAG1149_H
#define _JTAG1149_H
#include <LPC17xx.h>
#include <stdint.h>
#define PIN 0 // input
#define POUT 1 // output
#define TCK_PERIOD 10
void jtag_init(void);
typedef enum __cmd_signal {
TMS = 1,
TDI = 2,
TRST = 4,
TDO = 8
} jtag_cmd_signal_t;
/*
test setup, using olimex stk-1766:
target olimex
=================================================
TRST = 3 = rot UEXT9 / 0.7 (SCK1)
TDI = 5 = orange UEXT5 / 0.11 (SCL2)
TMS = 7 = gelb UEXT8 / 0.9 (MOSI1)
TCK = 9 = gruen UEXT7 / 0.8 (MISO1)
TDO = 13 = blau UEXT6 / 0.10 (SDA2)
GND UEXT2
UEXT:
+----------------+
| 2 4 6 8 10 |
| 1 3 5 7 9 |
+------ ------+
*/
#define JTAG_PORT 1
#define JTAG_TDOPIN 1
#define JTAG_TDOPORT 1
#define JTAG_TDO (1 << JTAG_TDOPIN)
#define JTAG_TDODIR LPC_GPIO1->FIODIR
#define JTAG_TDOMASK LPC_GPIO1->FIOMASK
#define JTAG_TDOSET LPC_GPIO1->FIOSET
#define JTAG_TDOCLR LPC_GPIO1->FIOCLR
#define JTAG_TDOPRT LPC_GPIO1->FIOPIN
#define jtag_TDO_low() ( JTAG_TDOCLR |= JTAG_TDO)
#define jtag_TDO_high() ( JTAG_TDOSET |= JTAG_TDO)
#define jtag_TDO_toggle() ( JTAG_TDOPRT ^= JTAG_TDO)
#define JTAG_TDIPIN 8
#define JTAG_TDIPORT 1
#define JTAG_TDI (1 << JTAG_TDIPIN)
#define JTAG_TDIDIR LPC_GPIO1->FIODIR
#define JTAG_TDIMASK LPC_GPIO1->FIOMASK
#define JTAG_TDISET LPC_GPIO1->FIOSET
#define JTAG_TDICLR LPC_GPIO1->FIOCLR
#define JTAG_TDIPRT LPC_GPIO1->FIOPIN
#define jtag_TDI_low() ( JTAG_TDICLR |= JTAG_TDI)
#define jtag_TDI_high() ( JTAG_TDISET |= JTAG_TDI)
#define jtag_TDI_toggle() ( JTAG_TDIPRT ^= JTAG_TDI)
#define JTAG_TMSPIN 4
#define JTAG_TMSPORT 1
#define JTAG_TMS (1 << JTAG_TMSPIN)
#define JTAG_TMSDIR LPC_GPIO1->FIODIR
#define JTAG_TMSMASK LPC_GPIO1->FIOMASK
#define JTAG_TMSSET LPC_GPIO1->FIOSET
#define JTAG_TMSCLR LPC_GPIO1->FIOCLR
#define JTAG_TMSPRT LPC_GPIO1->FIOPIN
#define jtag_TMS_low() ( JTAG_TMSCLR |= JTAG_TMS)
#define jtag_TMS_high() ( JTAG_TMSSET |= JTAG_TMS)
#define jtag_TMS_toggle() ( JTAG_TMSPRT ^= JTAG_TMS)
#define JTAG_TRSTPIN 9
#define JTAG_TRSTPORT 1
#define JTAG_TRST (1 << JTAG_TRSTPIN)
#define JTAG_TRSTDIR LPC_GPIO1->FIODIR
#define JTAG_TRSTMASK LPC_GPIO1->FIOMASK
#define JTAG_TRSTSET LPC_GPIO1->FIOSET
#define JTAG_TRSTCLR LPC_GPIO1->FIOCLR
#define JTAG_TRSTPRT LPC_GPIO1->FIOPIN
#define jtag_TRST_low() ( JTAG_TRSTCLR |= JTAG_TRST)
#define jtag_TRST_high() ( JTAG_TRSTSET |= JTAG_TRST)
#define jtag_TRST_toggle() ( JTAG_TRSTPRT ^= JTAG_TRST)
#define JTAG_TCKPIN 0
#define JTAG_TCKPORT 1
#define JTAG_TCK (1 << JTAG_TCKPIN)
#define JTAG_TCKDIR LPC_GPIO1->FIODIR
#define JTAG_TCKMASK LPC_GPIO1->FIOMASK
#define JTAG_TCKSET LPC_GPIO1->FIOSET
#define JTAG_TCKCLR LPC_GPIO1->FIOCLR
#define JTAG_TCKPRT LPC_GPIO1->FIOPIN
#define jtag_TCK_low() ( JTAG_TCKCLR |= JTAG_TCK)
#define jtag_TCK_high() ( JTAG_TCKSET |= JTAG_TCK)
#define jtag_TCK_toggle() ( JTAG_TCKPRT ^= JTAG_TCK)
#endif