summaryrefslogtreecommitdiffstats
path: root/src/rs232.c
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-23 11:51:01 +0100
committerNao Pross <naopross@thearcway.org>2018-02-23 11:51:01 +0100
commitc3818d4309e99e36b5cd2158966f0ed27a429e06 (patch)
tree7ec83bd89dc592e0e94431bffa6738ecf43d1208 /src/rs232.c
parentAdd const to MIDI pkt pointer arguments (diff)
downloadXilofono-c3818d4309e99e36b5cd2158966f0ed27a429e06.tar.gz
Xilofono-c3818d4309e99e36b5cd2158966f0ed27a429e06.zip
Fix rs232 interface for MIDI serial
Diffstat (limited to '')
-rw-r--r--src/rs232.c38
1 files changed, 22 insertions, 16 deletions
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 <xc.h>
-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)