MHAA Serial Core
v1.0.0
Nonblocking framed serial communication
Toggle main menu visibility
Loading...
Searching...
No Matches
serial.hpp
Go to the documentation of this file.
1
#ifndef MHAA_SERIAL_HPP
2
#define MHAA_SERIAL_HPP
3
4
#include <serial/peripheral.hpp>
5
#include <serial/types.hpp>
6
7
namespace
mhaa
8
{
9
namespace
serial
10
{
12
class
Serial
13
{
14
public
:
15
explicit
Serial
(Peripheral &peripheral) : peripheral_(peripheral) {}
16
17
Status
configure
(
const
Config &config)
18
{
19
if
(config.baud_rate == 0 || config.data_bits == 0 || config.data_bits > 16 ||
20
(config.mode == Mode::Asynchronous && config.stop_bits == StopBits::None))
21
{
22
return
Status::InvalidArgument;
23
}
24
return
peripheral_.configure(config);
25
}
26
27
Status
try_write
(Frame frame) {
return
peripheral_.try_write(frame); }
28
Status
try_read
(Frame &frame) {
return
peripheral_.try_read(frame); }
29
bool
transmission_complete
()
const
{
return
peripheral_.transmission_complete(); }
30
31
private
:
32
Peripheral &peripheral_;
33
};
34
}
35
}
36
37
#endif
mhaa::serial::Serial::transmission_complete
bool transmission_complete() const
Definition
serial.hpp:29
mhaa::serial::Serial::try_read
Status try_read(Frame &frame)
Definition
serial.hpp:28
mhaa::serial::Serial::configure
Status configure(const Config &config)
Definition
serial.hpp:17
mhaa::serial::Serial::try_write
Status try_write(Frame frame)
Definition
serial.hpp:27
mhaa::serial::Serial::Serial
Serial(Peripheral &peripheral)
Definition
serial.hpp:15
mhaa::serial
Definition
serial.hpp:10
mhaa
Definition
serial.hpp:8
include
serial
serial.hpp
Generated by
1.18.0