diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -1,6 +1,6 @@ /* * File: main.c - * Author: _prossn + * Author: Naoki Pross 4E * Date: 08.01.2018 * Target: PIC18F44K22 * Version 1.0 @@ -71,21 +71,47 @@ // Use project enums instead of #define for ON and OFF. #include "rs232.h" +#include "midi.h" #include <xc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +int eusart_write_midi(midi_message_t *pkt) +{ + if (pkt == NULL) { + return -1; + } + + if (pkt->data == NULL) { + return -2; + } + + size_t length = pkt->data_size; + uint8_t *data = pkt->data; + + putch((char)((pkt->status << 4) | pkt->channel)); + + while (length--) { + putch((char) *(data++)); + } + + return 0; +} + /* main program */ void main(void) { + midi_message_t sample_message; + midi_note_on(&sample_message, 0x0, 0x3C, 0x7F); + eusart_init(); /* main loop */ while (1) { - + eusart_write_midi(&sample_message); } } |