FreeCalypso > hg > fc-usbser-tools
changeset 23:7e6dcceb5ee8
fteeprom-prog: implement -r option for FT232R mode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Sep 2023 07:05:51 +0000 |
parents | 4e5c8ac4d508 |
children | 45d026fdb315 |
files | fteeprom/fteeprom-prog.c |
diffstat | 1 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/fteeprom/fteeprom-prog.c Sat Sep 09 01:06:43 2023 +0000 +++ b/fteeprom/fteeprom-prog.c Sat Sep 09 07:05:51 2023 +0000 @@ -83,26 +83,40 @@ main(argc, argv) char **argv; { + char **ap, *devsel; struct usb_device *dev; usb_dev_handle *usbh; + int ft232r_mode = 0; unsigned n; - if (argc < 2 || argc > 3) { - fprintf(stderr, "usage: %s device-selector [eeprom-image]\n", + if (argc < 2) { +usage: fprintf(stderr, + "usage: %s [-r] device-selector [eeprom-image]\n", argv[0]); exit(1); } - if (argv[2]) - read_eeprom_from_file(argv[2]); - else + ap = argv + 1; + if (!strcmp(*ap, "-r")) { + ft232r_mode = 1; + ap++; + } + if (!*ap) + goto usage; + devsel = *ap++; + if (*ap) { + if (ap[1]) + goto usage; + read_eeprom_from_file(*ap); + } else read_eeprom_from_stdin(); - dev = find_usbdev_by_desc_string(argv[1]); + dev = find_usbdev_by_desc_string(devsel); if (!dev) { fprintf(stderr, "error: specified USB device not found\n"); exit(1); } usbh = usbwrap_open_dev(dev, 1); - /* FIXME: reimplement FT232R magic sequence */ + if (ft232r_mode) + ft232r_eeprom_magic(usbh); for (n = 0; n < eeprom_size; n++) ftmini_write_eeprom_loc(usbh, n, eeprom[n]); usbwrap_close_dev(usbh);