Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 16 Jun 2009 07:17:22 +0000 (07:17 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 16 Jun 2009 07:17:22 +0000 (07:17 +0000)
Change MIDI demos to use real MIDI command values, and shift for the USB wrapper, rather than shift for the MIDI bytes. This is a little confusing for the MIDI USB wrapper, but allows for the use of real standardized MIDI command values.

Demos/Device/ClassDriver/MIDI/MIDI.c
Demos/Device/LowLevel/MIDI/MIDI.c
Demos/Device/LowLevel/MIDI/MIDI.h
LUFA/Drivers/USB/Class/Common/MIDI.h
LUFA/Drivers/USB/LowLevel/Pipe.h
LUFA/ManPages/ChangeLog.txt
Projects/MissleLauncher/MissileLauncher.c

index 234adca..511f280 100644 (file)
@@ -139,9 +139,9 @@ void CheckJoystickMovement(void)
                USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)\r
                        {\r
                                .CableNumber = 0,\r
-                               .Command     = MIDICommand,\r
+                               .Command     = (MIDICommand >> 4),\r
                                \r
-                               .Data1       = (MIDICommand << 4) | Channel,\r
+                               .Data1       = MIDICommand | Channel,\r
                                .Data2       = MIDIPitch,\r
                                .Data3       = MIDI_STANDARD_VELOCITY,                  \r
                        };\r
index c74d8d5..84d3778 100644 (file)
@@ -168,9 +168,9 @@ void MIDI_Task(void)
                        USB_MIDI_EventPacket_t MIDIEvent = (USB_MIDI_EventPacket_t)\r
                                {\r
                                        .CableNumber = 0,\r
-                                       .Command     = MIDICommand,\r
+                                       .Command     = (MIDICommand >> 4),\r
                                        \r
-                                       .Data1       = (MIDICommand << 4) | Channel,\r
+                                       .Data1       = MIDICommand | Channel,\r
                                        .Data2       = MIDIPitch,\r
                                        .Data3       = MIDI_STANDARD_VELOCITY,                  \r
                                };\r
index 1558501..735ac84 100644 (file)
 \r
    /* Macros: */\r
                /** MIDI command for a note on (activation) event */\r
-               #define MIDI_COMMAND_NOTE_ON         0x09\r
+               #define MIDI_COMMAND_NOTE_ON      0x90\r
 \r
                /** MIDI command for a note off (deactivation) event */\r
-               #define MIDI_COMMAND_NOTE_OFF        0x08\r
+               #define MIDI_COMMAND_NOTE_OFF     0x80\r
 \r
                /** Standard key press velocity value used for all note events, as no pressure sensor is mounted */\r
-               #define MIDI_STANDARD_VELOCITY       64\r
+               #define MIDI_STANDARD_VELOCITY    64\r
                \r
                /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel\r
                 *  addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.\r
                 *\r
                 *  \param channel  MIDI channel number to address\r
                 */\r
-               #define MIDI_CHANNEL(channel)        (channel - 1)\r
+               #define MIDI_CHANNEL(channel)     (channel - 1)\r
 \r
                /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */\r
                #define LEDMASK_USB_NOTREADY      LEDS_LED1\r
index 05bd846..f768ba2 100644 (file)
                #define MIDI_JACKTYPE_EXTERNAL      0x02\r
 \r
                /** MIDI command for a note on (activation) event */\r
-               #define MIDI_COMMAND_NOTE_ON        0x09\r
+               #define MIDI_COMMAND_NOTE_ON        0x90\r
 \r
                /** MIDI command for a note off (deactivation) event */\r
-               #define MIDI_COMMAND_NOTE_OFF       0x08\r
+               #define MIDI_COMMAND_NOTE_OFF       0x80\r
 \r
                /** Standard key press velocity value used for all note events */\r
                #define MIDI_STANDARD_VELOCITY      64\r
index f3da9d1..62cbe65 100644 (file)
 \r
        /* Public Interface - May be used in end-application: */\r
                /* Macros: */\r
+                       /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
+                       #define PIPE_ERRORFLAG_OVERFLOW         (1 << 6)\r
+\r
+                       /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
+                       #define PIPE_ERRORFLAG_UNDERFLOW        (1 << 5)\r
+\r
                        /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
                        #define PIPE_ERRORFLAG_CRC16            (1 << 4)\r
 \r
                                \r
                                #define Pipe_ClearErrorFlags()         MACROS{ UPERRX = 0; }MACROE\r
 \r
-                               #define Pipe_GetErrorFlags()           UPERRX\r
+                               #define Pipe_GetErrorFlags()           ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | \\r
+                                                                                  PIPE_ERRORFLAG_PID   | PIPE_ERRORFLAG_DATAPID | \\r
+                                                                                  PIPE_ERRORFLAG_DATATGL))                      | \\r
+                                                                       (UPSTAX & PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW))\r
 \r
                                #define Pipe_IsReadWriteAllowed()      ((UPINTX & (1 << RWAL)) ? true : false)\r
 \r
index 6343d3f..b3d533d 100644 (file)
@@ -21,6 +21,7 @@
   *  - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB\r
   *    host mode\r
   *  - Added USB Missle Launcher project, submitted by Dave Fletcher\r
+  *  - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors\r
   *\r
   *\r
   *  \section Sec_ChangeLog090605 Version 090605\r
index cb12e2a..e70187b 100644 (file)
@@ -64,8 +64,8 @@ uint8_t CMD_LEFTDOWN[8]  = {   0,  1,  0,  0,  1,  0,  8,  8  };
 uint8_t CMD_RIGHTDOWN[8] = {   0,  0,  1,  0,  1,  0,  8,  8  };\r
 uint8_t CMD_FIRE[8]      = {   0,  0,  0,  0,  0,  1,  8,  8  };\r
 \r
-uint8_t *CmdState;\r
-uint8_t CmdBuffer[LAUNCHER_CMD_BUFFER_SIZE];\r
+uint8_tCmdState;\r
+uint8_t  CmdBuffer[LAUNCHER_CMD_BUFFER_SIZE];\r
 \r
 /** Main program entry point. This routine configures the hardware required by the application, then\r
  *  starts the scheduler to run the application tasks.\r