FreeCalypso > hg > fc-usbser-tools
comparison cp2102/write_eeprom.c @ 96:c6d04771bf6a
cp2102-write-eeprom program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Sep 2023 02:38:59 +0000 |
parents | cp2102/read_eeprom.c@d4d3531d342a |
children |
comparison
equal
deleted
inserted
replaced
95:a378bf95c26c | 96:c6d04771bf6a |
---|---|
1 /* | |
2 * This module implements the elementary function for writing the EEPROM | |
3 * on 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 write_eeprom(usbh) | |
17 usb_dev_handle *usbh; | |
18 { | |
19 int rc; | |
20 | |
21 rc = usb_control_msg(usbh, DEVICE_OUT_REQTYPE, CP210x_CONFIG, | |
22 REG_EEPROM, 0, (char *) eeprom, SIZE_EEPROM, | |
23 USB_WRITE_TIMEOUT); | |
24 if (rc != SIZE_EEPROM) { | |
25 fprintf(stderr, | |
26 "EEPROM write error: usb_control_msg() returned %d\n", | |
27 rc); | |
28 exit(1); | |
29 } | |
30 } |