For the sake of this post I’m just posting some parts of the code. I use many functions/files for parsing and trying to organize the code.
Again, help would be appreciated. Specially for my concerns and start discarding issues (or rising new ones).
Descriptor Test
Start
Device addressed... Requesting device descriptor.
Device descriptor:
Descriptor Length: 12
USB version: 1.10
Class: FF Vendor Specific
Subclass: 00
Protocol: FF
Max.packet size: 08
Vendor ID: 0582
Product ID: 0113
Revision ID: 0100
Mfg.string index: 01 Length: 10 Contents: BOSS
Prod.string index: 02 Length: 12 Contents: ME-25
Serial number index: 00
Number of conf.: 01
Configuration number 0
Total configuration length: 155 bytes
Configuration descriptor:
Total length: 009B
Number of interfaces: 03
Configuration value: 01
Configuration string: 00
Attributes: C0 Self-powered
Max.power: 00 0ma
Interface descriptor:
Interface number: 00
Alternate setting: 00
Endpoints: 00
Class: FF Vendor Specific
Subclass: 02
Protocol: 00
Interface string: 00
Interface descriptor:
Interface number: 00
Alternate setting: 01
Endpoints: 01
Class: FF Vendor Specific
Subclass: 02
Protocol: 00
Interface string: 00
Unknown descriptor:
Length: 07
Type: 24
Contents: 01010001000B24
Unknown descriptor:
Length: 0B
Type: 24
Contents: 02010203180144AC000705
Endpoint descriptor:
Endpoint address: 01 Direction: OUT
Attributes: 09 Transfer type: Isochronous,
Sync Type: Not Supported,
Usage Type: Data
Max.packet size: 0120
Polling interval: 01 1 ms
Unknown descriptor:
Length: 07
Type: 25
Contents: 01000200020904
Interface descriptor:
Interface number: 01
Alternate setting: 00
Endpoints: 00
Class: FF Vendor Specific
Subclass: 02
Protocol: 00
Interface string: 00
Interface descriptor:
Interface number: 01
Alternate setting: 01
Endpoints: 01
Class: FF Vendor Specific
Subclass: 02
Protocol: 00
Interface string: 00
Unknown descriptor:
Length: 07
Type: 24
Contents: 01070001000B24
Unknown descriptor:
Length: 0B
Type: 24
Contents: 02010203180144AC000705
Endpoint descriptor:
Endpoint address: 02 Direction: IN
Attributes: 05 Transfer type: Isochronous,
Sync Type: Data,
Usage Type: Data
Max.packet size: 0120
Polling interval: 01 1 ms
Unknown descriptor:
Length: 07
Type: 25
Contents: 01000000000904
Interface descriptor:
Interface number: 02
Alternate setting: 00
Endpoints: 02
Class: FF Vendor Specific
Subclass: 03
Protocol: 00
Interface string: 00
Endpoint descriptor:
Endpoint address: 03 Direction: OUT
Attributes: 02 Transfer type: Bulk
Max.packet size: 0020
Polling interval: 00 0 ms
Endpoint descriptor:
Endpoint address: 04 Direction: IN
Attributes: 02 Transfer type: Bulk
Max.packet size: 0020
Polling interval: 00 0 ms
Interface descriptor:
Interface number: 02
Alternate setting: 01
Endpoints: 02
Class: FF Vendor Specific
Subclass: 03
Protocol: 00
Interface string: 00
Endpoint descriptor:
Endpoint address: 03 Direction: OUT
Attributes: 02 Transfer type: Bulk
Max.packet size: 0020
Polling interval: 01 1 ms
Endpoint descriptor:
Endpoint address: 04 Direction: IN
Attributes: 03 Transfer type: Interrupt
Max.packet size: 0020
Polling interval: 01 1 ms
Descriptor params
#define ME25_ADDR 1
#define ME25_VID_LO 0xFFFFFF82
#define ME25_VID_HI 0x05
#define ME25_PID_LO 0x13 // Batch Device
#define ME25_PID_HI 0x01
#define ME25_CONFIG 1
#define ME25_IF 0
#define ME25_NUM_EP 3 //EP record structure for ME25 controller
#define EP_MAXPKTSIZE 0x08
#define EP_BULK 0x03
#define EP_POLL 0x01
#define CONTROL_EP 0
#define OUTPUT_EP 1
#define INPUT_EP 2
#define ME25_01_REPORT_LEN 0x09
#define ME25_DESCR_LEN 0x9B
EP_RECORD ep_record[ ME25_NUM_EP ]; //EP record structure for ME25 controller
Product’s init
void ME25_init( void ){
byte rcode = 0;
ep_record[ CONTROL_EP ] = *( Usb.getDevTableEntry( 0 , 0 ));// copy EP 0 params
ep_record[ OUTPUT_EP ].epAddr = OUTPUT_EP; // Output endpoint
ep_record[ OUTPUT_EP ].Attr = EP_BULK;
ep_record[ OUTPUT_EP ].MaxPktSize = EP_MAXPKTSIZE;
ep_record[ OUTPUT_EP ].Interval = EP_POLL;
ep_record[ OUTPUT_EP ].sndToggle = bmSNDTOG0;
ep_record[ OUTPUT_EP ].rcvToggle = bmRCVTOG0;
ep_record[ INPUT_EP ].epAddr = INPUT_EP; // Input endpoint
ep_record[ INPUT_EP ].Attr = EP_BULK;
ep_record[ INPUT_EP ].MaxPktSize = EP_MAXPKTSIZE;
ep_record[ INPUT_EP ].Interval = EP_POLL;
ep_record[ INPUT_EP ].sndToggle = bmSNDTOG0;
ep_record[ INPUT_EP ].rcvToggle = bmRCVTOG0;
Usb.setDevTableEntry( ME25_ADDR, ep_record );//plug kbd.EP params to devtable
rcode=Usb.getDevDescr(ME25_ADDR,ep_record[CONTROL_EP].epAddr,ME25_DESCR_LEN,descrBuf);
if((descrBuf[ 8 ] != ME25_VID_LO) || (descrBuf[ 9 ] != ME25_VID_HI) || (descrBuf[ 10 ] != ME25_PID_LO) || (descrBuf[ 11 ] != ME25_PID_HI) ){
Serial.println("Unsupported USB Device");
while(1); //stop
}
rcode = Usb.setConf( ME25_ADDR, ep_record[ CONTROL_EP ].epAddr, ME25_CONFIG );
if( rcode ) {
Serial.print("Error attempting to configure ME25. Return code :");
Serial.println( rcode, HEX );
while(1); //stop
}
Serial.println("ME25 Ready");
}
Start & Polling
MAX3421E Max;
USB Usb;
void setup() {
Serial.begin(9600);
Max.powerOn();
delay(200);
}
void loop() {
Max.Task();
Usb.Task();
//wait for addressing state
if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING ) {
ME25_init();
Usb.setUsbTaskState( USB_STATE_RUNNING );
}
//poll the ME25 Controller
if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) {
process_report();
}
}
Function while polling
void process_report(void){
serialOutput(msgMute, sizeof(msgMute), "msgMute"); //Returns 0's
delay(2000);
serialOutput(msgClean, sizeof(msgClean), "msgClean"); //Returns 0's
while(1);
}
The actual message being sent
void serialOutput(char input[], int length, String message) {
byte rcode = 0;
//Serial.println(message);
for(int i = 0; i < 10; i++){
rcode = Usb.setReport(ME25_ADDR, 0x00, length, ME25_IF, 0x02, 0x00, input);
Serial.print(rcode, HEX);
delay(200);
}
Serial.println("");
}
The message
char msgClean[] = {
/**HEADERS**/
0xF0, 0x41, 0x10, 0x00, 0x00, 0x45, 0x12, 0x7F, 0x00, 0x00, 0x00,
/**STRUCTURE**/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x00, 0x5A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20,
0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20,
/**FOOTER**/
/*CheckSum2*/ 0x7C,
/*Footer1*/ 0xF7
};