int main(int argc, char *argv[]) { int num_devs; struct ftdi_context *ctx; struct ftdi_device_list *devs = NULL; (void)argc; (void)argv; ctx = ftdi_new(); if (!ctx) { printf("Initialization error.\n"); return 1; } num_devs = ftdi_usb_find_all(ctx, &devs, 0, 0); if (num_devs < 0) { printf("Device list error: %s.\n", ftdi_get_error_string(ctx)); ftdi_free(ctx); return 2; } printf("Found %d FTDI devices.\n", (int)num_devs); ftdi_list_free(&devs); ftdi_free(ctx); return 0; }
void spi_init(void) { int ret; ftdi = ftdi_new(); if (!ftdi) { fatal_error("ftdi_new failed!\n"); } ret = ftdi_usb_open(ftdi, 0x0403, 0x6001); if (ret < 0 && ret != -5) { ftdi_free(ftdi); fatal_error("unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); } ret = ftdi_set_bitmode(ftdi, PINS_OUT, BITMODE_SYNCBB); if (ret != 0) { ftdi_free(ftdi); fatal_error("unable to set bitmode: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); } ret = ftdi_set_baudrate(ftdi, 57600); if (ret != 0) { ftdi_disable_bitbang(ftdi); ftdi_free(ftdi); fatal_error("unable to set baudrate: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); } }
int init_rs485(struct rs485_data_t *rs485_data) { int ret; rs485_data->ftdi = ftdi_new(); if (!rs485_data->ftdi) { fprintf(stderr, "ftdi_new failed\n"); return -1; } /* check for FT232RL device */ if ((ret = ftdi_usb_open(rs485_data->ftdi, 0x0403, 0x6001)) < 0) { fprintf(stderr, "unable to open FTDI device: %d (%s)\n", ret, ftdi_get_error_string(rs485_data->ftdi)); ftdi_free(rs485_data->ftdi); return EXIT_FAILURE; } if ((ret = ftdi_set_baudrate(rs485_data->ftdi, rs485_data->speed)) < 0) { fprintf(stderr, "unable to set baudrate: %d (%s)\n", ret, ftdi_get_error_string(rs485_data->ftdi)); ftdi_free(rs485_data->ftdi); return EXIT_FAILURE; } if ((ret = ftdi_setflowctrl(rs485_data->ftdi, SIO_DISABLE_FLOW_CTRL)) < 0) { fprintf(stderr, "unable to set flow control: %d (%s)\n", ret, ftdi_get_error_string(rs485_data->ftdi)); return EXIT_FAILURE; } return 0; }
int close_rs485(struct rs485_data_t *rs485_data) { int ret; if ((ret = ftdi_usb_close(rs485_data->ftdi)) < 0) { fprintf(stderr, "unable to close ftdi device: %d (%s)\n", ret, ftdi_get_error_string(rs485_data->ftdi)); ftdi_free(rs485_data->ftdi); return EXIT_FAILURE; } ftdi_free(rs485_data->ftdi); return 0; }
~Private() { if (open) ftdi_usb_close(ftdi); ftdi_free(ftdi); }
// // Close the serial port. // static dc_status_t serial_ftdi_close (void **userdata) { ftdi_serial_t *device = (ftdi_serial_t*) *userdata; if (device == NULL) return DC_STATUS_SUCCESS; // Restore the initial terminal attributes. // See if it is possible using libusb or libftdi int ret = ftdi_usb_close(device->ftdi_ctx); if (ret < 0) { ERROR (device->context, "Unable to close the ftdi device : %d (%s)\n", ret, ftdi_get_error_string(device->ftdi_ctx)); return ret; } ftdi_free(device->ftdi_ctx); // Free memory. free (device); *userdata = NULL; return DC_STATUS_SUCCESS; }
void ftdi_fatal (struct ftdi_context *ftdi, char *str) { fprintf (stderr, "%s: %s\n", str, ftdi_get_error_string (ftdi)); ftdi_free(ftdi); exit (1); }
static struct ftdi_context *open_ftdi_device(int vid, int pid, int interface, char *serial) { struct ftdi_context *ftdi; int ret; ftdi = ftdi_new(); if (!ftdi) { fprintf(stderr, "Cannot allocate context memory\n"); return NULL; } ret = ftdi_set_interface(ftdi, interface); if (ret < 0) { fprintf(stderr, "cannot set ftdi interface %d: %s(%d)\n", interface, ftdi_get_error_string(ftdi), ret); goto open_failed; } ret = ftdi_usb_open_desc(ftdi, vid, pid, NULL, serial); if (ret < 0) { fprintf(stderr, "unable to open ftdi device: %s(%d)\n", ftdi_get_error_string(ftdi), ret); goto open_failed; } return ftdi; open_failed: ftdi_free(ftdi); return NULL; }
/** * Close the USB port and reset the sequencer logic. * * @param devc The struct containing private per-device-instance data. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments. */ static int close_usb_reset_sequencer(struct dev_context *devc) { /* Magic sequence of bytes for resetting the sequencer logic. */ uint8_t buf[8] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}; int ret; /* Note: Caller checked that devc and devc->ftdic != NULL. */ if (devc->ftdic->usb_dev) { /* Reset the sequencer logic, then wait 100ms. */ sr_dbg("Resetting sequencer logic."); (void) cv_write(devc, buf, 8); /* Ignore errors. */ g_usleep(100 * 1000); /* Purge FTDI buffers, then reset and close the FTDI device. */ sr_dbg("Purging buffers, resetting+closing FTDI device."); /* Log errors, but ignore them (i.e., don't abort). */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) sr_err("Failed to purge FTDI buffers (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); if ((ret = ftdi_usb_reset(devc->ftdic)) < 0) sr_err("Failed to reset FTDI device (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); if ((ret = ftdi_usb_close(devc->ftdic)) < 0) sr_err("Failed to close FTDI device (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); } /* Close USB device, deinitialize and free the FTDI context. */ ftdi_free(devc->ftdic); devc->ftdic = NULL; return SR_OK; }
/** * Will initialize the ftdi connection. * @return 0 on success. */ int IncrementParser::InitRS232() { int ret = 100; if ((ftdi_ = ftdi_new()) == 0){ fprintf(stderr, "ftdi_new failed\n"); return EXIT_FAILURE; } if ((ret = ftdi_usb_open(ftdi_, 0x0403, 0x6001)) < 0){ fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdi_)); ftdi_free(ftdi_); return EXIT_FAILURE; } // Read out FTDIChip-ID of R type chips if (ftdi_->type == TYPE_R){ unsigned int chipid; printf("ftdi_read_chipid: %d\n", ftdi_read_chipid(ftdi_, &chipid)); printf("FTDI chipid: %X\n", chipid); } ftdi_set_baudrate(ftdi_, baudrate_); printf("Baudrate set to: %d\n", baudrate_); init_done_ = true; return EXIT_SUCCESS; }
FtdiWrapper::FtdiWrapper(unsigned int vid, unsigned int pid, string description, string serialNum) { try { //construct connection context ftdiContext = ftdi_new(); if(ftdiContext == NULL) throw runtime_error("unable to initialize ftdi driver"); //open connection const char *desc = ( description.empty() ? NULL : description.c_str() ); const char *serial = ( serialNum.empty() ? NULL : serialNum.c_str() ); int rtn = ftdi_usb_open_desc(ftdiContext, vid, pid, desc, serial); if(rtn < 0) { stringstream msg; msg << "unable to open ftdi connection: "; msg << ftdi_get_error_string(ftdiContext); // msg << " (Do you have sufficient privileges to access the usb bus? Is the device connected?)"; throw runtime_error( msg.str() ); } } catch(...) { ftdi_free(ftdiContext); throw; } }
void spi_end() { prog_end(); ftdi_disable_bitbang(ftdi); ftdi_free(ftdi); }
/* * Return a list of devices found by libftdi together with a number of fields * describing the corresponding USB device. * The list is internally cached. To free it, call freeDeviceList(). * * Returns: a vector pointer containing 0 or more devices, or NULL if an error * occured while retrieving the list. When NULL is returned, this is guaranteed * to be an ftdi error. */ const FtdiDevice::vec_deviceInfo* FtdiDevice::getDeviceList( ftdi_context* c ) { ftdi_context* context = c ? c : ftdi_new(); if ( context == 0 ) return 0; if ( s_deviceList != 0 ) freeDeviceList(); int r = ftdi_usb_find_all( context, &s_ftdiDeviceList, USB_VENDOR_ID, USB_PRODUCT_ID ); s_deviceList = new vec_deviceInfo(); if ( r >= 0 ) { struct ftdi_device_list* openDev = s_ftdiDeviceList; while ( openDev ) { struct deviceInfo info; info.ftdiDevice = openDev->dev; info.usbInfo = fetchUsbInformation( context, info.ftdiDevice ); s_deviceList->push_back( info ); openDev = openDev->next; } } //Only free the context if it has been allocated locally. if ( c == 0 ) ftdi_free( context ); return s_deviceList; }
int main(void) { int ret; struct ftdi_context *ftdi; struct ftdi_version_info version; if ((ftdi = ftdi_new()) == 0) { fprintf(stderr, "ftdi_new failed\n"); return EXIT_FAILURE; } version = ftdi_get_library_version(); printf("Initialized libftdi %s (major: %d, minor: %d, micro: %d, snapshot ver: %s)\n", version.version_str, version.major, version.minor, version.micro, version.snapshot_str); // // own stuff // struct ftdi_device_list *devList; // if ((ret = ftdi_usb_find_all(ftdi,devList, 0, 0)) < 0) // { // fprintf(stderr, "unable to find devices: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); // ftdi_free(ftdi); // return EXIT_FAILURE; // } if ((ret = ftdi_usb_open(ftdi, 0x0403, 0x6014)) < 0) { fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); ftdi_free(ftdi); return EXIT_FAILURE; } // Read out FTDIChip-ID of R type chips if (ftdi->type == TYPE_232H) { unsigned int chipid; printf("ftdi_read_chipid: %d\n", ftdi_read_chipid(ftdi, &chipid)); printf("FTDI chipid: %X\n", chipid); } if ((ret = ftdi_usb_close(ftdi)) < 0) { fprintf(stderr, "unable to close ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); ftdi_free(ftdi); return EXIT_FAILURE; } ftdi_free(ftdi); return EXIT_SUCCESS; }
void ftdi_reader_create() { if ((ftdi_c = ftdi_new()) == 0) { Throw(FTDI_NEW_FAILED); } if (ftdi_usb_open(ftdi_c, FTDI_VID, FTDI_PID)!=0) { ftdi_free(ftdi_c); Throw(FTDI_USB_OPEN_FAILED); } if (ftdi_set_baudrate(ftdi_c, 3000000)!=0) { ftdi_usb_close(ftdi_c); ftdi_free(ftdi_c); Throw(FTDI_SET_BAUDRATE_FAILED); } }
void release(void) { if(ftdi) { ftdi_disable_bitbang(ftdi); ftdi_usb_close(ftdi); ftdi_free(ftdi); ftdi = NULL; } }
OBDDevice::~OBDDevice() { QMutexLocker locker( &obdMutex ); /* Release the FTDI context */ ftdi_usb_close( ftdi ); ftdi_free( ftdi ); qDebug() << "~OBDDevice()"; }
FtdiWrapper::~FtdiWrapper() { //close connection int rtn = ftdi_usb_close(ftdiContext); if(rtn < 0) cerr << ftdi_get_error_string(ftdiContext) << endl; //free connection context ftdi_free(ftdiContext); }
static void clear_helper(void *priv) { struct dev_context *devc; devc = priv; ftdi_free(devc->ftdic); g_free(devc->final_buf); }
static int dev_open(struct sr_dev_inst *sdi) { struct dev_context *devc; int ret; if (!(devc = sdi->priv)) return SR_ERR_BUG; /* Allocate memory for the FTDI context and initialize it. */ if (!(devc->ftdic = ftdi_new())) { sr_err("Failed to initialize libftdi."); return SR_ERR; } sr_dbg("Opening %s device (%04x:%04x).", devc->prof->modelname, devc->usb_vid, devc->usb_pid); /* Open the device. */ if ((ret = ftdi_usb_open_desc(devc->ftdic, devc->usb_vid, devc->usb_pid, devc->prof->iproduct, NULL)) < 0) { sr_err("Failed to open FTDI device (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } sr_dbg("Device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { sr_err("Failed to purge FTDI buffers (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } sr_dbg("FTDI buffers purged successfully."); /* Enable flow control in the FTDI chip. */ if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) { sr_err("Failed to enable FTDI flow control (%d): %s.", ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } sr_dbg("FTDI flow control enabled successfully."); /* Wait 100ms. */ g_usleep(100 * 1000); sdi->status = SR_ST_ACTIVE; if (ret == SR_OK) return SR_OK; err_ftdi_free: ftdi_free(devc->ftdic); /* Close device (if open), free FTDI context. */ devc->ftdic = NULL; return ret; }
void list_devices() { struct ftdi_context *ftdi; struct ftdi_device_list *dev_list; struct ftdi_device_list *dev_current; int num_devices; ftdi = ftdi_new(); if (!ftdi) { fprintf(stderr, "failed to initialize ftdi context\n"); exit(1); } num_devices = ftdi_usb_find_all(ftdi, &dev_list, VID, PID); if (num_devices < 0) { fprintf(stderr, "ftdi error: %s\n", ftdi_get_error_string(ftdi)); goto error; } if (!num_devices) { printf("unable to find saturn device!\n"); goto done; } dev_current = dev_list; num_devices = 0; while (dev_current) { char manufacturer[255]; char description[255]; char serial[255]; if (ftdi_usb_get_strings(ftdi, dev_current->dev, manufacturer, 255, description, 255, serial, 255) < 0) { fprintf(stderr, "ftdi error: %s\n", ftdi_get_error_string(ftdi)); goto done; } if (strcmp(DESCRIPTION, description) == 0) printf("%d: %s (%s, %s)\n", num_devices++, description, manufacturer, serial); dev_current = dev_current->next; } if (!num_devices) printf("unable to find saturn device!\n"); done: ftdi_list_free(&dev_list); error: ftdi_free(ftdi); }
static void clear_helper(void *priv) { struct dev_context *devc; devc = priv; ftdi_free(devc->ftdic); g_free(devc->compressed_buf); g_free(devc->sample_buf); g_free(devc); }
int platform_init(void) { int err; if(ftdic) { ftdi_usb_close(ftdic); ftdi_free(ftdic); ftdic = NULL; } if((ftdic = ftdi_new()) == NULL) { fprintf(stderr, "ftdi_new: %s\n", ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_set_interface(ftdic, INTERFACE_A)) != 0) { fprintf(stderr, "ftdi_set_interface: %d: %s\n", err, ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_usb_open(ftdic, FT2232_VID, FT2232_PID)) != 0) { fprintf(stderr, "unable to open ftdi device: %d (%s)\n", err, ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_set_latency_timer(ftdic, 1)) != 0) { fprintf(stderr, "ftdi_set_latency_timer: %d: %s\n", err, ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_set_baudrate(ftdic, 1000000)) != 0) { fprintf(stderr, "ftdi_set_baudrate: %d: %s\n", err, ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_usb_purge_buffers(ftdic)) != 0) { fprintf(stderr, "ftdi_set_baudrate: %d: %s\n", err, ftdi_get_error_string(ftdic)); abort(); } if((err = ftdi_write_data_set_chunksize(ftdic, BUF_SIZE)) != 0) { fprintf(stderr, "ftdi_write_data_set_chunksize: %d: %s\n", err, ftdi_get_error_string(ftdic)); abort(); } assert(gdb_if_init() == 0); jtag_scan(NULL); return 0; }
int main(int argc, char **argv) { void *hnd; int ret = 1; int flags; /* Parse command line options */ flags = parse_parameters(argc, argv); /* Open the USB device */ hnd = open_ftdi_device(usb_vid, usb_pid, usb_interface, usb_serial); if (hnd == NULL) return 1; /* Trigger embedded monitor detection */ if (send_special_waveform(hnd) < 0) goto terminate; if (config_i2c(hnd) < 0) goto terminate; if (check_chipid(hnd) < 0) goto terminate; if (flags & FLAG_UNPROTECT) command_write_unprotect(hnd); if (flags & FLAG_ERASE || output_filename) command_erase(hnd, flash_size, 0); if (input_filename) { ret = read_flash(hnd, input_filename, 0, flash_size); if (ret) goto terminate; } if (output_filename) { ret = write_flash(hnd, output_filename, 0); if (ret) goto terminate; } /* Normal exit */ ret = 0; terminate: /* Close the FTDI USB handle */ ftdi_usb_close(hnd); ftdi_free(hnd); return ret; }
int main(int argc, char *argv[]) { int ret; int i; struct ftdi_context *ftdi; unsigned int chipid; unsigned char buf[256]; track *tracks; int ntracks; ftdi = ftdi_new(); ret = ftdi_usb_open(ftdi, 0x0403, 0xB70A); if (ret < -1) { fprintf(stderr, "unable to open ftdi device: %d (%s)\n", ret, ftdi_get_error_string(ftdi)); return ret; } printf("type=%d\n", ftdi->type); ftdi_read_chipid(ftdi, &chipid); printf("chipid=%x\n", chipid); setup(ftdi); ftdi_setrts(ftdi, 1); while((ret = ftdi_read_data(ftdi, buf, 256)) > 0) { for(i = 0; i < ret; ++i) printf("%02X ", buf[i]); } ftdi_setrts(ftdi, 0); read_version(ftdi); read_product(ftdi); read_list(ftdi, &tracks, &ntracks); if (argc > 1) { i = atoi(argv[1]); printf("tracks[%d].no=%d\n", i, tracks[i].no); read_track_points(ftdi, &tracks[i], i); } free(tracks); ftdi_usb_close(ftdi); ftdi_free(ftdi); return 0; }
int main(int argc, char **argv) { struct ftdi_context *ftdi; int f; unsigned char buf[1]; int retval = 0; if ((ftdi = ftdi_new()) == 0) { fprintf(stderr, "ftdi_new failed\n"); return EXIT_FAILURE; } // fprintf(stderr, "ftdi_new result = %d\n", ftdi); f = ftdi_usb_open(ftdi, 0x0403, 0x6001); // fprintf(stderr, "ftdi_usb_open result = %d\n", f); if (f < 0 && f != -5) { fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi)); retval = 1; goto done; } // printf("ftdi open succeeded: %d\n",f); // printf("enabling bitbang mode\n"); ftdi_set_bitmode(ftdi, 0x02, BITMODE_BITBANG); // usleep(3 * 1000000); buf[0] = 0xff; // printf("turning everything on\n"); f = ftdi_write_data(ftdi, buf, 1); if (f < 0) { fprintf(stderr,"write failed for 0x%x, error %d (%s)\n",buf[0],f, ftdi_get_error_string(ftdi)); } // ftdi_disable_bitbang(ftdi); ftdi_usb_close(ftdi); ftdi_free(ftdi); done: return retval; }
static GSList *scan(struct sr_dev_driver *di, GSList *options) { int ret; unsigned int i; GSList *devices; struct ftdi_context *ftdic; (void)di; (void)options; devices = NULL; /* Allocate memory for the FTDI context and initialize it. */ if (!(ftdic = ftdi_new())) { sr_err("Failed to initialize libftdi."); return NULL; } /* Check for LA8 and/or LA16 devices with various VID/PIDs. */ for (i = 0; i < ARRAY_SIZE(vid_pid); i++) { ret = ftdi_usb_open_desc(ftdic, vid_pid[i].vid, vid_pid[i].pid, vid_pid[i].iproduct, NULL); /* Show errors other than "device not found". */ if (ret < 0 && ret != -3) sr_dbg("Error finding/opening device (%d): %s.", ret, ftdi_get_error_string(ftdic)); if (ret < 0) continue; /* No device found, or not usable. */ sr_dbg("Found %s device (%04x:%04x).", vid_pid[i].iproduct, vid_pid[i].vid, vid_pid[i].pid); if ((ret = add_device(i, vid_pid[i].model, &devices)) < 0) sr_dbg("Failed to add device: %d.", ret); if ((ret = ftdi_usb_close(ftdic)) < 0) sr_dbg("Failed to close FTDI device (%d): %s.", ret, ftdi_get_error_string(ftdic)); } /* Close USB device, deinitialize and free the FTDI context. */ ftdi_free(ftdic); ftdic = NULL; return devices; }
int main(int argc, char **argv) { struct ftdi_context *ftdi; int i, t; unsigned char data; int delay = 100000; /* 100 thousand microseconds: 1 tenth of a second */ while ((t = getopt (argc, argv, "d:")) != -1) { switch (t) { case 'd': delay = atoi (optarg); break; } } if ((ftdi = ftdi_new()) == 0) { fprintf(stderr, "ftdi_bew failed\n"); return EXIT_FAILURE; } if (ftdi_usb_open(ftdi, 0x0403, 0x6010) < 0) ftdi_fatal (ftdi, "Can't open ftdi device"); if (ftdi_set_bitmode(ftdi, 0xFF, BITMODE_BITBANG) < 0) ftdi_fatal (ftdi, "Can't enable bitbang"); for (i=optind; i < argc ; i++) { sscanf (argv[i], "%x", &t); data = t; if (ftdi_write_data(ftdi, &data, 1) < 0) { fprintf(stderr,"write failed for 0x%x: %s\n", data, ftdi_get_error_string(ftdi)); } usleep(delay); } ftdi_usb_close(ftdi); ftdi_free(ftdi); exit (0); }
void relay_setup (void) { int f; if ((ftdi = ftdi_new()) == 0) { printf("ftdi_new failed\nFatal error, exiting\n"); exit (1); } f = ftdi_usb_open(ftdi, 0x0403, 0x6001); if (f < 0 && f != -5) { printf("Unable to open ftdi device %s\nFatal error, exiting\n", ftdi_get_error_string(ftdi)); ftdi_free(ftdi); exit (1); } ftdi_set_bitmode(ftdi, 0xFF, BITMODE_BITBANG); return; }
int init() { int f; if ((ftdi = ftdi_new()) == 0) { fprintf(stderr, "ftdi_new failed\n"); return -1; } f = ftdi_usb_open(ftdi, 0x0403, 0x6010); if (f < 0 && f != -5) { fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi)); ftdi_free(ftdi); ftdi = NULL; return -1; } f = ftdi_set_bitmode(ftdi, 0xff, BITMODE_MPSSE); if(f != 0) { fprintf(stderr, "unable to set bit mode: %d (%s)\n", f, ftdi_get_error_string(ftdi)); release(); return -1; } uint8_t p[] = { 0x80, 0, 3 }; f = ftdi_write_data(ftdi, p, 3); if(f != 3) { fprintf(stderr, "unable to write command to ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi)); release(); return -1; } //Set TCK/SK Divisor 0x86, 0xValueL, 0xValueH uint8_t p1[] = { 0x86, 0, 1 }; //250KHz // uint8_t p1[] = { 0x86, 0, 10 }; //25KHz f = ftdi_write_data(ftdi, p1, 3); if(f != 3) { fprintf(stderr, "unable to write command2 to ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi)); release(); return -1; } return 0; }