diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-06 11:11:33 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-06 11:11:33 +0000 |
commit | 1007317c5fd9842036cd1641ffd60eda65034800 (patch) | |
tree | 8f685464bfe09fffe72c28b44de446e4ebda3b92 /LUFA/Drivers/USB | |
parent | 590d9b5ff882182e04dd05209ec46703c29c1e96 (diff) | |
download | lufa-1007317c5fd9842036cd1641ffd60eda65034800.tar.gz lufa-1007317c5fd9842036cd1641ffd60eda65034800.tar.bz2 lufa-1007317c5fd9842036cd1641ffd60eda65034800.zip |
Fixed broken MIDI host driver MIDI_Host_ReceiveEventPacket() function due to not unfreezing the MIDI data IN pipe before use (thanks to Michael Brown).
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MIDIClassHost.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c index 0d33bfec4..1300577fc 100644 --- a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c @@ -192,18 +192,27 @@ bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface { if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive)) return HOST_SENDCONTROL_DeviceDisconnected; + + bool DataReady = false; Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); - if (!(Pipe_IsReadWriteAllowed())) - return false; - - Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL); - - if (!(Pipe_IsReadWriteAllowed())) - Pipe_ClearIN(); + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + { + Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL); + DataReady = true; + } - return true; + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return DataReady; } #endif |