summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/midi
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/midi')
-rw-r--r--tmk_core/protocol/midi/bytequeue/bytequeue.c4
-rw-r--r--tmk_core/protocol/midi/bytequeue/interrupt_setting.c8
-rw-r--r--tmk_core/protocol/midi/midi.c130
-rw-r--r--tmk_core/protocol/midi/midi.h6
-rw-r--r--tmk_core/protocol/midi/midi_device.c11
-rw-r--r--tmk_core/protocol/midi/qmk_midi.c2
-rw-r--r--tmk_core/protocol/midi/sysex_tools.c2
7 files changed, 119 insertions, 44 deletions
diff --git a/tmk_core/protocol/midi/bytequeue/bytequeue.c b/tmk_core/protocol/midi/bytequeue/bytequeue.c
index e36a9e66b1..0dd18680f0 100644
--- a/tmk_core/protocol/midi/bytequeue/bytequeue.c
+++ b/tmk_core/protocol/midi/bytequeue/bytequeue.c
@@ -52,7 +52,9 @@ byteQueueIndex_t bytequeue_length(byteQueue_t* queue) {
}
// we don't need to avoid interrupts if there is only one reader
-uint8_t bytequeue_get(byteQueue_t* queue, byteQueueIndex_t index) { return queue->data[(queue->start + index) % queue->length]; }
+uint8_t bytequeue_get(byteQueue_t* queue, byteQueueIndex_t index) {
+ return queue->data[(queue->start + index) % queue->length];
+}
// we just update the start index to remove elements
void bytequeue_remove(byteQueue_t* queue, byteQueueIndex_t numToRemove) {
diff --git a/tmk_core/protocol/midi/bytequeue/interrupt_setting.c b/tmk_core/protocol/midi/bytequeue/interrupt_setting.c
index 407cc65f49..d9c0035946 100644
--- a/tmk_core/protocol/midi/bytequeue/interrupt_setting.c
+++ b/tmk_core/protocol/midi/bytequeue/interrupt_setting.c
@@ -30,7 +30,9 @@ interrupt_setting_t store_and_clear_interrupt(void) {
return sreg;
}
-void restore_interrupt_setting(interrupt_setting_t setting) { SREG = setting; }
+void restore_interrupt_setting(interrupt_setting_t setting) {
+ SREG = setting;
+}
#elif defined(__arm__)
# include <ch.h>
@@ -39,5 +41,7 @@ interrupt_setting_t store_and_clear_interrupt(void) {
return 0;
}
-void restore_interrupt_setting(interrupt_setting_t setting) { chSysUnlock(); }
+void restore_interrupt_setting(interrupt_setting_t setting) {
+ chSysUnlock();
+}
#endif
diff --git a/tmk_core/protocol/midi/midi.c b/tmk_core/protocol/midi/midi.c
index 643c43722d..f3792552f4 100644
--- a/tmk_core/protocol/midi/midi.c
+++ b/tmk_core/protocol/midi/midi.c
@@ -17,7 +17,7 @@
// along with avr-midi. If not, see <http://www.gnu.org/licenses/>.
#include "midi.h"
-#include <string.h> //for memcpy
+#include <string.h> //for memcpy
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
@@ -25,9 +25,13 @@
# define NULL 0
#endif
-bool midi_is_statusbyte(uint8_t theByte) { return (bool)(theByte & MIDI_STATUSMASK); }
+bool midi_is_statusbyte(uint8_t theByte) {
+ return (bool)(theByte & MIDI_STATUSMASK);
+}
-bool midi_is_realtime(uint8_t theByte) { return (theByte >= MIDI_CLOCK); }
+bool midi_is_realtime(uint8_t theByte) {
+ return (theByte >= MIDI_CLOCK);
+}
midi_packet_length_t midi_packet_length(uint8_t status) {
switch (status & 0xF0) {
@@ -83,7 +87,9 @@ void midi_send_noteoff(MidiDevice* device, uint8_t chan, uint8_t num, uint8_t ve
device->send_func(device, 3, MIDI_NOTEOFF | (chan & MIDI_CHANMASK), num & 0x7F, vel & 0x7F);
}
-void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, uint8_t amt) { device->send_func(device, 3, MIDI_AFTERTOUCH | (chan & MIDI_CHANMASK), note_num & 0x7F, amt & 0x7F); }
+void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, uint8_t amt) {
+ device->send_func(device, 3, MIDI_AFTERTOUCH | (chan & MIDI_CHANMASK), note_num & 0x7F, amt & 0x7F);
+}
// XXX does this work right?
// amt in range -0x2000, 0x1fff
@@ -102,34 +108,62 @@ void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt) {
device->send_func(device, 3, MIDI_PITCHBEND | (chan & MIDI_CHANMASK), uAmt & 0x7F, (uAmt >> 7) & 0x7F);
}
-void midi_send_programchange(MidiDevice* device, uint8_t chan, uint8_t num) { device->send_func(device, 2, MIDI_PROGCHANGE | (chan & MIDI_CHANMASK), num & 0x7F, 0); }
+void midi_send_programchange(MidiDevice* device, uint8_t chan, uint8_t num) {
+ device->send_func(device, 2, MIDI_PROGCHANGE | (chan & MIDI_CHANMASK), num & 0x7F, 0);
+}
-void midi_send_channelpressure(MidiDevice* device, uint8_t chan, uint8_t amt) { device->send_func(device, 2, MIDI_CHANPRESSURE | (chan & MIDI_CHANMASK), amt & 0x7F, 0); }
+void midi_send_channelpressure(MidiDevice* device, uint8_t chan, uint8_t amt) {
+ device->send_func(device, 2, MIDI_CHANPRESSURE | (chan & MIDI_CHANMASK), amt & 0x7F, 0);
+}
-void midi_send_clock(MidiDevice* device) { device->send_func(device, 1, MIDI_CLOCK, 0, 0); }
+void midi_send_clock(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_CLOCK, 0, 0);
+}
-void midi_send_tick(MidiDevice* device) { device->send_func(device, 1, MIDI_TICK, 0, 0); }
+void midi_send_tick(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_TICK, 0, 0);
+}
-void midi_send_start(MidiDevice* device) { device->send_func(device, 1, MIDI_START, 0, 0); }
+void midi_send_start(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_START, 0, 0);
+}
-void midi_send_continue(MidiDevice* device) { device->send_func(device, 1, MIDI_CONTINUE, 0, 0); }
+void midi_send_continue(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_CONTINUE, 0, 0);
+}
-void midi_send_stop(MidiDevice* device) { device->send_func(device, 1, MIDI_STOP, 0, 0); }
+void midi_send_stop(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_STOP, 0, 0);
+}
-void midi_send_activesense(MidiDevice* device) { device->send_func(device, 1, MIDI_ACTIVESENSE, 0, 0); }
+void midi_send_activesense(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_ACTIVESENSE, 0, 0);
+}
-void midi_send_reset(MidiDevice* device) { device->send_func(device, 1, MIDI_RESET, 0, 0); }
+void midi_send_reset(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_RESET, 0, 0);
+}
-void midi_send_tcquarterframe(MidiDevice* device, uint8_t time) { device->send_func(device, 2, MIDI_TC_QUARTERFRAME, time & 0x7F, 0); }
+void midi_send_tcquarterframe(MidiDevice* device, uint8_t time) {
+ device->send_func(device, 2, MIDI_TC_QUARTERFRAME, time & 0x7F, 0);
+}
// XXX is this right?
-void midi_send_songposition(MidiDevice* device, uint16_t pos) { device->send_func(device, 3, MIDI_SONGPOSITION, pos & 0x7F, (pos >> 7) & 0x7F); }
+void midi_send_songposition(MidiDevice* device, uint16_t pos) {
+ device->send_func(device, 3, MIDI_SONGPOSITION, pos & 0x7F, (pos >> 7) & 0x7F);
+}
-void midi_send_songselect(MidiDevice* device, uint8_t song) { device->send_func(device, 2, MIDI_SONGSELECT, song & 0x7F, 0); }
+void midi_send_songselect(MidiDevice* device, uint8_t song) {
+ device->send_func(device, 2, MIDI_SONGSELECT, song & 0x7F, 0);
+}
-void midi_send_tunerequest(MidiDevice* device) { device->send_func(device, 1, MIDI_TUNEREQUEST, 0, 0); }
+void midi_send_tunerequest(MidiDevice* device) {
+ device->send_func(device, 1, MIDI_TUNEREQUEST, 0, 0);
+}
-void midi_send_byte(MidiDevice* device, uint8_t b) { device->send_func(device, 1, b, 0, 0); }
+void midi_send_byte(MidiDevice* device, uint8_t b) {
+ device->send_func(device, 1, b, 0, 0);
+}
void midi_send_data(MidiDevice* device, uint16_t count, uint8_t byte0, uint8_t byte1, uint8_t byte2) {
// ensure that the count passed along is always 3 or lower
@@ -150,32 +184,62 @@ void midi_send_array(MidiDevice* device, uint16_t count, uint8_t* array) {
}
}
-void midi_register_cc_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_cc_callback = func; }
+void midi_register_cc_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_cc_callback = func;
+}
-void midi_register_noteon_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_noteon_callback = func; }
+void midi_register_noteon_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_noteon_callback = func;
+}
-void midi_register_noteoff_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_noteoff_callback = func; }
+void midi_register_noteoff_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_noteoff_callback = func;
+}
-void midi_register_aftertouch_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_aftertouch_callback = func; }
+void midi_register_aftertouch_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_aftertouch_callback = func;
+}
-void midi_register_pitchbend_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_pitchbend_callback = func; }
+void midi_register_pitchbend_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_pitchbend_callback = func;
+}
-void midi_register_songposition_callback(MidiDevice* device, midi_three_byte_func_t func) { device->input_songposition_callback = func; }
+void midi_register_songposition_callback(MidiDevice* device, midi_three_byte_func_t func) {
+ device->input_songposition_callback = func;
+}
-void midi_register_progchange_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_progchange_callback = func; }
+void midi_register_progchange_callback(MidiDevice* device, midi_two_byte_func_t func) {
+ device->input_progchange_callback = func;
+}
-void midi_register_chanpressure_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_chanpressure_callback = func; }
+void midi_register_chanpressure_callback(MidiDevice* device, midi_two_byte_func_t func) {
+ device->input_chanpressure_callback = func;
+}
-void midi_register_songselect_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_songselect_callback = func; }
+void midi_register_songselect_callback(MidiDevice* device, midi_two_byte_func_t func) {
+ device->input_songselect_callback = func;
+}
-void midi_register_tc_quarterframe_callback(MidiDevice* device, midi_two_byte_func_t func) { device->input_tc_quarterframe_callback = func; }
+void midi_register_tc_quarterframe_callback(MidiDevice* device, midi_two_byte_func_t func) {
+ device->input_tc_quarterframe_callback = func;
+}
-void midi_register_realtime_callback(MidiDevice* device, midi_one_byte_func_t func) { device->input_realtime_callback = func; }
+void midi_register_realtime_callback(MidiDevice* device, midi_one_byte_func_t func) {
+ device->input_realtime_callback = func;
+}
-void midi_register_tunerequest_callback(MidiDevice* device, midi_one_byte_func_t func) { device->input_tunerequest_callback = func; }
+void midi_register_tunerequest_callback(MidiDevice* device, midi_one_byte_func_t func) {
+ device->input_tunerequest_callback = func;
+}
-void midi_register_sysex_callback(MidiDevice* device, midi_sysex_func_t func) { device->input_sysex_callback = func; }
+void midi_register_sysex_callback(MidiDevice* device, midi_sysex_func_t func) {
+ device->input_sysex_callback = func;
+}
-void midi_register_fallthrough_callback(MidiDevice* device, midi_var_byte_func_t func) { device->input_fallthrough_callback = func; }
+void midi_register_fallthrough_callback(MidiDevice* device, midi_var_byte_func_t func) {
+ device->input_fallthrough_callback = func;
+}
-void midi_register_catchall_callback(MidiDevice* device, midi_var_byte_func_t func) { device->input_catchall_callback = func; }
+void midi_register_catchall_callback(MidiDevice* device, midi_var_byte_func_t func) {
+ device->input_catchall_callback = func;
+}
diff --git a/tmk_core/protocol/midi/midi.h b/tmk_core/protocol/midi/midi.h
index 75f3b13b0b..34547077e4 100644
--- a/tmk_core/protocol/midi/midi.h
+++ b/tmk_core/protocol/midi/midi.h
@@ -48,7 +48,7 @@ extern "C" {
*
* @param device the device to initialize
*/
-void midi_device_init(MidiDevice* device); // [implementation in midi_device.c]
+void midi_device_init(MidiDevice* device); // [implementation in midi_device.c]
/**
* @brief Process input data
@@ -58,7 +58,7 @@ void midi_device_init(MidiDevice* device); // [implementation in midi_device.c]
*
* @param device the device to process
*/
-void midi_device_process(MidiDevice* device); // [implementation in midi_device.c]
+void midi_device_process(MidiDevice* device); // [implementation in midi_device.c]
/**@}*/
@@ -115,7 +115,7 @@ void midi_send_aftertouch(MidiDevice* device, uint8_t chan, uint8_t note_num, ui
* @param chan the channel to send on, 0-15
* @param amt the bend amount range: -8192..8191, 0 means no bend
*/
-void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt); // range -8192, 8191
+void midi_send_pitchbend(MidiDevice* device, uint8_t chan, int16_t amt); // range -8192, 8191
/**
* @brief Send a program change message via the given device.
diff --git a/tmk_core/protocol/midi/midi_device.c b/tmk_core/protocol/midi/midi_device.c
index 58fe685e2d..77c010b156 100644
--- a/tmk_core/protocol/midi/midi_device.c
+++ b/tmk_core/protocol/midi/midi_device.c
@@ -60,12 +60,17 @@ void midi_device_init(MidiDevice* device) {
void midi_device_input(MidiDevice* device, uint8_t cnt, uint8_t* input) {
uint8_t i;
- for (i = 0; i < cnt; i++) bytequeue_enqueue(&device->input_queue, input[i]);
+ for (i = 0; i < cnt; i++)
+ bytequeue_enqueue(&device->input_queue, input[i]);
}
-void midi_device_set_send_func(MidiDevice* device, midi_var_byte_func_t send_func) { device->send_func = send_func; }
+void midi_device_set_send_func(MidiDevice* device, midi_var_byte_func_t send_func) {
+ device->send_func = send_func;
+}
-void midi_device_set_pre_input_process_func(MidiDevice* device, midi_no_byte_func_t pre_process_func) { device->pre_input_process_callback = pre_process_func; }
+void midi_device_set_pre_input_process_func(MidiDevice* device, midi_no_byte_func_t pre_process_func) {
+ device->pre_input_process_callback = pre_process_func;
+}
void midi_device_process(MidiDevice* device) {
// call the pre_input_process_callback if there is one
diff --git a/tmk_core/protocol/midi/qmk_midi.c b/tmk_core/protocol/midi/qmk_midi.c
index 3a454d61ae..f6a5d92281 100644
--- a/tmk_core/protocol/midi/qmk_midi.c
+++ b/tmk_core/protocol/midi/qmk_midi.c
@@ -50,7 +50,7 @@ static void usb_send_func(MidiDevice* device, uint16_t cnt, uint8_t byte0, uint8
event.Event = MIDI_EVENT(cable, SYSEX_START_OR_CONT);
break;
default:
- return; // invalid cnt
+ return; // invalid cnt
}
} else {
// deal with 'system common' messages
diff --git a/tmk_core/protocol/midi/sysex_tools.c b/tmk_core/protocol/midi/sysex_tools.c
index 84bca72158..c9a9d03285 100644
--- a/tmk_core/protocol/midi/sysex_tools.c
+++ b/tmk_core/protocol/midi/sysex_tools.c
@@ -35,7 +35,7 @@ uint16_t sysex_decoded_length(uint16_t encoded_length) {
}
uint16_t sysex_encode(uint8_t *encoded, const uint8_t *source, const uint16_t length) {
- uint16_t encoded_full = length / 7; // number of full 8 byte sections from 7 bytes of input
+ uint16_t encoded_full = length / 7; // number of full 8 byte sections from 7 bytes of input
uint16_t i, j;
// fill out the fully encoded sections