2 * (c) 2009-2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
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.
9 #include "uart_omap35x.h"
10 #include "poll_timeout_counter.h"
26 LCD_REG_CHAR_LENGTH_5BIT = 0 << 0,
27 LCD_REG_CHAR_LENGTH_6BIT = 1 << 0,
28 LCD_REG_CHAR_LENGTH_7BIT = 2 << 0,
29 LCD_REG_CHAR_LENGTH_8BIT = 3 << 0,
30 LCD_REG_CHAR_NB_STOP_2 = 1 << 2,
31 LCD_REG_CHAR_PARITY_EN = 1 << 3,
32 LCD_REG_CHAR_PARITY_TYPE1_EVEN = 1 << 4,
34 LSR_REG_RX_FIFO_E_AVAIL = 1 << 0,
35 LSR_REG_TX_FIFO_E_EMPTY = 1 << 5,
37 SSR_REG_TX_FIFO_FULL = 1 << 0,
39 SYSC_REG_SOFTRESET = 1 << 1,
41 SYSC_REG_RESETDONE = 1 << 0,
45 bool Uart_omap35x::startup(Io_register_block const *regs)
50 //_regs->write<unsigned int>(SYSC_REG, _regs->read<unsigned int>(SYSC_REG) | SYSC_REG_SOFTRESET);
51 // Poll_timeout_counter i(3000000);
52 //while (i.test(!(_regs->read<unsigned int>(SYSS_REG) & SYSC_REG_RESETDONE)))
58 void Uart_omap35x::shutdown()
62 bool Uart_omap35x::enable_rx_irq(bool enable)
64 _regs->write<unsigned int>(IER_REG, enable ? 1 : 0);
67 bool Uart_omap35x::change_mode(Transfer_mode, Baud_rate r)
75 int Uart_omap35x::get_char(bool blocking) const
81 return _regs->read<unsigned int>(RHR_REG);
84 int Uart_omap35x::char_avail() const
86 return _regs->read<unsigned int>(LSR_REG) & LSR_REG_RX_FIFO_E_AVAIL;
89 void Uart_omap35x::out_char(char c) const
91 _regs->write<unsigned int>(THR_REG, c);
92 Poll_timeout_counter i(3000000);
93 while (i.test(!(_regs->read<unsigned int>(LSR_REG) & LSR_REG_TX_FIFO_E_EMPTY)))
97 int Uart_omap35x::write(char const *s, unsigned long count) const
99 unsigned long c = count;
103 Poll_timeout_counter i(3000000);
104 while (i.test(_regs->read<unsigned int>(UART01x_FR) & UART01x_FR_BUSY))