111 uint8_t bConfNum = 0;
115 #ifdef DEBUG_USB_HOST
158 goto FailGetDevDescr;
192 goto FailGetDevDescr;
195 pid = udd->idProduct;
196 num_of_conf = udd->bNumConfigurations;
202 goto FailSetDevTblEntry;
214 USBTRACE(
"\r\nSTEP1: MIDI Start\r\n");
215 for(uint8_t i = 0; i < num_of_conf; i++) {
219 goto FailGetConfDescr;
229 USBTRACE(
"MIDI not found.\r\nSTEP2: Attempts vendor specific bulk device\r\n");
231 for(uint8_t i = 0; i < num_of_conf; i++) {
235 goto FailGetConfDescr;
242 USBTRACE2(
"\r\nSTEP2: Vendor,NumEP:", bNumEP);
247 goto FailGetConfDescr;
259 goto FailSetConfDescr;
294 if(
vid == 0x1235 ) {
299 if(
pid == 0x20 ||
pid == 0x36 ||
pid == 0x51 ||
pid == 0x69 ) {
305 if( (0x30 <=
pid &&
pid <= 0x32) ||
pid == 0x35 || (0x7B <=
pid &&
pid <= 0x7D)
306 ||
pid == 0x102 || (0x113 <=
pid &&
pid <= 0x122) || (0x134 <=
pid &&
pid <= 0x137) ) {
323 dataptr[*bytes_rcvd] =
'\0';
324 dataptr[(*bytes_rcvd)+1] =
'\0';
342 goto RecvData_return_from_buffer;
357 RecvData_return_from_buffer:
360 if( isRaw ==
true ) {
375 uint8_t status = dataptr[0];
378 if ( status == 0xf0 ) {
384 buf[0] = (uint8_t)(nCable << 4) | cin;
411 Notify(
PSTR(
"SendData():"), 0x80),
D_PrintHex((buf[0]), 0x80),
D_PrintHex((buf[1]), 0x80),
D_PrintHex((buf[2]), 0x80),
D_PrintHex((buf[3]), 0x80),
Notify(
PSTR(
"\r\n"), 0x80);
416 #ifdef DEBUG_USB_HOST
419 USBTRACE(
"Endpoint descriptor:\r\n");
447 if( *dataptr != 0xf0 ){
452 while(*dataptr != 0xf7) {
469 uint16_t n = datasize;
476 uint16_t pktSize = (n+2)/3;
482 buf[wptr] = (nCable << 4) | 0x4;
486 buf[wptr++] = (nCable << 4) | 0x5;
487 buf[wptr++] = *(dataptr++);
493 buf[wptr++] = (nCable << 4) | 0x6;
494 buf[wptr++] = *(dataptr++);
495 buf[wptr++] = *(dataptr++);
500 buf[wptr] = (nCable << 4) | 0x7;
504 buf[wptr++] = *(dataptr++);
505 buf[wptr++] = *(dataptr++);
506 buf[wptr++] = *(dataptr++);
511 if( wptr >= maxpkt || n == 0 ){
525 uint8_t cin = *(p) & 0x0f;
528 if( (cin & 0xc) != 4 )
return rc;
556 theXtractor(xtractor),
561 isMidiSearch(modeMidi){
562 theBuffer.
pValue = varBuffer;
566 void MidiDescParser::Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset __attribute__((unused))) {
567 uint16_t cntdn = (uint16_t)len;
568 uint8_t *p = (uint8_t*)pbuf;
571 if(!ParseDescriptor(&p, &cntdn))
575 bool MidiDescParser::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) {
578 switch(stateParseDescr) {
585 if(!valParser.
Parse(pp, pcntdn))
587 dscrLen = *((uint8_t*)theBuffer.
pValue);
588 dscrType = *((uint8_t*)theBuffer.
pValue + 1);
597 theBuffer.
pValue = varBuffer + 2;
603 isGoodInterface =
false;
617 if(!valParser.
Parse(pp, pcntdn))
622 if(!valParser.
Parse(pp, pcntdn))
624 USBTRACE(
"Interface descriptor:\r\n");
637 USBTRACE(
"-MIDI not found\r\n\r\n");
641 isGoodInterface =
true;
648 if(!valParser.
Parse(pp, pcntdn))
650 if(isGoodInterface && nEPs < 2){
651 USBTRACE(
">Extracting endpoint\r\n");
658 if(!theSkipper.
Skip(pp, pcntdn, dscrLen - 2))
661 theBuffer.
pValue = varBuffer;
669 uint8_t iface __attribute__((unused)),
670 uint8_t alt __attribute__((unused)),
671 uint8_t proto __attribute__((unused)),
676 #ifdef DEBUG_USB_HOST
677 PrintEndpointDescriptor(pep);
684 USBTRACE(
"-No valid EP found.\r\n");
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_ERROR_EPINFO_IS_NULL
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_NAK_MAX_POWER
virtual void FreeAddress(uint8_t addr)=0
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
bool Skip(uint8_t **pp, uint16_t *pcntdn, uint16_t bytes_to_skip)
void Initialize(MultiValueBuffer *pbuf)
void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset)
MidiDescParser(UsbMidiConfigXtracter *xtractor, bool modeMidi)
void Initialize(MultiValueBuffer *const pbuf)
bool Parse(uint8_t **pp, uint16_t *pcntdn)
static const uint8_t epDataInIndex
uint8_t convertStatus2Cin(uint8_t status)
bool EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
uint8_t bTransferTypeMask
static const uint8_t epDataOutIndex
uint8_t SendData(uint8_t *dataptr, uint8_t nCable=0)
uint8_t lookupMsgSize(uint8_t midiMsg, uint8_t cin=0)
virtual uint8_t Release()
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
uint8_t SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable=0)
uint8_t recvBuf[MIDI_EVENT_PACKET_SIZE]
void setupDeviceSpecific()
uint16_t countSysExDataSize(uint8_t *dataptr)
uint8_t extractSysExData(uint8_t *p, uint8_t *buf)
EpInfo epInfo[MIDI_MAX_ENDPOINTS]
uint8_t RecvData(uint16_t *bytes_rcvd, uint8_t *dataptr)
uint8_t getMsgSizeFromCin(uint8_t cin)
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
AddressPool & GetAddressPool()
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
virtual bool EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
void D_PrintHex(T val, int lvl)
uint8_t bConfigurationValue
uint8_t bAlternateSetting
uint8_t bInterfaceSubClass
uint8_t bInterfaceProtocol
#define USB_TRANSFER_TYPE_BULK
#define USB_DESCRIPTOR_INTERFACE
#define HID_DESCRIPTOR_HID
#define USB_DESCRIPTOR_CONFIGURATION
#define bmUSB_TRANSFER_TYPE
#define USB_DESCRIPTOR_ENDPOINT
#define USB_SUBCLASS_MIDISTREAMING
#define MIDI_EVENT_PACKET_SIZE
#define MIDI_MAX_ENDPOINTS
#define MIDI_MAX_SYSEX_SIZE
#define USBH_MIDI_VERSION