From 18abece8f8a8af17a3b5e80dc1baf61457409600 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 2 Feb 2018 12:12:18 +0100 Subject: 2 February 2018 Documentation: - new API documentation - datasheets for new components - update BOM - update documentation data Hardware: - update schematic for MIDI connector Software: - new MIDI API - update prject target to PIC18F45K22 --- src/main.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index da15d3a..4fb245a 100644 --- a/src/main.c +++ b/src/main.c @@ -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 #include #include #include +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); } } -- cgit v1.2.1