diff options
| author | hathach <[email protected]> | 2021-04-02 13:26:55 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-04-02 13:26:55 +0700 |
| commit | 080b14b292251e46b43aac9e1cf7807dc2d3eb2c (patch) | |
| tree | a22f89ff2ebc16d814535334673b6720c1e9771a /examples | |
| parent | 949ff791e0222d9d89fe54b7cab036125997b66e (diff) | |
fix midi tx fifo overflow cause data corruption
rename
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/dynamic_configuration/src/main.c | 2 | ||||
| -rw-r--r-- | examples/device/midi_test/src/main.c | 8 | ||||
| -rw-r--r-- | examples/make.mk | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/examples/device/dynamic_configuration/src/main.c b/examples/device/dynamic_configuration/src/main.c index acee295f6..ce1f752d0 100644 --- a/examples/device/dynamic_configuration/src/main.c +++ b/examples/device/dynamic_configuration/src/main.c @@ -172,7 +172,7 @@ void midi_task(void) // 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); + while( tud_midi_available() ) tud_midi_packet_read(packet); // send note every 1000 ms if (board_millis() - start_ms < 286) return; // not enough time diff --git a/examples/device/midi_test/src/main.c b/examples/device/midi_test/src/main.c index 858a096b6..af10350df 100644 --- a/examples/device/midi_test/src/main.c +++ b/examples/device/midi_test/src/main.c @@ -132,7 +132,7 @@ void midi_task(void) // 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); + while ( tud_midi_available() ) tud_midi_packet_read(packet); // send note every 1000 ms if (board_millis() - start_ms < 286) return; // not enough time @@ -146,10 +146,12 @@ void midi_task(void) if (previous < 0) previous = sizeof(note_sequence) - 1; // Send Note On for current position at full velocity (127) on channel 1. - tud_midi_write24(cable_num, 0x90 | channel, note_sequence[note_pos], 127); + uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 }; + tud_midi_write(cable_num, note_on, 3); // Send Note Off for previous note. - tud_midi_write24(cable_num, 0x80 | channel, note_sequence[previous], 0); + uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0}; + tud_midi_write(cable_num, note_off, 3); // Increment position note_pos++; diff --git a/examples/make.mk b/examples/make.mk index e04a2592a..ffcb8ee5c 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -103,7 +103,7 @@ CFLAGS += \ # Debugging/Optimization ifeq ($(DEBUG), 1) - CFLAGS += -Og + CFLAGS += -O0 else CFLAGS += -Os endif |
