4fa8a66c3c9e166f1bb4d0fcd18a1b58447da9ad
[openocd.git] / src / jtag / drivers / rlink_dtc_cmd.h
blob4fa8a66c3c9e166f1bb4d0fcd18a1b58447da9ad
1 /***************************************************************************
2 * Copyright (C) 2008 Lou Deluxe *
3 * lou.openocd012@fixit.nospammail.net *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 /* A command position with the high nybble of 0x0 is reserved for an error condition.
22 * If executed, it stops the DTC and raises the ERROR flag */
24 #define DTC_CMD_SHIFT_TMS_BYTES(bytes) ((0x1 << 4) | ((bytes) - 1))
25 /* Shift 1-16 bytes out TMS. TDI is 0. */
26 /* Bytes to shift follow. */
28 #define DTC_CMD_SHIFT_TDI_BYTES(bytes) ((0x2 << 4) | ((bytes) - 1))
29 /* Shift 1-16 bytes out TDI. TMS is 0. */
30 /* Bytes to shift follow. */
32 #define DTC_CMD_SHIFT_TDI_AND_TMS_BYTES(bytes) ((0x3 << 4) | ((bytes) - 1))
33 /* Shift 1-16 byte pairs out TDI and TMS. */
34 /* Byte pairs to shift follow in TDI, TMS order. */
36 #define DTC_CMD_SHIFT_TDO_BYTES(bytes) ((0x4 << 4) | ((bytes) - 1))
37 /* Shift 1-16 bytes in TDO. TMS is unaffected. */
38 /* Reply buffer contains bytes shifted in. */
40 #define DTC_CMD_SHIFT_TDIO_BYTES(bytes) ((0x6 << 4) | ((bytes) - 1))
41 /* Shift 1-16 bytes out TDI and in TDO. TMS is unaffected. */
43 #define DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(tms, tdi, tdo) ((0x8 << 4) | (\
44 (tms) ? (1 << 0) : 0 \
45 ) | (\
46 (tdi) ? (1 << 1) : 0 \
47 ) | (\
48 (tdo) ? (1 << 3) : 0 \
50 /* Single bit shift.
51 * tms and tdi are the levels shifted out on TMS and TDI, respectively.
52 * tdo indicates whether a byte will be returned in the reply buffer with its
53 * least significant bit set to reflect TDO
54 * Care should be taken when tdo is zero, as the underlying code actually does put
55 * that byte in the reply buffer. Setting tdo to zero just moves the pointer back.
56 * The result is that if this command is executed when the reply buffer is already full,
57 * a byte will be written erroneously to memory not belonging to the reply buffer.
58 * This could be worked around at the expense of DTC code space and speed. */
60 #define DTC_CMD_SHIFT_TMS_BITS(bits) ((0x9 << 4) | ((bits) - 1))
61 /* Shift 1-8 bits out TMS. */
62 /* Bits to be shifted out are left justified in the following byte. */
64 #define DTC_CMD_SHIFT_TDIO_BITS(bits) ((0xe << 4) | ((bits) - 1))
65 /* Shift 1-8 bits out TDI and in TDO, TMS is unaffected. */
66 /* Bits to be shifted out are left justified in the following byte. */
67 /* Bits shifted in are right justified in the byte placed in the reply buffer. */
69 #define DTC_CMD_STOP (0xf << 4)
70 /* Stop processing the command buffer and wait for the next one. */
71 /* A shared status byte is updated with bit 0 set when this has happened,
72 * and it is cleared when a new command buffer becomes ready.
73 * The host can poll that byte to see when it is safe to read a reply. */