aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/LowLevel/MIDI/MIDI.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-08 07:46:07 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-08 07:46:07 +0000
commite6881fd166586793a5a90effeefe4188092f383b (patch)
tree18812dc15a6837bd283593fa4da59cee89a3b1ed /Demos/Device/LowLevel/MIDI/MIDI.c
parentac70ddd0a1c412bb54def48e53caaebd0b5c9c61 (diff)
downloadlufa-e6881fd166586793a5a90effeefe4188092f383b.tar.gz
lufa-e6881fd166586793a5a90effeefe4188092f383b.tar.bz2
lufa-e6881fd166586793a5a90effeefe4188092f383b.zip
Error status LEDs shown when device endpoint configuration fails to complete.
MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready.
Diffstat (limited to 'Demos/Device/LowLevel/MIDI/MIDI.c')
-rw-r--r--Demos/Device/LowLevel/MIDI/MIDI.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/Demos/Device/LowLevel/MIDI/MIDI.c b/Demos/Device/LowLevel/MIDI/MIDI.c
index 6dd38af85..856f7dbe9 100644
--- a/Demos/Device/LowLevel/MIDI/MIDI.c
+++ b/Demos/Device/LowLevel/MIDI/MIDI.c
@@ -90,17 +90,23 @@ void EVENT_USB_Disconnect(void)
*/
void EVENT_USB_ConfigurationChanged(void)
{
- /* Setup MIDI stream endpoints */
- Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK,
- ENDPOINT_DIR_OUT, MIDI_STREAM_EPSIZE,
- ENDPOINT_BANK_SINGLE);
-
- Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPNUM, EP_TYPE_BULK,
- ENDPOINT_DIR_IN, MIDI_STREAM_EPSIZE,
- ENDPOINT_BANK_SINGLE);
-
/* Indicate USB connected and ready */
LEDs_SetAllLEDs(LEDMASK_USB_READY);
+
+ /* Setup MIDI stream endpoints */
+ if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPNUM, EP_TYPE_BULK,
+ ENDPOINT_DIR_OUT, MIDI_STREAM_EPSIZE,
+ ENDPOINT_BANK_SINGLE)))
+ {
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ }
+
+ if (!(Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPNUM, EP_TYPE_BULK,
+ ENDPOINT_DIR_IN, MIDI_STREAM_EPSIZE,
+ ENDPOINT_BANK_SINGLE)))
+ {
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ }
}
/** Task to handle the generation of MIDI note change events in response to presses of the board joystick, and send them
@@ -159,8 +165,9 @@ void MIDI_Task(void)
*/
void SendMIDINoteChange(const uint8_t Pitch, const bool OnOff, const uint8_t CableID, const uint8_t Channel)
{
- /* Wait until endpoint ready for more data */
- while (!(Endpoint_IsReadWriteAllowed()));
+ /* If endpoint ready for more data, abort */
+ if (!(Endpoint_IsReadWriteAllowed()))
+ return;
/* Check if the message should be a Note On or Note Off command */
uint8_t Command = ((OnOff)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);