]> Joshua Wise's Git repositories - s3load.git/blame - libnexys.win32.c
initial commit of s3load
[s3load.git] / libnexys.win32.c
CommitLineData
5ee943f9
JW
1#define LIBNEXYS_INTERNAL
2#include "libnexys.h"
3#include <stdio.h>
4
5nexys2_t nexys2_init(void) {
6 int device;
7 char devname[32];
8 HANDLE hand;
9 ERC erc;
10
11 if (!DpcInit(&erc))
12 {
13 printf("DpcInit failed\n");
14 return NULL;
15 }
16
17 if ((device = DvmgGetDefaultDev(&erc)) == -1)
18 {
19 printf("We appear to lack a default device. Sadface :(\n");
20 return NULL;
21 }
22
23 DvmgGetDevName(device, devname, &erc);
24 printf("Interacting with device %d (%s)\n", device, devname);
25
26 if (!DpcOpenJtag(&hand, devname, &erc, NULL))
27 {
28 printf("JTAG open failed\n");
29 return NULL;
30 }
31 return hand;
32}
33
34int nexys2_jtag_enable(HANDLE hand)
35{
36 ERC erc;
37 return DpcEnableJtag(hand, &erc, NULL) ? 0 : -1;
38}
39
40int nexys2_jtag_disable(HANDLE hand)
41{
42 ERC erc;
43 return DpcDisableJtag(hand, &erc, NULL) ? 0 : -1;
44}
45
46int nexys2_jtag_setbits(HANDLE hand, int tms, int tdi, int tck)
47{
48 ERC erc;
49 return DpcSetTmsTdiTck(hand, tms, tdi, tck, &erc, NULL) ? 0 : -1;
50}
51
52int nexys2_jtag_puttdi(HANDLE hand, int tms, int nbits, unsigned char *bits, unsigned char *obits)
53{
54 ERC erc;
55 return DpcPutTdiBits(hand, nbits, bits, tms, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
56}
57
58int nexys2_jtag_puttmstdi(HANDLE hand, int nbits, unsigned char *bits, unsigned char *obits)
59{
60 ERC erc;
61 return DpcPutTmsTdiBits(hand, nbits, bits, obits ? 1 : 0, obits, &erc, NULL) ? 0 : -1;
62}
63
64int nexys2_jtag_gettdo(HANDLE hand, int tdi, int tms, int nbits, unsigned char *obits)
65{
66 ERC erc;
67 return DpcGetTdoBits(hand, nbits, tdi, tms, obits, &erc, NULL) ? 0 : -1;
68}
This page took 0.02833 seconds and 4 git commands to generate.