From c3818d4309e99e36b5cd2158966f0ed27a429e06 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 23 Feb 2018 11:51:01 +0100 Subject: Fix rs232 interface for MIDI serial --- src/rs232.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/rs232.c') diff --git a/src/rs232.c b/src/rs232.c index e87e49b..e060759 100644 --- a/src/rs232.c +++ b/src/rs232.c @@ -1,35 +1,41 @@ #include "rs232.h" #include -void eusart_init(void) +void eusart1_init(void) { // set Async and 8 bits frame - TXSTAbits.SYNC = 0; - TXSTAbits.TX9 = 0; + TXSTA1bits.SYNC = 0; + TXSTA1bits.TX9 = 0; - // 9600 baud prescaler - RCSTAbits.SPEN = 1; - SPBRG = 129; - TXSTAbits.BRGH = 1; - BAUDCONbits.BRG16 = 0; + // baud prescaler + RCSTA1bits.SPEN = 1; + SPBRG1 = 31; + SPBRGH1 = 0; + TXSTA1bits.BRGH = 0; + BAUDCON1bits.BRG16 = 0; // set up TX / RX pins - TRISC7 = 1; - TRISC6 = 1; - RCSTAbits.CREN = 1; // enable continuous reception - TXSTAbits.TXEN = 1; + TRISCbits.TRISC7 = 1; + TRISCbits.TRISC6 = 1; + RCSTA1bits.CREN = 1; // enable continuous reception + TXSTA1bits.TXEN = 1; +} + +void eusart2_init(void) +{ + // TODO } void putch(char c) { - while (!TXIF); - TXREG = c; + while (!TX1IF); + TX1REG = c; } char getch(void) { - while (!RCIF); - return RCREG; + while (!RC1IF); + return RC1REG; } char getche(void) -- cgit v1.2.1