FreeCalypso > hg > fc-usbser-tools
comparison cp2102/decode_usb_desc.c @ 85:0787525a33e2
cp2102-decode-ee-desc program started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 27 Sep 2023 18:43:14 +0000 |
parents | |
children | b7397959ae68 |
comparison
equal
deleted
inserted
replaced
84:b36397a56bda | 85:0787525a33e2 |
---|---|
1 /* | |
2 * This program reads a CP2102 EEPROM image from an Intel HEX file | |
3 * and decodes the USB descriptors portion thereof. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include "cp210x_defs.h" | |
10 | |
11 u_char eeprom[SIZE_EEPROM]; | |
12 | |
13 main(argc, argv) | |
14 char **argv; | |
15 { | |
16 if (argc != 2) { | |
17 fprintf(stderr, "usage: %s ihex-file\n", argv[0]); | |
18 exit(1); | |
19 } | |
20 read_intel_hex(argv[1]); | |
21 printf("USB device descriptor at 0x3988:\n"); | |
22 printf(" bLength: %u", eeprom[0x388]); | |
23 if (eeprom[0x388] != 18) | |
24 fputs(" (WRONG!)", stdout); | |
25 putchar('\n'); | |
26 printf(" bDescriptorType: 0x%02X", eeprom[0x389]); | |
27 if (eeprom[0x389] != 0x01) | |
28 fputs(" (WRONG!)", stdout); | |
29 putchar('\n'); | |
30 printf(" bcdUSB: 0x%02X%02X\n", | |
31 eeprom[0x38B], eeprom[0x38A]); | |
32 printf(" bDeviceClass: 0x%02X\n", eeprom[0x38C]); | |
33 printf(" bDeviceSubClass: 0x%02X\n", eeprom[0x38D]); | |
34 printf(" bDeviceProtocol: 0x%02X\n", eeprom[0x38E]); | |
35 printf(" bMaxPacketSize0: 0x%02X\n", eeprom[0x38F]); | |
36 printf(" idVendor: 0x%02X%02X\n", | |
37 eeprom[0x391], eeprom[0x390]); | |
38 printf(" idProduct: 0x%02X%02X\n", | |
39 eeprom[0x393], eeprom[0x392]); | |
40 printf(" bcdDevice: 0x%02X%02X\n", | |
41 eeprom[0x395], eeprom[0x394]); | |
42 printf(" iManufacturer: %u\n", eeprom[0x396]); | |
43 printf(" iProduct: %u\n", eeprom[0x397]); | |
44 printf(" iSerialNumber: %u\n", eeprom[0x398]); | |
45 printf(" bNumConfigurations: %u\n", eeprom[0x399]); | |
46 /* decoding of other descriptors remains to be implemented */ | |
47 exit(0); | |
48 } |