comparison cp2102/read_eeprom.c @ 53:d4d3531d342a

cp2102-read-eeprom program written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Sep 2023 18:49:07 +0000
parents
children
comparison
equal deleted inserted replaced
52:61cdcf2eb17b 53:d4d3531d342a
1 /*
2 * This module implements the elementary function for reading the EEPROM
3 * content out of a CP2102 device.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <usb.h>
11 #include "cp210x_defs.h"
12
13 extern u_char eeprom[SIZE_EEPROM];
14
15 void
16 read_eeprom(usbh)
17 usb_dev_handle *usbh;
18 {
19 int rc;
20
21 rc = usb_control_msg(usbh, DEVICE_IN_REQTYPE, CP210x_CONFIG,
22 REG_EEPROM, 0, (char *) eeprom, SIZE_EEPROM,
23 USB_READ_TIMEOUT);
24 if (rc != SIZE_EEPROM) {
25 fprintf(stderr,
26 "EEPROM read error: usb_control_msg() returned %d\n",
27 rc);
28 exit(1);
29 }
30 }