view cp2102/read_eeprom.c @ 98:1cacc1ae56f0

cp2102 tools: convert to -d option for non-default device
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 28 Sep 2023 04:45:13 +0000
parents d4d3531d342a
children
line wrap: on
line source

/*
 * This module implements the elementary function for reading the EEPROM
 * content out of 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
read_eeprom(usbh)
	usb_dev_handle *usbh;
{
	int rc;

	rc = usb_control_msg(usbh, DEVICE_IN_REQTYPE, CP210x_CONFIG,
			     REG_EEPROM, 0, (char *) eeprom, SIZE_EEPROM,
			     USB_READ_TIMEOUT);
	if (rc != SIZE_EEPROM) {
		fprintf(stderr,
			"EEPROM read error: usb_control_msg() returned %d\n",
			rc);
		exit(1);
	}
}