Renamed settings to config
This commit is contained in:
48
config.hpp
Normal file
48
config.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
namespace uart {
|
||||
|
||||
enum class DataBits {
|
||||
FIVE,
|
||||
SIX,
|
||||
SEVEN,
|
||||
EIGHT,
|
||||
NINE,
|
||||
};
|
||||
|
||||
enum class StopBits {
|
||||
ONE,
|
||||
TWO,
|
||||
};
|
||||
|
||||
enum class Parity {
|
||||
NONE,
|
||||
ODD,
|
||||
EVEN,
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <const DataBits dataBits>
|
||||
struct choose_data_type {
|
||||
using type = uint8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct choose_data_type<DataBits::NINE> {
|
||||
using type = uint16_t;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <const uint32_t baudRate = 9600, const DataBits dataBits = DataBits::EIGHT, const Parity parity = Parity::NONE,
|
||||
const StopBits stopBits = StopBits::ONE>
|
||||
struct config {
|
||||
static constexpr auto BAUD_RATE = baudRate;
|
||||
static constexpr auto DATA_BITS = dataBits;
|
||||
static constexpr auto PARITY = parity;
|
||||
static constexpr auto STOP_BITS = stopBits;
|
||||
using data_t = typename detail::choose_data_type<DATA_BITS>::type;
|
||||
};
|
||||
|
||||
} // namespace uart
|
||||
Reference in New Issue
Block a user