Add Midi Endpoint task to ChibiOS main (#8071)

master
Drashna Jaelre 2020-02-04 18:28:47 -08:00 committed by GitHub
parent 8a749a7a8e
commit 0010d0c45e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -81,6 +81,9 @@ void raw_hid_task(void);
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
void console_task(void); void console_task(void);
#endif #endif
#ifdef MIDI_ENABLE
void midi_ep_task(void);
#endif
/* TESTING /* TESTING
* Amber LED blinker thread, times are in milliseconds. * Amber LED blinker thread, times are in milliseconds.
@ -214,6 +217,9 @@ int main(void) {
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
console_task(); console_task();
#endif #endif
#ifdef MIDI_ENABLE
midi_ep_task();
#endif
#ifdef VIRTSER_ENABLE #ifdef VIRTSER_ENABLE
virtser_task(); virtser_task();
#endif #endif

View File

@ -833,7 +833,17 @@ bool recv_midi_packet(MIDI_EventPacket_t *const event) {
size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE); size_t size = chnReadTimeout(&drivers.midi_driver.driver, (uint8_t *)event, sizeof(MIDI_EventPacket_t), TIME_IMMEDIATE);
return size == sizeof(MIDI_EventPacket_t); return size == sizeof(MIDI_EventPacket_t);
} }
void midi_ep_task(void) {
uint8_t buffer[MIDI_STREAM_EPSIZE];
size_t size = 0;
do {
size_t size = chnReadTimeout(&drivers.midi_driver.driver, buffer, sizeof(buffer), TIME_IMMEDIATE);
if (size > 0) {
MIDI_EventPacket_t event;
recv_midi_packet(&event);
}
} while (size > 0);
}
#endif #endif
#ifdef VIRTSER_ENABLE #ifdef VIRTSER_ENABLE