1 #include <p24FJ64GA004.h>
5 static unsigned char ubx_w, ubx_r;
6 static unsigned char ubx_buf[256];
8 void __attribute__((interrupt, no_auto_psv)) _U1RXInterrupt(void)
11 uart1_rx_intf_clear();
12 while(uart1_rx_is_rdy()) {
13 ubx_buf[ubx_w++] = uart1_getc();
15 if (U1STAbits.OERR == 1) U1STAbits.OERR = 0;
17 void uart1_puts(char *s)
20 while(uart1_tx_is_full());
24 void uart2_puts(char *s)
27 while(uart2_tx_is_full());
34 int uart1_rcvbuf_is_data(void)
36 if (ubx_r == ubx_w) return 0;
42 int uart1_rcvbuf_getc(void)
44 if (ubx_r == ubx_w) return -1;
45 return ubx_buf[ubx_r++];
48 void uart1_rcvbuf_clear(void)
53 void uart1_init(unsigned int mode, unsigned int sts, unsigned int baud)
61 void uart2_init(unsigned int mode, unsigned int sts, unsigned int baud)