FreeCalypso > hg > freecalypso-hwlab
comparison ee2232/ee2232-prog.c @ 5:a85b6b7398bc
ee2232-prog: actual EEPROM write implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 05 Apr 2018 22:36:51 +0000 |
parents | 02ea5dbdf84b |
children |
comparison
equal
deleted
inserted
replaced
4:02ea5dbdf84b | 5:a85b6b7398bc |
---|---|
63 exit(1); | 63 exit(1); |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 test_output() | |
69 { | |
70 unsigned n, col; | |
71 | |
72 for (n = 0; n < eeprom_size; n++) { | |
73 col = n & 7; | |
74 if (col == 0) | |
75 printf("%02X:", n * 2); | |
76 printf(" %04X", eeprom[n]); | |
77 if (col == 7) | |
78 putchar('\n'); | |
79 } | |
80 } | |
81 | |
82 main(argc, argv) | 68 main(argc, argv) |
83 char **argv; | 69 char **argv; |
84 { | 70 { |
85 struct ftdi_context ftdi; | 71 struct ftdi_context ftdi; |
72 unsigned n; | |
86 | 73 |
87 process_cmdline(argc, argv); | 74 process_cmdline(argc, argv); |
88 if (erase) | 75 if (erase) |
89 memset(eeprom, 0xFF, eeprom_size * 2); | 76 memset(eeprom, 0xFF, eeprom_size * 2); |
90 else | 77 else |
91 read_eeprom_from_stdin(); | 78 read_eeprom_from_stdin(); |
92 test_output(); | 79 ftdi_init(&ftdi); |
80 if (ftdi_usb_open_string(&ftdi, device_selector) < 0) { | |
81 fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); | |
82 exit(1); | |
83 } | |
84 for (n = 0; n < eeprom_size; n++) { | |
85 if (ftdi_write_eeprom_location(&ftdi, n, eeprom[n]) < 0) { | |
86 fprintf(stderr, "EEPROM write error: %s\n", | |
87 ftdi.error_str); | |
88 exit(1); | |
89 } | |
90 } | |
91 ftdi_usb_close(&ftdi); | |
93 exit(0); | 92 exit(0); |
94 | |
95 } | 93 } |