Leonardo LEDs are RX/TX active Low and USER active high, not the other way around.
[pub/USBasp.git] / Demos / Host / ClassDriver / MIDIHost / MIDIHost.c
index 068730c..04a9454 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2012.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -44,11 +44,16 @@ USB_ClassInfo_MIDI_Host_t Keyboard_MIDI_Interface =
        {
                .Config =
                        {
        {
                .Config =
                        {
-                               .DataINPipeNumber       = 1,
-                               .DataINPipeDoubleBank   = false,
-
-                               .DataOUTPipeNumber      = 2,
-                               .DataOUTPipeDoubleBank  = false,
+                               .DataINPipe             =
+                                       {
+                                               .Address        = (PIPE_DIR_IN  | 1),
+                                               .Banks          = 1,
+                                       },
+                               .DataOUTPipe            =
+                                       {
+                                               .Address        = (PIPE_DIR_OUT | 2),
+                                               .Banks          = 1,
+                                       },
                        },
        };
 
                        },
        };
 
@@ -96,7 +101,7 @@ void SetupHardware(void)
 }
 
 /** Task to manage an enumerated USB MIDI device once connected, to display received
 }
 
 /** Task to manage an enumerated USB MIDI device once connected, to display received
- *  note events from the host and send note changes in response to tbe board's joystick.
+ *  note events from the host and send note changes in response to the board's joystick.
  */
 void JoystickHost_Task(void)
 {
  */
 void JoystickHost_Task(void)
 {
@@ -106,8 +111,8 @@ void JoystickHost_Task(void)
        MIDI_EventPacket_t MIDIEvent;
        while (MIDI_Host_ReceiveEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent))
        {
        MIDI_EventPacket_t MIDIEvent;
        while (MIDI_Host_ReceiveEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent))
        {
-               bool NoteOnEvent  = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_ON  >> 4));
-               bool NoteOffEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_OFF >> 4));
+               bool NoteOnEvent  = (MIDIEvent.Event == MIDI_EVENT(0, MIDI_COMMAND_NOTE_ON));
+               bool NoteOffEvent = (MIDIEvent.Event == MIDI_EVENT(0, MIDI_COMMAND_NOTE_OFF));
 
                /* Display note events from the host */
                if (NoteOnEvent || NoteOffEvent)
 
                /* Display note events from the host */
                if (NoteOnEvent || NoteOffEvent)
@@ -168,8 +173,7 @@ void CheckJoystickMovement(void)
        {
                MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
                        {
        {
                MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
                        {
-                               .CableNumber = 0,
-                               .Command     = (MIDICommand >> 4),
+                               .Event       = MIDI_EVENT(0, MIDICommand),
 
                                .Data1       = MIDICommand | Channel,
                                .Data2       = MIDIPitch,
 
                                .Data1       = MIDICommand | Channel,
                                .Data2       = MIDIPitch,