diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-20 13:04:26 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2012-05-20 13:04:26 +0000 |
commit | 82162c710c3c26739c07b41b20048c30cce78943 (patch) | |
tree | f13423bf8139c609988242c76be20c29fe341e24 | |
parent | f2ae4dc255bd86438cffb62c138326b1c0b5725f (diff) | |
download | lufa-82162c710c3c26739c07b41b20048c30cce78943.tar.gz lufa-82162c710c3c26739c07b41b20048c30cce78943.tar.bz2 lufa-82162c710c3c26739c07b41b20048c30cce78943.zip |
Additional fixes to the MIDI host driver due to not unfreezing/re-freezing pipes correctly (thanks to Michael Brown).
-rw-r--r-- | Demos/Host/LowLevel/MIDIHost/MIDIHost.c | 6 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MIDIClassHost.c | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/Demos/Host/LowLevel/MIDIHost/MIDIHost.c b/Demos/Host/LowLevel/MIDIHost/MIDIHost.c index f4a52accd..f6b607a97 100644 --- a/Demos/Host/LowLevel/MIDIHost/MIDIHost.c +++ b/Demos/Host/LowLevel/MIDIHost/MIDIHost.c @@ -167,6 +167,7 @@ void MIDIHost_Task(void) return; Pipe_SelectPipe(MIDI_DATA_IN_PIPE); + Pipe_Unfreeze(); if (Pipe_IsINReceived()) { @@ -187,8 +188,11 @@ void MIDIHost_Task(void) MIDIEvent.Data2, MIDIEvent.Data3); } } + + Pipe_Freeze(); Pipe_SelectPipe(MIDI_DATA_OUT_PIPE); + Pipe_Unfreeze(); if (Pipe_IsOUTReady()) { @@ -251,6 +255,8 @@ void MIDIHost_Task(void) Pipe_ClearOUT(); } + Pipe_Freeze(); + /* Save previous joystick value for next joystick change detection */ PrevJoystickStatus = JoystickStatus; } diff --git a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c index 1300577fc..b1abb68d7 100644 --- a/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c +++ b/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c @@ -156,15 +156,21 @@ uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) uint8_t ErrorCode; Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipe.Address); - + Pipe_Unfreeze(); + if (Pipe_BytesInPipe()) { Pipe_ClearOUT(); if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) - return ErrorCode; + { + Pipe_Freeze(); + return ErrorCode; + } } + Pipe_Freeze(); + return PIPE_READYWAIT_NoError; } @@ -177,13 +183,19 @@ uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterface uint8_t ErrorCode; Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipe.Address); - + Pipe_Unfreeze(); + if ((ErrorCode = Pipe_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != PIPE_RWSTREAM_NoError) - return ErrorCode; + { + Pipe_Freeze(); + return ErrorCode; + } if (!(Pipe_IsReadWriteAllowed())) Pipe_ClearOUT(); + Pipe_Freeze(); + return PIPE_RWSTREAM_NoError; } |