Skip to content

Commit

Permalink
Merge pull request #705 from YuuichiAkagawa/pr_usbh_midi_100
Browse files Browse the repository at this point in the history
Update MIDI driver v1.0.0
  • Loading branch information
Lauszus committed Apr 23, 2022
2 parents 9184254 + 3aca1f3 commit 6ab44fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 9 additions & 3 deletions usbh_midi.cpp
Expand Up @@ -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:
Expand All @@ -275,10 +276,14 @@ uint8_t USBH_MIDI::Init(uint8_t parent, uint8_t port, bool lowspeed)
/* 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;
}

Expand All @@ -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;
}
Expand Down
7 changes: 6 additions & 1 deletion usbh_midi.h
Expand Up @@ -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
Expand Down Expand Up @@ -137,8 +137,13 @@ class USBH_MIDI : public USBDeviceConfig, public UsbMidiConfigXtracter
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_

0 comments on commit 6ab44fa

Please sign in to comment.