16#include <l4/drivers/io_regblock.h>
18#include "poll_timeout_counter.h"
30 Io_register_block
const *_regs;
33 void *
operator new (size_t,
void* a)
37 typedef unsigned Transfer_mode;
38 typedef unsigned Baud_rate;
41 : _mode(~0U), _rate(~0U)
51 virtual bool startup(Io_register_block
const *regs) = 0;
81 virtual int get_char(
bool blocking =
true)
const = 0;
101 virtual int write(
char const *s,
unsigned long count,
102 bool blocking =
true)
const = 0;
123 Transfer_mode
mode()
const {
return _mode; }
130 Baud_rate
rate()
const {
return _rate; }
144 template <
typename Uart_driver>
146 bool blocking =
true)
const
148 auto *self =
static_cast<Uart_driver const*
>(
this);
151 for (c = 0; c < count; ++c)
153 if (!blocking && !self->tx_avail())
157 while (i.
test(!self->tx_avail()))
160 self->out_char(*s++);
164 self->wait_tx_done();
Evaluate an expression for a maximum number of times.
bool test(bool expression=true)
Evaluate the expression for a maximum number of times.
virtual void irq_ack()
Acknowledge a received interrupt.
virtual int write(char const *s, unsigned long count, bool blocking=true) const =0
Transmit a number of characters.
virtual void shutdown()=0
Terminate the UART driver.
Baud_rate rate() const
Return the baud rate.
virtual int char_avail() const =0
Check if there is at least one character available for reading from the UART.
int generic_write(char const *s, unsigned long count, bool blocking=true) const
Internal function transmitting each character one-after-another and finally waiting that the transmis...
virtual bool change_mode(Transfer_mode m, Baud_rate r)=0
Set certain parameters of the UART.
virtual bool startup(Io_register_block const *regs)=0
Start the UART driver.
virtual bool enable_rx_irq(bool=true)
Enable the receive IRQ.
virtual int get_char(bool blocking=true) const =0
Read a character from the UART.
Transfer_mode mode() const
Return the transfer mode.
L4 low-level kernel interface.