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.
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
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
\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
#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
\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
* - 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
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_t* CmdState;\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