YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
uart_data_interface.h
1// ---------------------------------------------
2// This file is part of
3// _ _ __ _ _ __ __
4// ( \/ ) /__\ ( )_( ) /__\ ( )
5// \ / /(__)\ ) _ ( /(__)\ )(__
6// (__)(__)(__)(_) (_)(__)(__)(____)
7//
8// Yet Another HW Abstraction Library
9// Copyright (C) Andreas Terstegge
10// BSD Licensed (see file LICENSE)
11//
12// ---------------------------------------------
13//
14// This file defines a generic and abstract C++
15// interface for a UART (Universal Asynchronous
16// Receiver/Transmitter) data communication.
17
18#ifndef _UART_DATA_INTERFACE_H_
19#define _UART_DATA_INTERFACE_H_
20
21#include <functional>
22using std::function;
23
25public:
26 // Check if a character is available for reading.
27 virtual bool available() = 0;
28
29 // get a character
30 virtual char getc() = 0;
31
32 // write/send a character
33 virtual void putc(char c) = 0;
34
35 // Interrupt handling
36 virtual void uartAttachIrq (function<void(char)> f) = 0;
37 virtual void uartDetachIrq () = 0;
38 virtual void uartEnableIrq () = 0;
39 virtual void uartDisableIrq() = 0;
40
41protected:
42 virtual ~uart_data_interface() = default;
43};
44
45#endif /* _UART_DATA_INTERFACE_H_ */