annotate cp2102/write_eeprom.c @ 105:1e820ed0904e

Installed-binaries: list of binaries installed by this package I am establishing a new convention for all FreeCalypso tools, across different packages and source repositories: each FC tools package will have a file name Installed-binaries listing all user-invokable binaries that package installs in /opt/freecalypso/bin. These files are to serve as an aid to users and distro package maintainers who prefer to not add /opt/freecalypso/bin to their PATH. The alternative to adding this directory to PATH is to create a symlink for every installed binary in some standard location such as /usr/bin or /usr/local/bin, pointing to the actual binary in /opt/freecalypso/bin; having a list of all FC-installed binaries in a standardized format will allow this process to be automated.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 29 Sep 2023 19:42:53 +0000
parents c6d04771bf6a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
96
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
2 * This module implements the elementary function for writing the EEPROM
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
3 * on a CP2102 device.
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <usb.h>
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "cp210x_defs.h"
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern u_char eeprom[SIZE_EEPROM];
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 void
96
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
16 write_eeprom(usbh)
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 usb_dev_handle *usbh;
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int rc;
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
96
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
21 rc = usb_control_msg(usbh, DEVICE_OUT_REQTYPE, CP210x_CONFIG,
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 REG_EEPROM, 0, (char *) eeprom, SIZE_EEPROM,
96
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
23 USB_WRITE_TIMEOUT);
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (rc != SIZE_EEPROM) {
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 fprintf(stderr,
96
c6d04771bf6a cp2102-write-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
26 "EEPROM write error: usb_control_msg() returned %d\n",
53
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 rc);
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 exit(1);
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
d4d3531d342a cp2102-read-eeprom program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }