Line | |
---|
1 | #include <pic18fregs.h> |
---|
2 | #include <stdio.h> |
---|
3 | #include <my_serial2.h> |
---|
4 | |
---|
5 | char uart2_txbuf[UART2_BUFSIZE]; |
---|
6 | unsigned char uart2_txbuf_prod; |
---|
7 | volatile unsigned char uart2_txbuf_cons; |
---|
8 | |
---|
9 | char uart2_rxbuf[UART2_BUFSIZE]; |
---|
10 | volatile unsigned char uart2_rxbuf_prod; |
---|
11 | unsigned char uart2_rxbuf_cons; |
---|
12 | |
---|
13 | void |
---|
14 | uart2_putchar_raw(char c) |
---|
15 | { |
---|
16 | unsigned char new_uart2_txbuf_prod; |
---|
17 | new_uart2_txbuf_prod = (uart2_txbuf_prod + 1) & UART2_BUFSIZE_MASK; |
---|
18 | while (new_uart2_txbuf_prod == uart2_txbuf_cons) { |
---|
19 | PIE3bits.TX2IE = 1; /* ensure we'll make progress */ |
---|
20 | } |
---|
21 | uart2_txbuf[uart2_txbuf_prod] = c; |
---|
22 | uart2_txbuf_prod = new_uart2_txbuf_prod; |
---|
23 | PIE3bits.TX2IE = 1; |
---|
24 | } |
---|
25 | |
---|
26 | char |
---|
27 | uart2_getchar() |
---|
28 | { |
---|
29 | register char c; |
---|
30 | while (uart2_rxbuf_cons == uart2_rxbuf_prod) |
---|
31 | ; |
---|
32 | |
---|
33 | uart2_rxbuf_cons = (uart2_rxbuf_cons + 1) & UART2_BUFSIZE_MASK; |
---|
34 | c = uart2_rxbuf[uart2_rxbuf_cons]; |
---|
35 | return c; |
---|
36 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.