Update MIDI driver v1.0.0

This commit is contained in:
Yuuichi Akagawa 2022-04-21 21:53:19 +09:00
parent 9184254b87
commit 3aca1f36f5
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) if (rcode)
goto FailSetConfDescr; goto FailSetConfDescr;
bPollEnable = true;
if(pFuncOnInit) if(pFuncOnInit)
pFuncOnInit(); // Call the user function pFuncOnInit(); // Call the user function
bPollEnable = true;
USBTRACE("Init done.\r\n"); USBTRACE("Init done.\r\n");
return 0; return 0;
FailGetDevDescr: FailGetDevDescr:
@ -275,10 +276,14 @@ FailSetConfDescr:
/* Performs a cleanup after failed Init() attempt */ /* Performs a cleanup after failed Init() attempt */
uint8_t USBH_MIDI::Release() uint8_t USBH_MIDI::Release()
{ {
if(pFuncOnRelease && bPollEnable)
pFuncOnRelease(); // Call the user function
pUsb->GetAddressPool().FreeAddress(bAddress); pUsb->GetAddressPool().FreeAddress(bAddress);
bAddress = 0; bAddress = 0;
bPollEnable = false; bPollEnable = false;
readPtr = 0; readPtr = 0;
return 0; return 0;
} }
@ -296,8 +301,9 @@ void USBH_MIDI::setupDeviceSpecific()
return; return;
} }
// LaunchKey: 0x30-32, 0x35:Mini, 0x7B-0x7D:MK2 // 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) ) { if( (0x30 <= pid && pid <= 0x32) || pid == 0x35 || (0x7B <= pid && pid <= 0x7D)
|| pid == 0x102 || (0x113 <= pid && pid <= 0x122) || (0x134 <= pid && pid <= 0x137) ) {
bTransferTypeMask = 2; bTransferTypeMask = 2;
return; return;
} }

View file

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