Loading...
Searching...
No Matches
L4::Uart Class Referenceabstract

Uart driver abstraction. More...

`#include <uart_base.h>`

Inheritance diagram for L4::Uart:
Collaboration diagram for L4::Uart:

## Public Member Functions

virtual bool | startup (Io_register_block const *regs)=0
| Start the UART driver.
virtual void | shutdown ()=0
| Terminate the UART driver.
virtual bool | change_mode (Transfer_mode m, Baud_rate r)=0
| Set certain parameters of the UART.
virtual int | write (char const *s, unsigned long count, bool blocking=true) const =0
| Transmit a number of characters.
Transfer_mode | mode () const
| Return the transfer mode.
Baud_rate | rate () const
| Return the baud rate.
virtual bool | enable_rx_irq (bool=true)
| Enable the receive IRQ.
virtual void | irq_ack ()
| Acknowledge a received interrupt.
virtual int | char_avail () const =0
| Check if there is at least one character available for reading from the UART.
virtual int | get_char (bool blocking=true) const =0
| Read a character from the UART.

## Protected Member Functions

template<typename Uart_driver, bool Timeout_guard = true>
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 transmission did actually finish.

## Detailed Description

Uart driver abstraction.

Definition at line 20 of file uart_base.h.

## Member Function Documentation

## change_mode()

virtual bool L4::Uart::change_mode | ( | Transfer_mode | m,
|  | Baud_rate | r )

pure virtual

Set certain parameters of the UART.

Parameters

  m | UART mode. Depends on the hardware.
  r | Baud rate.

Return values

  true | Mode setting succeeded (or was not performed at all).
  false | Mode setting failed for some reason.

Note
  Some drivers don't perform any mode setting at all and just return true.

Implemented in L4::Uart_apb.

## char_avail()

virtual int L4::Uart::char_avail | ( |  | ) | const

pure virtual

Check if there is at least one character available for reading from the UART.

Returns
  0 if there is no character available for reading, !=0 otherwise.

Implemented in L4::Uart_apb.

## enable_rx_irq()

virtual bool L4::Uart::enable_rx_irq | ( | bool | = true | ) |

inlinevirtual

Enable the receive IRQ.

Return values

  true | The RX IRQ was successfully enabled / disabled.
  false | The RX IRQ couldn't be enabled / disabled. The driver does not support this operation.

Reimplemented in L4::Uart_apb.

Definition at line 103 of file uart_base.h.

## generic_write()

template<typename Uart_driver, bool Timeout_guard = true>

int L4::Uart::generic_write | ( | char const * | s,
|  | unsigned long | count,
|  | bool | blocking = true ) const

inlineprotected

Internal function transmitting each character one-after-another and finally waiting that the transmission did actually finish.

Parameters

  s | Buffer containing the characters.
  count | The number of characters to transmit.
  blocking | If true, wait until there is space in the transmit buffer and also wait until every character was successful transmitted. Otherwise do not wait.

Returns
  The number of successful written characters.

Definition at line 141 of file uart_base.h.

References L4::Poll_timeout_counter::test().

Here is the call graph for this function:

## get_char()

virtual int L4::Uart::get_char | ( | bool | blocking = true | ) | const

pure virtual

Read a character from the UART.

Parameters

  blocking | If true, wait until a character is available for reading. Otherwise do not wait and just return -1 if no character is available.

Returns
  The actual character read from the UART.

Implemented in L4::Uart_apb.

## mode()

Transfer_mode L4::Uart::mode | ( |  | ) | const

inline

Return the transfer mode.

Returns
  The transfer mode.

Definition at line 86 of file uart_base.h.

## rate()

Baud_rate L4::Uart::rate | ( |  | ) | const

inline

Return the baud rate.

Returns
  The baud rate.

Definition at line 93 of file uart_base.h.

## shutdown()

virtual void L4::Uart::shutdown | ( |  | ) |

pure virtual

Terminate the UART driver.

This includes disabling of interrupts.

Implemented in L4::Uart_apb.

## startup()

virtual bool L4::Uart::startup | ( | Io_register_block const * | regs | ) |

pure virtual

Start the UART driver.

Parameters

  regs | IO register block of the UART.

Return values

  true | Startup succeeded.
  false | Startup failed.

Implemented in L4::Uart_apb.

## write()

virtual int L4::Uart::write | ( | char const * | s,
|  | unsigned long | count,
|  | bool | blocking = true ) const

pure virtual

Transmit a number of characters.

Parameters

  s | Buffer containing the characters.
  count | Number of characters to transmit.
  blocking | If true, wait until there is space in the transmit buffer and also wait until every character was successful transmitted. Otherwise do not wait.

Returns
  The number of successfully written characters.

Implemented in L4::Uart_apb.

The documentation for this class was generated from the following file:

- pkg/drivers-frst/uart/include/uart_base.h