diff options
Diffstat (limited to 'Demos/Device/LowLevel/MIDI/MIDI.c')
-rw-r--r-- | Demos/Device/LowLevel/MIDI/MIDI.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Demos/Device/LowLevel/MIDI/MIDI.c b/Demos/Device/LowLevel/MIDI/MIDI.c index 84d377854..954cbcbf6 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_IsConnected) || !(USB_ConfigurationNumber))
+ 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);
|