6 * Platform independent UART stub.
13 * Type UART transfer mode (Bits, Stopbits etc.).
15 typedef unsigned TransferMode;
20 typedef unsigned BaudRate;
22 /* These constants must be defined in the
23 arch part of the uart. To define them there
24 has the advantage of most efficent definition
27 static unsigned const PAR_NONE = xxx;
28 static unsigned const PAR_EVEN = xxx;
29 static unsigned const PAR_ODD = xxx;
30 static unsigned const DAT_5 = xxx;
31 static unsigned const DAT_6 = xxx;
32 static unsigned const DAT_7 = xxx;
33 static unsigned const DAT_8 = xxx;
34 static unsigned const STOP_1 = xxx;
35 static unsigned const STOP_2 = xxx;
37 static unsigned const MODE_8N1 = PAR_NONE | DAT_8 | STOP_1;
38 static unsigned const MODE_7E1 = PAR_EVEN | DAT_7 | STOP_1;
40 // these two values are to leave either mode
41 // or baud rate unchanged on a call to change_mode
42 static unsigned const MODE_NC = xxx;
43 static unsigned const BAUD_NC = xxx;
49 /* Interface definition - implemented in the arch part */
57 * (abstract) Shutdown the serial port.
62 * (abstract) Get the IRQ assigned to the port.
67 * (abstract) Enable rcv IRQ in UART.
69 void enable_rcv_irq();
72 * (abstract) Disable rcv IRQ in UART.
74 void disable_rcv_irq();
77 * (abstract) Change transfer mode or speed.
78 * @param m the new mode for the transfer, or MODE_NC for no mode change.
79 * @param r the new baud rate, or BAUD_NC, for no speed change.
81 bool change_mode(TransferMode m, BaudRate r);
84 * (abstract) Get the current transfer mode.
86 TransferMode get_mode();
89 * (abstract) Write str.
91 int write( char const *str, size_t len );
94 * (abstract) Read a character.
96 int getchar( bool blocking = true );
99 * (abstract) Is there anything to read?
101 int char_avail() const;
103 Mword get_attributes() const;
110 Uart::get_attributes() const
112 return UART | IN | OUT;
115 //---------------------------------------------------------------------------
118 #include "uart_base.h"
128 static L4::Uart *uart();
132 //---------------------------------------------------------------------------
133 IMPLEMENTATION [libuart]:
135 IMPLEMENT Uart::Uart()
139 IMPLEMENT Uart::~Uart()
144 PUBLIC bool Uart::startup( Address _address, unsigned /*irq*/ )
146 return uart()->startup(_address);
149 IMPLEMENT inline void Uart::shutdown()
155 IMPLEMENT inline bool Uart::change_mode(TransferMode m, BaudRate baud)
157 return uart()->change_mode(m, baud);
161 int Uart::write( const char *s, __SIZE_TYPE__ count )
163 return uart()->write(s, count);
167 int Uart::getchar( bool blocking )
169 return uart()->get_char(blocking);
174 int Uart::char_avail() const
176 return uart()->char_avail();
181 int Uart::irq() const
183 return uart()->rx_irq();
187 void Uart::enable_rcv_irq()
189 uart()->enable_rx_irq(true);
193 void Uart::disable_rcv_irq()
195 uart()->enable_rx_irq(false);