2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
\r
4 * This program is free software; you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation; either version 2 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program; if not, write to the Free Software
\r
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
18 * Revision : $Id: uart_private.h,v 1.1.2.5 2009-01-03 16:24:50 zer0 Exp $
\r
22 /* Olivier MATZ, Droids-corp 2004 - 2009 */
\r
24 #ifndef _UART_PRIVATE_H_
\r
25 #define _UART_PRIVATE_H_
\r
27 #include <aversive.h>
\r
28 #include <aversive/list.h>
\r
31 #include <uart_defs.h>
\r
32 #include <uart_config.h>
\r
34 typedef volatile uint8_t *uart_reg_t;
\r
45 const struct regs uart_regs[UART_HW_NUM];
\r
47 typedef void (event)(char);
\r
48 typedef void (event_9bits)(int);
\r
50 /** The emission fifo of uart */
\r
51 extern struct cirbuf g_tx_fifo[UART_HW_NUM];
\r
53 /** The reception fifo of uart */
\r
54 extern struct cirbuf g_rx_fifo[UART_HW_NUM];
\r
56 extern event *rx_event[UART_HW_NUM];
\r
57 extern event *tx_event[UART_HW_NUM];
\r
59 void uart_send_next_char(uint8_t num);
\r
60 int8_t uart_setconf(uint8_t num, struct uart_config *u);
\r
62 static inline char uart_get_udr(uint8_t num)
\r
64 return *uart_regs[num].udr;
\r
67 static inline void uart_set_udr(uint8_t num, char c)
\r
69 *uart_regs[num].udr = c;
\r
70 /* tx event function. We suppose interrupts are already
\r
71 * locked, so no pb with tx_event pointer */
\r
76 #ifdef CONFIG_MODULE_UART_9BITS
\r
77 static inline int uart_get_udr_9bits(uint8_t num)
\r
79 int val = *uart_regs[num].udr;
\r
80 val |= (*uart_regs[num].ucsrb & ((1 << RXB8) ? 0x100 : 0));
\r
84 static inline void uart_set_udr_9bits(uint8_t num, int c)
\r
87 *uart_regs[num].ucsrb |= (1 << RXB8);
\r
89 *uart_regs[num].ucsrb &= ~(1 << RXB8);
\r
90 *uart_regs[num].udr = c;
\r
92 /* tx event function. We suppose interrupts are already
\r
93 * locked, so no pb with tx_event pointer */
\r
95 ((event_9bits *)tx_event[num])(c);
\r
97 #endif /* CONFIG_MODULE_UART_9BITS */
\r
99 #endif /* _UART_PRIVATE_H_ */
\r