FreeCalypso > hg > fc-usbser-tools
view libuwrap/claim_if.c @ 96:c6d04771bf6a
cp2102-write-eeprom program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Sep 2023 02:38:59 +0000 |
parents | 5cbde3c80c24 |
children |
line wrap: on
line source
/* * The operation of programming an FTDI EEPROM *can* be done without ever * claiming any of the chip's interfaces and without unbinding ttyUSB from * any channel, even if we are doing the special magic sequence for FT232R. * However, given the identity-altering nature of EEPROM programming it is * generally a good idea to claim all interfaces and unbind all ttyUSB * devices, and in the case of FT232R the magic sequence breaks normal * UART operation. * * This library module provides building block functions: a function for * claiming one interface and a higher-level function claiming all interfaces * of a multichannel device. */ #include <stdio.h> #include <stdlib.h> #include <usb.h> #include "open_close.h" void usbwrap_claim_interface(usb_dev_handle *usbh, int ifnum, int detach) { if (detach) usb_detach_kernel_driver_np(usbh, ifnum); if (usb_claim_interface(usbh, ifnum) != 0) { fprintf(stderr, "error: usb_claim_interface() failed\n"); exit(1); } } void usbwrap_claim_all_ifs(usb_dev_handle *usbh) { struct usb_device *dev = usb_device(usbh); unsigned numint = dev->config->bNumInterfaces; unsigned n; for (n = 0; n < numint; n++) usbwrap_claim_interface(usbh, n, 1); }