projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Collapse configuration descriptor size retrieval and size testing into a single if...
[pub/USBasp.git]
/
Demos
/
Device
/
LowLevel
/
MIDI
/
MIDI.c
diff --git
a/Demos/Device/LowLevel/MIDI/MIDI.c
b/Demos/Device/LowLevel/MIDI/MIDI.c
index
c74d8d5
..
8aed527
100644
(file)
--- a/
Demos/Device/LowLevel/MIDI/MIDI.c
+++ b/
Demos/Device/LowLevel/MIDI/MIDI.c
@@
-116,16
+116,17
@@
void MIDI_Task(void)
{
\r
static uint8_t PrevJoystickStatus;
\r
\r
{
\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_DeviceState != DEVICE_STATE_Configured)
\r
+ return;
\r
+
\r
Endpoint_SelectEndpoint(MIDI_STREAM_IN_EPNUM);
\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
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
uint8_t JoystickStatus = Joystick_GetStatus();
\r
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
\r
\r
@@
-168,9
+169,9
@@
void MIDI_Task(void)
USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)
\r
{
\r
.CableNumber = 0,
\r
USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)
\r
{
\r
.CableNumber = 0,
\r
- .Command =
MIDICommand
,
\r
+ .Command =
(MIDICommand >> 4)
,
\r
\r
\r
- .Data1 =
(MIDICommand << 4)
| Channel,
\r
+ .Data1 =
MIDICommand
| Channel,
\r
.Data2 = MIDIPitch,
\r
.Data3 = MIDI_STANDARD_VELOCITY,
\r
};
\r
.Data2 = MIDIPitch,
\r
.Data3 = MIDI_STANDARD_VELOCITY,
\r
};
\r