Go to the documentation of this file.
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;
289 if(
vid == 0x1235 ) {
294 if(
pid == 0x20 ||
pid == 0x36 ||
pid == 0x51 ||
pid == 0x69 ) {
300 if( ( 0x30 <=
pid &&
pid <= 0x32) ||
pid == 0x35 || ( 0x7B <=
pid &&
pid <= 0x7D) ) {
317 dataptr[*bytes_rcvd] =
'\0';
318 dataptr[(*bytes_rcvd)+1] =
'\0';
336 goto RecvData_return_from_buffer;
351 RecvData_return_from_buffer:
354 if( isRaw ==
true ) {
369 uint8_t status = dataptr[0];
372 if ( status == 0xf0 ) {
378 buf[0] = (uint8_t)(nCable << 4) | cin;
405 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);
410 #ifdef DEBUG_USB_HOST
413 USBTRACE(
"Endpoint descriptor:\r\n");
441 if( *dataptr != 0xf0 ){
446 while(*dataptr != 0xf7) {
463 uint16_t n = datasize;
470 uint16_t pktSize = (n+2)/3;
476 buf[wptr] = (nCable << 4) | 0x4;
480 buf[wptr++] = (nCable << 4) | 0x5;
481 buf[wptr++] = *(dataptr++);
487 buf[wptr++] = (nCable << 4) | 0x6;
488 buf[wptr++] = *(dataptr++);
489 buf[wptr++] = *(dataptr++);
494 buf[wptr] = (nCable << 4) | 0x7;
498 buf[wptr++] = *(dataptr++);
499 buf[wptr++] = *(dataptr++);
500 buf[wptr++] = *(dataptr++);
505 if( wptr >= maxpkt || n == 0 ){
519 uint8_t cin = *(p) & 0x0f;
522 if( (cin & 0xc) != 4 )
return rc;
550 theXtractor(xtractor),
555 isMidiSearch(modeMidi){
556 theBuffer.
pValue = varBuffer;
560 void MidiDescParser::Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset __attribute__((unused))) {
561 uint16_t cntdn = (uint16_t)len;
562 uint8_t *p = (uint8_t*)pbuf;
565 if(!ParseDescriptor(&p, &cntdn))
569 bool MidiDescParser::ParseDescriptor(uint8_t **pp, uint16_t *pcntdn) {
572 switch(stateParseDescr) {
579 if(!valParser.
Parse(pp, pcntdn))
581 dscrLen = *((uint8_t*)theBuffer.
pValue);
582 dscrType = *((uint8_t*)theBuffer.
pValue + 1);
591 theBuffer.
pValue = varBuffer + 2;
597 isGoodInterface =
false;
611 if(!valParser.
Parse(pp, pcntdn))
616 if(!valParser.
Parse(pp, pcntdn))
618 USBTRACE(
"Interface descriptor:\r\n");
631 USBTRACE(
"-MIDI not found\r\n\r\n");
635 isGoodInterface =
true;
642 if(!valParser.
Parse(pp, pcntdn))
644 if(isGoodInterface && nEPs < 2){
645 USBTRACE(
">Extracting endpoint\r\n");
652 if(!theSkipper.
Skip(pp, pcntdn, dscrLen - 2))
655 theBuffer.
pValue = varBuffer;
663 uint8_t iface __attribute__((unused)),
664 uint8_t alt __attribute__((unused)),
665 uint8_t proto __attribute__((unused)),
670 #ifdef DEBUG_USB_HOST
671 PrintEndpointDescriptor(pep);
678 USBTRACE(
"-No valid EP found.\r\n");
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
uint8_t bConfigurationValue
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
uint16_t countSysExDataSize(uint8_t *dataptr)
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
void Initialize(MultiValueBuffer *pbuf)
uint8_t bInterfaceSubClass
virtual bool EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset)
#define USBH_MIDI_VERSION
#define MIDI_MAX_SYSEX_SIZE
#define USB_DESCRIPTOR_ENDPOINT
#define USB_DESCRIPTOR_CONFIGURATION
void D_PrintHex(T val, int lvl)
bool Parse(uint8_t **pp, uint16_t *pcntdn)
#define HID_DESCRIPTOR_HID
uint8_t getMsgSizeFromCin(uint8_t cin)
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
static const uint8_t epDataInIndex
uint8_t bInterfaceProtocol
#define USB_SUBCLASS_MIDISTREAMING
void Initialize(MultiValueBuffer *const pbuf)
#define USB_NAK_MAX_POWER
uint8_t recvBuf[MIDI_EVENT_PACKET_SIZE]
#define USB_DESCRIPTOR_INTERFACE
uint8_t convertStatus2Cin(uint8_t status)
#define bmUSB_TRANSFER_TYPE
void setupDeviceSpecific()
uint8_t lookupMsgSize(uint8_t midiMsg, uint8_t cin=0)
#define MIDI_MAX_ENDPOINTS
uint8_t extractSysExData(uint8_t *p, uint8_t *buf)
uint8_t SendData(uint8_t *dataptr, uint8_t nCable=0)
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
#define USB_ERROR_EPINFO_IS_NULL
virtual uint8_t Release()
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
bool Skip(uint8_t **pp, uint16_t *pcntdn, uint16_t bytes_to_skip)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
uint8_t bTransferTypeMask
bool EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
virtual void FreeAddress(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
uint8_t SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable=0)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
uint8_t bAlternateSetting
MidiDescParser(UsbMidiConfigXtracter *xtractor, bool modeMidi)
#define MIDI_EVENT_PACKET_SIZE
EpInfo epInfo[MIDI_MAX_ENDPOINTS]
static const uint8_t epDataOutIndex
#define USB_TRANSFER_TYPE_BULK
uint8_t RecvData(uint16_t *bytes_rcvd, uint8_t *dataptr)
AddressPool & GetAddressPool()