Skip to content

Instantly share code, notes, and snippets.

@triffid
Created April 30, 2012 03:31
Show Gist options
  • Save triffid/2555220 to your computer and use it in GitHub Desktop.
Save triffid/2555220 to your computer and use it in GitHub Desktop.
C++ USB for cortex-m3
USB u;
USBCDC uc;
USBMSC msc;
USBECM ecm;
UART dbg(UART0, 230400);
int main(void) {
dbg.send((uint8_t *) "start\n", 6);
uc.attach(&u);
msc.attach(&u);
uint8_t mac[6] = { 0xAE, 0xF0, 0x28, 0x5D, 0x66, 0x21 };
ecm.setMAC(mac);
ecm.attach(&u);
u.init();
u.dumpDescriptors();
for (;;);
}
*** OUTPUT: ***
[0:+18]Device:
USB Version: 1.1
Class: 0x0000 (PER INTF)
SubClass: 0x0000
Protocol: 0x0000
Max Packet: 8
Vendor: 0xFFFF
Product: 0x0005
Manufacturer: [1] USB Magic!
Product: [2] R2C2
Serial: [3] A1XTQZ
Num Configs: 1
[1:+9]Configuration:
Total Length: 237b
Num Interfaces: 5
Configuration Value: 1
Configuration: -none-
Attributes: Bus Powered
Max Power: 500mA
[2:+4]\0x409
[3:+22]USB Magic!
[4:+10]R2C2
[5:+14]A1XTQZ
[6:+9] *Interface
Number: 0
Alternate: 0
Num Endpoints: 1
Class: 0x02 (COMM)
SubClass: 0x02 (ACM)
Protocol: 0x01
Interface: -none-
[7:+7] *Endpoint
Address: 0x81 (IN)
Attributes: 0x03 (Interrupt)
Max Packet: 8
Interval: 16
[8:+5] *CDC Call Management
Capabilities: 0x03 (CALLMGMT)(DATAINTF)
Data Interface: 1
[9:+5] *CDC header
bcdCDC: 0x0110
[10:+4] *CDC ACM
Capabilities: 0x06 (LINE)(BRK)
[11:+5] *CDC union
Master: 0
Slave: 1
[12:+9] *Interface
Number: 1
Alternate: 0
Num Endpoints: 2
Class: 0x0A (CDC DATA)
SubClass: 0x00
Protocol: 0x00
Interface: -none-
[13:+7] *Endpoint
Address: 0x02 (OUT)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[14:+7] *Endpoint
Address: 0x85 (IN)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[15:+9] *Interface
Number: 2
Alternate: 0
Num Endpoints: 2
Class: 0x08 (MSC)
SubClass: 0x06 (SCSI)
Protocol: 0x50
Interface: -none-
[16:+7] *Endpoint
Address: 0x08 (OUT)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[17:+7] *Endpoint
Address: 0x8B (IN)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[18:+9] *Interface
Number: 3
Alternate: 0
Num Endpoints: 1
Class: 0x02 (COMM)
SubClass: 0x06 (ETHERNET)
Protocol: 0x00
Interface: -none-
[19:+5] *CDC header
bcdCDC: 0x0110
[20:+5] *CDC union
Master: 3
Slave: 4
[21:+13] *CDC Ethernet
MAC address: [4] AEF0285D6621
Statistics: 0x00
Max Segment Size: 1514
MC Filters: 0
Power Filters: 0
[22:+7] *Endpoint
Address: 0x84 (IN)
Attributes: 0x03 (Interrupt)
Max Packet: 8
Interval: 10
[23:+9] *Interface
Number: 4
Alternate: 0
Num Endpoints: 0
Class: 0x0A (CDC DATA)
SubClass: 0x00
Protocol: 0x00
Interface: -none-
[24:+9] *Interface
Number: 4
Alternate: 1
Num Endpoints: 2
Class: 0x0A (CDC DATA)
SubClass: 0x00
Protocol: 0x00
Interface: -none-
[25:+7] *Endpoint
Address: 0x0E (OUT)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[26:+7] *Endpoint
Address: 0x8F (IN)
Attributes: 0x02 (Bulk)
Max Packet: 64
Interval: 0
[27:+26]AEF0285D6621
--- FIN at 28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment