summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Golovanov <[email protected]>2021-02-06 00:01:46 +0300
committerAlexander Golovanov <[email protected]>2021-02-06 00:01:46 +0300
commit9f7143af29814156482c5e80bab925687e37b16d (patch)
treef62ae458e572c25cef51e492eb169a94b7b73594
parent2a34be2eb0654198f535afced31556d832b4bf58 (diff)
CDC-like blocking behaviour for MIDI
Also added a dummy readout for MIDI into examples
-rw-r--r--examples/device/dynamic_configuration/src/main.c6
-rw-r--r--examples/device/midi_test/src/main.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/examples/device/dynamic_configuration/src/main.c b/examples/device/dynamic_configuration/src/main.c
index 3ad13aefa..45786e99a 100644
--- a/examples/device/dynamic_configuration/src/main.c
+++ b/examples/device/dynamic_configuration/src/main.c
@@ -165,6 +165,12 @@ void midi_task(void)
{
static uint32_t start_ms = 0;
+ // The MIDI interface always creates input and output port/jack descriptors
+ // regardless of these being used or not. Therefore incoming traffic should be read
+ // (possibly just discarded) to avoid the sender blocking in IO
+ uint8_t packet[4];
+ while(tud_midi_available()) tud_midi_receive(packet);
+
// send note every 1000 ms
if (board_millis() - start_ms < 286) return; // not enough time
start_ms += 286;
diff --git a/examples/device/midi_test/src/main.c b/examples/device/midi_test/src/main.c
index 96292dd6b..d92621fc9 100644
--- a/examples/device/midi_test/src/main.c
+++ b/examples/device/midi_test/src/main.c
@@ -125,6 +125,12 @@ void midi_task(void)
{
static uint32_t start_ms = 0;
+ // The MIDI interface always creates input and output port/jack descriptors
+ // regardless of these being used or not. Therefore incoming traffic should be read
+ // (possibly just discarded) to avoid the sender blocking in IO
+ uint8_t packet[4];
+ while(tud_midi_available()) tud_midi_receive(packet);
+
// send note every 1000 ms
if (board_millis() - start_ms < 286) return; // not enough time
start_ms += 286;