]> git.zerfleddert.de Git - fnordlicht-mini/blame - firmware/fnordlicht-firmware/uart.h
more tx disabling.
[fnordlicht-mini] / firmware / fnordlicht-firmware / uart.h
CommitLineData
ec1bef8e 1/* vim:ts=4 sts=4 et tw=80
2 *
3 * fnordlicht firmware
4 *
5 * for additional information please
6 * see http://lochraster.org/fnordlichtmini
7 *
8 * (c) by Alexander Neumann <alexander@bumpern.de>
9 * Lars Noschinski <lars@public.noschinski.de>
10 *
11 * This program is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 3 as published by
13 * the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#ifndef UART_H
25#define UART_H
26
27#include "globals.h"
28#include "fifo.h"
29#include "../common/io.h"
30
31#if !CONFIG_SERIAL
32
33#define uart_init(...)
34#define uart_putc(...)
35
36#else
37
38/* structs */
39struct global_uart_t {
40 fifo_t rx;
a73d0f32 41#if UART_TX_ENABLED
ec1bef8e 42 fifo_t tx;
a73d0f32 43#endif
ec1bef8e 44};
45
46/* global variables */
47extern volatile struct global_uart_t global_uart;
48
49/* prototypes */
50void uart_init(void);
51void uart_putc(uint8_t data);
52
a73d0f32 53#if UART_TX_ENABLED
ec1bef8e 54static inline bool uart_send_complete(void)
55{
56 return _BV(_UDRE_UART0) & _UCSRA_UART0;
57}
a73d0f32 58#else
59/* we're never incomplete, never. */
60#define uart_send_complete() 1
61#endif
ec1bef8e 62
63#endif
64
65#endif
Impressum, Datenschutz