2 * DPCUTIL compatibility driver for libnexys
3 * libnexys, a free driver for Digilent NEXYS2 boards
5 * Copyright (c) 2007-2008 Joshua Wise
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
11 * Commercial licenses are available by request.
14 #define LIBNEXYS_INTERNAL
18 nexys2_t nexys2_init(void) {
26 printf("DpcInit failed\n");
30 if ((device = DvmgGetDefaultDev(&erc)) == -1)
32 printf("We appear to lack a default device. Sadface :(\n");
36 DvmgGetDevName(device, devname, &erc);
37 printf("Interacting with device %d (%s)\n", device, devname);
39 if (!DpcOpenJtag(&hand, devname, &erc, NULL))
41 printf("JTAG open failed\n");
47 int nexys2_jtag_enable(HANDLE hand)
50 return DpcEnableJtag(hand, &erc, NULL) ? 0 : -1;
53 int nexys2_jtag_disable(HANDLE hand)
56 return DpcDisableJtag(hand, &erc, NULL) ? 0 : -1;
59 int nexys2_jtag_setbits(HANDLE hand, int tms, int tdi, int tck)
62 return DpcSetTmsTdiTck(hand, tms, tdi, tck, &erc, NULL) ? 0 : -1;
65 int nexys2_jtag_puttdi(HANDLE hand, int tms, int nbits, unsigned char *bits, unsigned char *obits)
68 return DpcPutTdiBits(hand, nbits, bits, tms, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
71 int nexys2_jtag_puttmstdi(HANDLE hand, int nbits, unsigned char *bits, unsigned char *obits)
74 return DpcPutTmsTdiBits(hand, nbits, bits, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
77 int nexys2_jtag_gettdo(HANDLE hand, int tdi, int tms, int nbits, unsigned char *obits)
80 return DpcGetTdoBits(hand, nbits, tdi, tms, obits, &erc, NULL) ? 0 : -1;