Merge pull request #705 from YuuichiAkagawa/pr_usbh_midi_100

Update MIDI driver v1.0.0
This commit is contained in:
Kristian Sloth Lauszus 2022-04-24 00:50:32 +02:00 committed by GitHub
commit 6ab44fafd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -258,10 +258,11 @@ uint8_t USBH_MIDI::Init(uint8_t parent, uint8_t port, bool lowspeed)
if (rcode)
goto FailSetConfDescr;
bPollEnable = true;
if(pFuncOnInit)
pFuncOnInit(); // Call the user function
bPollEnable = true;
USBTRACE("Init done.\r\n");
return 0;
FailGetDevDescr:
@ -275,10 +276,14 @@ FailSetConfDescr:
/* Performs a cleanup after failed Init() attempt */
uint8_t USBH_MIDI::Release()
{
if(pFuncOnRelease && bPollEnable)
pFuncOnRelease(); // Call the user function
pUsb->GetAddressPool().FreeAddress(bAddress);
bAddress = 0;
bPollEnable = false;
readPtr = 0;
return 0;
}
@ -296,8 +301,9 @@ void USBH_MIDI::setupDeviceSpecific()
return;
}
// LaunchKey: 0x30-32, 0x35:Mini, 0x7B-0x7D:MK2
if( ( 0x30 <= pid && pid <= 0x32) || pid == 0x35 || ( 0x7B <= pid && pid <= 0x7D) ) {
// LaunchKey: 0x30-32, 0x35:Mini, 0x7B-0x7D:MK2, 0x0102,0x113-0x122:MiniMk3, 0x134-0x137:MK3
if( (0x30 <= pid && pid <= 0x32) || pid == 0x35 || (0x7B <= pid && pid <= 0x7D)
|| pid == 0x102 || (0x113 <= pid && pid <= 0x122) || (0x134 <= pid && pid <= 0x137) ) {
bTransferTypeMask = 2;
return;
}

View file

@ -28,7 +28,7 @@
#define _USBH_MIDI_H_
#include "Usb.h"
#define USBH_MIDI_VERSION 601
#define USBH_MIDI_VERSION 10000
#define MIDI_MAX_ENDPOINTS 3 //endpoint 0, bulk_IN(MIDI), bulk_OUT(MIDI)
#define USB_SUBCLASS_MIDISTREAMING 3
#define MIDI_EVENT_PACKET_SIZE 64
@ -137,8 +137,13 @@ public:
void attachOnInit(void (*funcOnInit)(void)) {
pFuncOnInit = funcOnInit;
};
void attachOnRelease(void (*funcOnRelease)(void)) {
pFuncOnRelease = funcOnRelease;
};
private:
void (*pFuncOnInit)(void) = nullptr; // Pointer to function called in onInit()
void (*pFuncOnRelease)(void) = nullptr; // Pointer to function called in onRelease()
};
#endif //_USBH_MIDI_H_