YAHAL
Yet Another Hardware Abstraction Library
Loading...
Searching...
No Matches
uart_ctrl_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) control.
17
18#ifndef _UART_CTRL_INTERFACE_H_
19#define _UART_CTRL_INTERFACE_H_
20
21#include <cstdint>
22
23typedef uint16_t uart_mode_t;
24
25namespace UART {
26 const uart_mode_t BITS_7 = 0x0001;
27 const uart_mode_t BITS_8 = 0x0002;
28 const uart_mode_t NO_PARITY = 0x0004;
29 const uart_mode_t EVEN_PARITY = 0x0008;
30 const uart_mode_t ODD_PARITY = 0x0010;
31 const uart_mode_t STOPBITS_1 = 0x0020;
32 const uart_mode_t STOPBITS_2 = 0x0040;
33}
35public:
36 // set the uart mode
37 virtual void uartMode(uart_mode_t mode) = 0;
38
39 // set the baudrate in Hz
40 virtual void setBaudrate(uint32_t) = 0;
41
42 // send a break condition for ms milliseconds.
43 // A value of 0xffff means indefinitely 'on',
44 // a value of 0 means immediate 'off'
45 virtual void sendBreak(uint16_t ms) = 0;
46
47 // set hw control lines
48 virtual void setDTR(bool dtr) = 0;
49 virtual void setRTS(bool rts) = 0;
50
51 // FIFO control
52 virtual void enableFIFO(bool) = 0;
53
54protected:
55 virtual ~uart_ctrl_interface() = default;
56};
57
58#endif /* _UART_CTRL_INTERFACE_H_ */