GPLv2
[s3load.git] / libnexys.win32.c
CommitLineData
de1916b0
JW
1/* libnexys.c
2 * DPCUTIL compatibility driver for libnexys
3 * libnexys, a free driver for Digilent NEXYS2 boards
4 *
5 * Copyright (c) 2007-2008 Joshua Wise
6 *
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.
10 *
11 * Commercial licenses are available by request.
12 */
13
5ee943f9
JW
14#define LIBNEXYS_INTERNAL
15#include "libnexys.h"
16#include <stdio.h>
17
18nexys2_t nexys2_init(void) {
19 int device;
20 char devname[32];
21 HANDLE hand;
22 ERC erc;
23
24 if (!DpcInit(&erc))
25 {
26 printf("DpcInit failed\n");
27 return NULL;
28 }
29
30 if ((device = DvmgGetDefaultDev(&erc)) == -1)
31 {
32 printf("We appear to lack a default device. Sadface :(\n");
33 return NULL;
34 }
35
36 DvmgGetDevName(device, devname, &erc);
37 printf("Interacting with device %d (%s)\n", device, devname);
38
39 if (!DpcOpenJtag(&hand, devname, &erc, NULL))
40 {
41 printf("JTAG open failed\n");
42 return NULL;
43 }
44 return hand;
45}
46
47int nexys2_jtag_enable(HANDLE hand)
48{
49 ERC erc;
50 return DpcEnableJtag(hand, &erc, NULL) ? 0 : -1;
51}
52
53int nexys2_jtag_disable(HANDLE hand)
54{
55 ERC erc;
56 return DpcDisableJtag(hand, &erc, NULL) ? 0 : -1;
57}
58
59int nexys2_jtag_setbits(HANDLE hand, int tms, int tdi, int tck)
60{
61 ERC erc;
62 return DpcSetTmsTdiTck(hand, tms, tdi, tck, &erc, NULL) ? 0 : -1;
63}
64
65int nexys2_jtag_puttdi(HANDLE hand, int tms, int nbits, unsigned char *bits, unsigned char *obits)
66{
67 ERC erc;
68 return DpcPutTdiBits(hand, nbits, bits, tms, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
69}
70
71int nexys2_jtag_puttmstdi(HANDLE hand, int nbits, unsigned char *bits, unsigned char *obits)
72{
73 ERC erc;
74 return DpcPutTmsTdiBits(hand, nbits, bits, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
75}
76
77int nexys2_jtag_gettdo(HANDLE hand, int tdi, int tms, int nbits, unsigned char *obits)
78{
79 ERC erc;
80 return DpcGetTdoBits(hand, nbits, tdi, tms, obits, &erc, NULL) ? 0 : -1;
81}
This page took 0.023308 seconds and 4 git commands to generate.