FreeCalypso > hg > fc-usbser-tools
comparison duart28/main.c @ 31:530ec3792de8
fc-duart28-conf: implement set command
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Sep 2023 19:40:58 +0000 |
parents | a7393d00996a |
children | df284688d0c8 |
comparison
equal
deleted
inserted
replaced
30:8de3891460db | 31:530ec3792de8 |
---|---|
39 return 0; | 39 return 0; |
40 } | 40 } |
41 | 41 |
42 oper_program(newconf) | 42 oper_program(newconf) |
43 { | 43 { |
44 fprintf(stderr, "error: set command not yet implemented\n"); | 44 struct usb_device *dev; |
45 exit(1); | 45 usb_dev_handle *usbh; |
46 int prev; | |
47 | |
48 dev = find_duart28_usbdev(); | |
49 if (!dev) { | |
50 fprintf(stderr, "error: no DUART28 adapter found\n"); | |
51 exit(1); | |
52 } | |
53 usbh = usbwrap_open_dev(dev, 1); | |
54 read_eeprom(usbh); | |
55 prev = analyze_eeprom(); | |
56 if (prev == newconf) { | |
57 printf("EEPROM is already in the right state, nothing to do\n"); | |
58 usbwrap_close_dev(usbh); | |
59 return 0; | |
60 } | |
61 printf("Reprogramming to DUART28%c configuration\n", newconf); | |
62 update_eeprom(usbh, newconf); | |
63 usbwrap_close_dev(usbh); | |
64 printf("EEPROM changed, replug the USB device to take effect\n"); | |
65 return 0; | |
46 } | 66 } |
47 | 67 |
48 main(argc, argv) | 68 main(argc, argv) |
49 char **argv; | 69 char **argv; |
50 { | 70 { |