FreeCalypso > hg > fc-usbser-tools
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cp2102/write_eeprom.c Thu Sep 28 02:38:59 2023 +0000 @@ -0,0 +1,30 @@ +/* + * This module implements the elementary function for writing the EEPROM + * on a CP2102 device. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <usb.h> +#include "cp210x_defs.h" + +extern u_char eeprom[SIZE_EEPROM]; + +void +write_eeprom(usbh) + usb_dev_handle *usbh; +{ + int rc; + + rc = usb_control_msg(usbh, DEVICE_OUT_REQTYPE, CP210x_CONFIG, + REG_EEPROM, 0, (char *) eeprom, SIZE_EEPROM, + USB_WRITE_TIMEOUT); + if (rc != SIZE_EEPROM) { + fprintf(stderr, + "EEPROM write error: usb_control_msg() returned %d\n", + rc); + exit(1); + } +}