diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2017-06-16 00:22:47 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2017-06-16 00:22:47 +0200 |
commit | f9357256249657af2374e3c334b9180e63dc5a30 (patch) | |
tree | 32b4b0990d77467a17eb77a52186060460b82fdd /floppyMusic/midi.c | |
parent | a5ae30562fc5adbabaf46763b8826ac4d843c26e (diff) | |
download | avrFloppy-f9357256249657af2374e3c334b9180e63dc5a30.tar.gz |
Split in different files
Diffstat (limited to 'floppyMusic/midi.c')
-rw-r--r-- | floppyMusic/midi.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/floppyMusic/midi.c b/floppyMusic/midi.c new file mode 100644 index 0000000..ff70a95 --- /dev/null +++ b/floppyMusic/midi.c @@ -0,0 +1,42 @@ +/* + * midi.c + * + * Created: 12.06.2017 20:43:47 + * Author: Jonas + */ + +#include "midi.h" + +void midi_setup() +{ + uart_init(9600); +} + +void midi_recieve(struct midi_command *_command) +{ + if(!(UCSRB & (1<<RXEN))) //Return if UART reciever not enabled + return; + + char status, data1, data2; + char command, channel, note, velocity; + + status = uart_recieve(); + data1 = uart_recieve(); + data2 = uart_recieve(); + + command = status & 0x0f; //Mask out last 4 bits + channel = (status >> 4) & 0x0f; // Shift channel into first 4 bits; + note = data1; + velocity = data2; + + _command->command = command; + _command->channel=channel; + _command->note = note; + _command->velocity = velocity; + +} + +void midi_send(struct midi_command _command) +{ + +}
\ No newline at end of file |