{\r
static uint8_t PrevJoystickStatus;\r
\r
- /* Select the MIDI IN stream */\r
+ /* Device must be connected and configured for the task to run */\r
+ if (!(USB_IsConnected) || !(USB_ConfigurationNumber))\r
+ return;\r
+\r
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);\r
\r
- /* Check if endpoint is ready to be written to */\r
if (Endpoint_IsINReady())\r
{\r
uint8_t MIDICommand = 0;\r
uint8_t MIDIPitch;\r
\r
- /* Get current joystick mask, XOR with previous to detect joystick changes */\r
uint8_t JoystickStatus = Joystick_GetStatus();\r
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);\r
\r