diff options
| author | Ha Thach <[email protected]> | 2021-02-06 12:30:28 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-06 12:30:28 +0700 |
| commit | be1bd74b4b0c2392d3232c995a5d0604d7938d85 (patch) | |
| tree | 7fee280ec8d80acf924153ac9403eb2d3b5a215b /examples/device | |
| parent | 7b62c71dd5ec42e61499d2d83902df9484842670 (diff) | |
| parent | 9f7143af29814156482c5e80bab925687e37b16d (diff) | |
Merge pull request #618 from homeodor/master
A CDC-like blocking behaviour for MIDI, incl. SysEx
Diffstat (limited to 'examples/device')
| -rw-r--r-- | examples/device/dynamic_configuration/src/main.c | 6 | ||||
| -rw-r--r-- | examples/device/midi_test/src/main.c | 6 |
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; |
