X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/dcf303762ad6b1401d2dcfd763764b400dcee2f7..b9dd51cd632c1a8cff18f77b4f09c33bdf804768:/Demos/Device/LowLevel/MIDI/MIDI.c?ds=inline diff --git a/Demos/Device/LowLevel/MIDI/MIDI.c b/Demos/Device/LowLevel/MIDI/MIDI.c index 84d377854..8aed527db 100644 --- a/Demos/Device/LowLevel/MIDI/MIDI.c +++ b/Demos/Device/LowLevel/MIDI/MIDI.c @@ -116,16 +116,17 @@ void MIDI_Task(void) { static uint8_t PrevJoystickStatus; - /* Select the MIDI IN stream */ + /* Device must be connected and configured for the task to run */ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM); - /* Check if endpoint is ready to be written to */ if (Endpoint_IsINReady()) { uint8_t MIDICommand = 0; uint8_t MIDIPitch; - /* Get current joystick mask, XOR with previous to detect joystick changes */ uint8_t JoystickStatus = Joystick_GetStatus(); uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);