X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f896c00c48f04fb9273555ab8d9b1af99f865d25..cfe054474ffafddcbba0f6d3f46d3f02473fac96:/LUFA/Drivers/USB/Class/Device/MIDI.c diff --git a/LUFA/Drivers/USB/Class/Device/MIDI.c b/LUFA/Drivers/USB/Class/Device/MIDI.c index 1d342f5ce..79d9e742e 100644 --- a/LUFA/Drivers/USB/Class/Device/MIDI.c +++ b/LUFA/Drivers/USB/Class/Device/MIDI.c @@ -33,13 +33,15 @@ #include "MIDI.h" -void MIDI_Device_ProcessControlPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo) +void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { } -bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo) +bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { + memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); + if (MIDIInterfaceInfo->Config.DataINEndpointNumber) { if (!(Endpoint_ConfigureEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_BULK, @@ -63,28 +65,34 @@ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceIn return true; } -void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo) +void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) { } -void MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event) +uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event) { - if (!(USB_IsConnected)) - return; + if (USB_DeviceState != DEVICE_STATE_Configured) + return ENDPOINT_RWSTREAM_NoError; Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber); if (Endpoint_IsReadWriteAllowed()); { - Endpoint_Write_Stream_LE(Event, sizeof(USB_MIDI_EventPacket_t), NO_STREAM_CALLBACK); + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK)) != ENDPOINT_RWSTREAM_NoError) + return ErrorCode; + Endpoint_ClearIN(); } + + return ENDPOINT_RWSTREAM_NoError; } -bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceInfo, USB_MIDI_EventPacket_t* Event) +bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, MIDI_EventPacket_t* const Event) { - if (!(USB_IsConnected)) + if (USB_DeviceState != DEVICE_STATE_Configured) return false; Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpointNumber); @@ -92,7 +100,7 @@ bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* MIDIInterfaceIn if (!(Endpoint_IsReadWriteAllowed())) return false; - Endpoint_Read_Stream_LE(Event, sizeof(USB_MIDI_EventPacket_t), NO_STREAM_CALLBACK); + Endpoint_Read_Stream_LE(Event, sizeof(Event), NO_STREAM_CALLBACK); Endpoint_ClearOUT(); return true;