OpenOCD
rlink_dtc_cmd.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2008 Lou Deluxe *
5  * lou.openocd012@fixit.nospammail.net *
6  ***************************************************************************/
7 
8 #ifndef OPENOCD_JTAG_DRIVERS_RLINK_DTC_CMD_H
9 #define OPENOCD_JTAG_DRIVERS_RLINK_DTC_CMD_H
10 
11 /* A command position with the high nybble of 0x0 is reserved for an error condition.
12  * If executed, it stops the DTC and raises the ERROR flag */
13 
14 #define DTC_CMD_SHIFT_TMS_BYTES(bytes) ((0x1 << 4) | ((bytes) - 1))
15 /* Shift 1-16 bytes out TMS. TDI is 0. */
16 /* Bytes to shift follow. */
17 
18 #define DTC_CMD_SHIFT_TDI_BYTES(bytes) ((0x2 << 4) | ((bytes) - 1))
19 /* Shift 1-16 bytes out TDI. TMS is 0. */
20 /* Bytes to shift follow. */
21 
22 #define DTC_CMD_SHIFT_TDI_AND_TMS_BYTES(bytes) ((0x3 << 4) | ((bytes) - 1))
23 /* Shift 1-16 byte pairs out TDI and TMS. */
24 /* Byte pairs to shift follow in TDI, TMS order. */
25 
26 #define DTC_CMD_SHIFT_TDO_BYTES(bytes) ((0x4 << 4) | ((bytes) - 1))
27 /* Shift 1-16 bytes in TDO. TMS is unaffected. */
28 /* Reply buffer contains bytes shifted in. */
29 
30 #define DTC_CMD_SHIFT_TDIO_BYTES(bytes) ((0x6 << 4) | ((bytes) - 1))
31 /* Shift 1-16 bytes out TDI and in TDO. TMS is unaffected. */
32 
33 #define DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(tms, tdi, tdo) ((0x8 << 4) | (\
34  (tms) ? (1 << 0) : 0 \
35 ) | (\
36  (tdi) ? (1 << 1) : 0 \
37 ) | (\
38  (tdo) ? (1 << 3) : 0 \
39 ))
40 /* Single bit shift.
41  * tms and tdi are the levels shifted out on TMS and TDI, respectively.
42  * tdo indicates whether a byte will be returned in the reply buffer with its
43  * least significant bit set to reflect TDO
44  * Care should be taken when tdo is zero, as the underlying code actually does put
45  * that byte in the reply buffer. Setting tdo to zero just moves the pointer back.
46  * The result is that if this command is executed when the reply buffer is already full,
47  * a byte will be written erroneously to memory not belonging to the reply buffer.
48  * This could be worked around at the expense of DTC code space and speed. */
49 
50 #define DTC_CMD_SHIFT_TMS_BITS(bits) ((0x9 << 4) | ((bits) - 1))
51 /* Shift 1-8 bits out TMS. */
52 /* Bits to be shifted out are left justified in the following byte. */
53 
54 #define DTC_CMD_SHIFT_TDIO_BITS(bits) ((0xe << 4) | ((bits) - 1))
55 /* Shift 1-8 bits out TDI and in TDO, TMS is unaffected. */
56 /* Bits to be shifted out are left justified in the following byte. */
57 /* Bits shifted in are right justified in the byte placed in the reply buffer. */
58 
59 #define DTC_CMD_STOP (0xf << 4)
60 /* Stop processing the command buffer and wait for the next one. */
61 /* A shared status byte is updated with bit 0 set when this has happened,
62  * and it is cleared when a new command buffer becomes ready.
63  * The host can poll that byte to see when it is safe to read a reply. */
64 
65 #endif /* OPENOCD_JTAG_DRIVERS_RLINK_DTC_CMD_H */