Fixed Context::open as get_strings() closes the device before. Thanks to Chris M...
[libftdi] / examples / bitbang.c
index c2d67b9..2326605 100644 (file)
@@ -2,6 +2,9 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#ifdef __WIN32__
+#define sleep(x) Sleep(x)
+#endif
 #include <ftdi.h>
 
 int main(int argc, char **argv)
@@ -10,7 +13,11 @@ int main(int argc, char **argv)
     int f,i;
     char buf[1];
 
-    ftdi_init(&ftdic);
+    if (ftdi_init(&ftdic) < 0)
+    {
+        fprintf(stderr, "ftdi_init failed\n");
+        return EXIT_FAILURE;
+    }
 
     f = ftdi_usb_open(&ftdic, 0x0403, 0x6001);