FreeCalypso > hg > fc-usbser-tools
comparison libftmini/eeprom_rd.c @ 14:67ecb394b24f
libftmini: starting with EEPROM read
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 07 Sep 2023 07:59:09 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:c53dee063cdd | 14:67ecb394b24f |
---|---|
1 /* elementary FTDI EEPROM read function */ | |
2 | |
3 #include <sys/types.h> | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 #include <usb.h> | |
7 #include "ftdi_defs.h" | |
8 #include "ftdi_tune.h" | |
9 #include "eeprom_func.h" | |
10 | |
11 u_short ftmini_read_eeprom_loc(usb_dev_handle *usbh, u_short addr) | |
12 { | |
13 u_char buf[2]; | |
14 int rc; | |
15 | |
16 rc = usb_control_msg(usbh, FTDI_DEVICE_IN_REQTYPE, | |
17 SIO_READ_EEPROM_REQUEST, 0, addr, (char *) buf, 2, | |
18 USB_READ_TIMEOUT); | |
19 if (rc != 2) { | |
20 fprintf(stderr, | |
21 "EEPROM read error: usb_control_msg() returned %d\n", | |
22 rc); | |
23 exit(1); | |
24 } | |
25 return buf[0] | (buf[1] << 8); | |
26 } |