2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: uart_send9_nowait.c,v 1.1.2.2 2008-12-27 16:50:01 zer0 Exp $
22 /* Olivier MATZ, Droids-corp 2004 - 2009 */
25 #include <uart_defs.h>
26 #include <uart_private.h>
28 int uart_send_9bits_nowait(uint8_t num, int c)
33 /* if tx intrp are disabled (RXCIE is 0) */
34 if ( !(*uart_regs[num].ucsrb & (1 << RXCIE )) ) {
35 /* we have to poll the status register before xmit */
36 if (*uart_regs[num].ucsra & (1<<UDRE)) {
37 uart_set_udr_9bits(c);
47 /* the fifo must have 2 free places */
48 if( CIRBUF_GET_FREELEN(&g_tx_fifo) < 2) {
53 /* uart is ready to send */
54 if (CIRBUF_IS_EMPTY(&g_tx_fifo[num]) &&
55 *uart_regs[num].ucsra & (1<<UDRE)) {
56 uart_set_udr_9bits(c);
57 sbi(*uart_regs[num].ucsrb, UDRIE); /* XXX */
59 else { /* not ready, put char in fifo */
60 cirbuf_add_buf_head(&g_tx_fifo, (char *)&c, 2);