]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/drivers-frst/uart/include/uart_base.h
update
[l4.git] / l4 / pkg / drivers-frst / uart / include / uart_base.h
1 /*
2  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #ifndef L4_CXX_UART_H__
10 #define L4_CXX_UART_H__
11
12 #include <stddef.h>
13
14 namespace L4
15 {
16   class Uart
17   {
18   protected:
19     int _rx_irq;
20     int _tx_irq;
21     unsigned _mode;
22     unsigned _rate;
23
24   public:
25     void *operator new (size_t, void* a)
26     { return a; }
27
28   public:
29     typedef unsigned Transfer_mode;
30     typedef unsigned Baud_rate;
31
32     Uart(int rx_irq, int tx_irq)
33     : _rx_irq(rx_irq), _tx_irq(tx_irq), _mode(~0U), _rate(~0U)
34     {}
35
36     virtual bool startup(unsigned long base) = 0;
37
38     virtual ~Uart() {}
39     virtual void shutdown() = 0;
40     virtual bool enable_rx_irq(bool enable = true) = 0;
41     virtual bool enable_tx_irq(bool enable = true) = 0;
42     virtual bool change_mode(Transfer_mode m, Baud_rate r) = 0;
43     virtual int get_char(bool blocking = true) const = 0;
44     virtual int char_avail() const = 0;
45     virtual int write(char const *s, unsigned long count) const = 0;
46
47     int rx_irq() const { return _rx_irq; }
48     int tx_irq() const { return _tx_irq; }
49     Transfer_mode mode() const { return _mode; }
50     Baud_rate rate() const { return _rate; }
51   };
52 };
53
54 #endif
55