Skip to main content

adept2_sys/
djtag.rs

1/*    This header file contains the interface declarations for the      */
2/*    applications programming interface to the Digilent djtg.DLL       */
3/*                                                                      */
4/*    This DLL provides API services to provide the JTAG                */
5/*    application protocol for Adept2.                                  */
6
7// Define port properties bits for JTAG ports.
8use dpcdecl::*;
9use std::os::raw::c_char;
10
11/// port supports set speed call
12pub const dprpJtgSetSpeed: DPRP = 0x00000001;
13/// device fully implements DjtgSetTmsTdiTck
14pub const dprpJtgSetPinState: DPRP = 0x00000002;
15/// port supports transaction buffering
16pub const dprpJtgTransBuffering: DPRP = 0x00000004;
17/// port supports DjtgWait
18pub const dprpJtgWait: DPRP = 0x00000008;
19/// port supports DjtgSetDelayCnt and DjtgGetDelayCnt
20pub const dprpJtgDelayCnt: DPRP = 0x00000010;
21/// port supports DjtgSetReadyCnt and DjtgGetReadyCnt
22pub const dprpJtgReadyCnt: DPRP = 0x00000020;
23/// port supports DjtgEscape
24pub const dprpJtgEscape: DPRP = 0x00000040;
25/// port supports the MScan format
26pub const dprpJtgMScan: DPRP = 0x00000080;
27/// port supports the OScan0 format
28pub const dprpJtgOScan0: DPRP = 0x00000100;
29/// port supports the OScan1 format
30pub const dprpJtgOScan1: DPRP = 0x00000200;
31/// port supports the OScan2 format
32pub const dprpJtgOScan2: DPRP = 0x00000400;
33/// port supports the OScan3 format
34pub const dprpJtgOScan3: DPRP = 0x00000800;
35/// port supports the OScan4 format
36pub const dprpJtgOScan4: DPRP = 0x00001000;
37/// port supports the OScan5 format
38pub const dprpJtgOScan5: DPRP = 0x00002000;
39/// port supports the OScan6 format
40pub const dprpJtgOScan6: DPRP = 0x00004000;
41/// port supports the OScan7 format
42pub const dprpJtgOScan7: DPRP = 0x00008000;
43/// port supports DjtgCheckPacket
44pub const dprpJtgCheckPacket: DPRP = 0x00010000;
45/// port supports DjtgBatch
46pub const dprpJtgBatch: DPRP = 0x00020000;
47/// port supports DjtgSetAuxReset
48pub const dprpJtgSetAuxReset: DPRP = 0x00040000;
49/// port supports DjtgSetGpioState and related functions
50pub const dprpJtgSetGetGpio: DPRP = 0x00080000;
51
52// Define the symbols used to specify the scan format when calling
53// DjtgSetScanFormat.
54
55pub const jtgsfNone: u8 = 0;
56pub const jtgsfJScan0: u8 = 1;
57pub const jtgsfJScan1: u8 = 2;
58pub const jtgsfJScan2: u8 = 3;
59pub const jtgsfJScan3: u8 = 4;
60pub const jtgsfMScan: u8 = 5;
61pub const jtgsfOScan0: u8 = 6;
62pub const jtgsfOScan1: u8 = 7;
63pub const jtgsfOScan2: u8 = 8;
64pub const jtgsfOScan3: u8 = 9;
65pub const jtgsfOScan4: u8 = 10;
66pub const jtgsfOScan5: u8 = 11;
67pub const jtgsfOScan6: u8 = 12;
68pub const jtgsfOScan7: u8 = 13;
69
70// Define the symbols used to specify the edge count when calling
71// DjtgEscape.
72
73/// Number of edges for a Custom Escape
74pub const cedgeJtgCustom: u8 = 2;
75/// Number of edges for a Deselection Escape
76pub const cedgeJtgDeselect: u8 = 4;
77/// Number of edges for a Selection Escape
78pub const cedgeJtgSelect: u8 = 6;
79/// Number of edges for a Reset Escape
80pub const cedgeJtgReset: u8 = 8;
81
82/* ------------------------------------------------------------ */
83/*              JTG Batch Command Declarations                  */
84/* ------------------------------------------------------------ */
85
86pub const jcbSetTmsTdiTck: u32 = 1;
87pub const jcbGetTmsTdiTdoTck: u32 = 2;
88pub const jcbPutTms: u32 = 3;
89pub const jcbPutTmsGetTdo: u32 = 4;
90pub const jcbPutTdi: u32 = 5;
91pub const jcbPutTdiGetTdo: u32 = 6;
92pub const jcbGetTdo: u32 = 7;
93pub const jcbClockTck: u32 = 8;
94pub const jcbWaitUs: u32 = 9;
95pub const jcbSetAuxReset: u32 = 10;
96pub const jcbGetGpioMask: u32 = 11;
97pub const jcbSetGpioDir: u32 = 12;
98pub const jcbGetGpioDir: u32 = 13;
99pub const jcbSetGpioState: u32 = 14;
100pub const jcbGetGpioState: u32 = 15;
101
102pub const djbpWaitUs: u32 = 0x00000001;
103pub const djbpSetAuxReset: u32 = 0x00000002;
104pub const djbpSetGetGpio: u32 = 0x00000004;
105
106extern "C" {
107    pub fn DjtgGetVersion(szVersion: *mut c_char) -> BOOL;
108    pub fn DjtgGetPortCount(hif: HIF, pcprt: *mut i32) -> BOOL;
109    pub fn DjtgGetPortProperties(hif: HIF, prtReq: i32, pdprp: *mut u32) -> BOOL;
110    pub fn DjtgGetBatchProperties(hif: HIF, prtReq: i32, pdjbp: *mut u32) -> BOOL;
111    pub fn DjtgEnable(hif: HIF) -> BOOL;
112    pub fn DjtgEnableEx(hif: HIF, prtReq: i32) -> BOOL;
113    pub fn DjtgDisable(hif: HIF) -> BOOL;
114
115    // configuration functions
116    pub fn DjtgGetSpeed(hif: HIF, pfrqCur: *mut u32) -> BOOL;
117    pub fn DjtgSetSpeed(hif: HIF, frqReq: u32, pfrqSet: *mut u32) -> BOOL;
118    pub fn DjtgSetTmsTdiTck(hif: HIF, fTms: BOOL, fTdi: BOOL, fTck: BOOL) -> BOOL;
119    pub fn DjtgGetTmsTdiTdoTck(
120        hif: HIF,
121        pfTms: *mut BOOL,
122        pfTdi: *mut BOOL,
123        pfTdo: *mut BOOL,
124        pfTck: *mut BOOL,
125    ) -> BOOL;
126    pub fn DjtgSetAuxReset(hif: HIF, fReset: BOOL, fEnOutput: BOOL) -> BOOL;
127    pub fn DjtgEnableTransBuffering(hif: HIF, fEnable: BOOL) -> BOOL;
128    pub fn DjtgSyncBuffer(hif: HIF) -> BOOL;
129
130    // misc. functions
131    pub fn DjtgWait(hif: HIF, tusWait: u32, ptusWaited: *mut u32) -> BOOL;
132
133    // gpio functions
134    pub fn DjtgGetGpioMask(hif: HIF, pfsMaskOut: *mut u32, pfsMaskIn: *mut u32) -> BOOL;
135    pub fn DjtgSetGpioDir(hif: HIF, fsDirReq: u32, pfsDirSet: *mut u32) -> BOOL;
136    pub fn DjtgGetGpioDir(hif: HIF, pfsDir: *mut u32) -> BOOL;
137    pub fn DjtgSetGpioState(hif: HIF, fsState: u32) -> BOOL;
138    pub fn DjtgGetGpioState(hif: HIF, pfsState: *mut u32) -> BOOL;
139
140    // overlapped functions
141    pub fn DjtgPutTdiBits(
142        hif: HIF,
143        fTms: BOOL,
144        rgbSnd: *mut u8,
145        rgbRcv: *mut u8,
146        cbits: u32,
147        fOverlap: BOOL,
148    ) -> BOOL;
149    pub fn DjtgPutTmsBits(
150        hif: HIF,
151        fTdi: BOOL,
152        rgbSnd: *mut u8,
153        rgbRcv: *mut u8,
154        cbits: u32,
155        fOverlap: BOOL,
156    ) -> BOOL;
157    pub fn DjtgPutTmsTdiBits(
158        hif: HIF,
159        rgbSnd: *mut u8,
160        rgbRcv: *mut u8,
161        cbitpairs: u32,
162        fOverlap: BOOL,
163    ) -> BOOL;
164    pub fn DjtgGetTdoBits(
165        hif: HIF,
166        fTdi: BOOL,
167        fTms: BOOL,
168        rgbRcv: *mut u8,
169        cbits: u32,
170        fOverlap: BOOL,
171    ) -> BOOL;
172    pub fn DjtgClockTck(hif: HIF, fTms: BOOL, fTdi: BOOL, cclk: u32, fOverlap: BOOL) -> BOOL;
173    pub fn DjtgBatch(
174        hif: HIF,
175        cbSnd: u32,
176        rgbSnd: *mut u8,
177        cbRcv: u32,
178        rgbRcv: *mut u8,
179        fOverlap: BOOL,
180    ) -> BOOL;
181
182    // 1149.7-2009 configuration functions
183    pub fn DjtgSetScanFormat(hif: HIF, jtgsfFmt: u8, fShiftXR: BOOL) -> BOOL;
184    pub fn DjtgGetScanFormat(hif: HIF, pjtgsfFmt: *mut u8, pfShiftXR: *mut BOOL) -> BOOL;
185    pub fn DjtgSetReadyCnt(
186        hif: HIF,
187        cbitRdy: u8,
188        pcretOutReq: *mut u32,
189        pcretOutSet: *mut u32,
190    ) -> BOOL;
191    pub fn DjtgGetReadyCnt(hif: HIF, pcbitRdy: *mut u8, pcretOut: *mut u32) -> BOOL;
192    pub fn DjtgSetDelayCnt(hif: HIF, cbitDlyReq: u32, pcbitDlySet: *mut u32, fReset: BOOL) -> BOOL;
193    pub fn DjtgGetDelayCnt(hif: HIF, pcbitDly: *mut u32, pfReset: *mut BOOL) -> BOOL;
194
195    // 1149.7-2009 misc. functions
196    pub fn DjtgCheckPacket(hif: HIF, cedgeNop: u8, fReset: BOOL, fOverlap: BOOL) -> BOOL;
197    pub fn DjtgEscape(hif: HIF, cedgeEsc: u8, fOverlap: BOOL) -> BOOL;
198}