27 #if !defined(_USBH_MIDI_H_)
31 #define USBH_MIDI_VERSION 10000
32 #define MIDI_MAX_ENDPOINTS 3
33 #define USB_SUBCLASS_MIDISTREAMING 3
34 #define MIDI_EVENT_PACKET_SIZE 64
35 #define MIDI_MAX_SYSEX_SIZE 256
38 const uint8_t
cin2len[] PROGMEM = {0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1};
39 const uint8_t
sys2cin[] PROGMEM = {0, 2, 3, 2, 0, 0, 5, 0, 0xf, 0, 0xf, 0xf, 0xf, 0, 0xf, 0xf};
48 virtual bool EndpointXtract(uint8_t conf __attribute__((unused)), uint8_t iface __attribute__((unused)), uint8_t alt __attribute__((unused)), uint8_t proto __attribute__((unused)),
const USB_ENDPOINT_DESCRIPTOR *ep __attribute__((unused))) {
58 uint8_t varBuffer[16 ];
60 uint8_t stateParseDescr;
70 bool ParseDescriptor(uint8_t **pp, uint16_t *pcntdn);
74 void Parse(
const uint16_t len,
const uint8_t *pbuf,
const uint16_t &offset);
110 #ifdef DEBUG_USB_HOST
120 uint8_t
RecvData(uint16_t *bytes_rcvd, uint8_t *dataptr);
121 uint8_t
RecvData(uint8_t *outBuf,
bool isRaw=
false);
123 uint8_t
SendData(uint8_t *dataptr, uint8_t nCable=0);
126 uint8_t
SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable=0);
129 inline uint8_t
RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr) {
return RecvData(bytes_rcvd, dataptr); };
133 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
138 pFuncOnInit = funcOnInit;
142 pFuncOnRelease = funcOnRelease;
145 void (*pFuncOnInit)(void) =
nullptr;
146 void (*pFuncOnRelease)(void) =
nullptr;
void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset)
MidiDescParser(UsbMidiConfigXtracter *xtractor, bool modeMidi)
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
uint8_t RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr)
static const uint8_t epDataOutIndex
uint8_t SendRawData(uint16_t bytes_send, uint8_t *dataptr)
void attachOnRelease(void(*funcOnRelease)(void))
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)
void attachOnInit(void(*funcOnInit)(void))
virtual uint8_t GetAddress()
uint8_t getMsgSizeFromCin(uint8_t cin)
uint8_t RecvRawData(uint8_t *outBuf)
uint8_t RcvData(uint8_t *outBuf)
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)
#define MIDI_EVENT_PACKET_SIZE
#define MIDI_MAX_ENDPOINTS
#define pgm_read_byte_near(addr)