3#ifndef DEFAULT_UART_BAUD_RATE
4# define DEFAULT_UART_BAUD_RATE 921'600
8#include <platform/concepts/uart.hh>
42 BITPACK_DERIVED_PREFIX;
103 BITPACK_USUAL_PREFIX;
131 BITPACK_USUAL_PREFIX;
158 void parity(
bool enableParity =
true,
bool oddParity =
false)
volatile
160 using enum Control::Parity;
161 control.set(enableParity ? (oddParity ? Odd : Even) : None);
172 bool lineLoopback =
false)
volatile
174 control.alter([=](
auto v) {
176 v, =, SystemLoopback{systemLoopback});
185 fifoControl.alter([](
auto v) {
200 fifoControl.set(level);
211 fifoControl.set(level);
215 template<
typename Interrupt>
218 interruptEnable.member<Interrupt>() = Interrupt{
true};
222 template<
typename Interrupt>
225 interruptEnable.member<Interrupt>() = Interrupt{
false};
231 interruptEnable.alter([interrupt](
auto v) {
232 return decltype(v){v.raw() | interrupt.
raw()};
239 interruptEnable.alter([interrupt](
auto v) {
240 return decltype(v){v.raw() & ~interrupt.raw()};
244 void init(
unsigned baudRate = DEFAULT_UART_BAUD_RATE)
volatile
248 ((
static_cast<uint64_t
>(baudRate) << 20) / CPU_TIMER_HZ);
250 control.
alter([=](
auto v) {
261 control.alter([=](
auto v) {
274 control =
decltype(control){0};
277 [[gnu::always_inline]] uint16_t transmit_fifo_level()
volatile
282 [[gnu::always_inline]] uint16_t receive_fifo_level()
volatile
287 bool can_write()
volatile
290 status.read(), ==, TransmitFull::Cleared);
293 bool can_read()
volatile
296 status.read(), ==, ReceiveEmpty::Cleared);
322#ifndef CHERIOT_PLATFORM_CUSTOM_UART
constexpr Storage raw() const
A shorter way of spelling static_cast<Storage>(...).
constexpr void alter(this Self &&self, auto &&f)
Convenience function for unconditionally changing several sub-fields at once.
const auto read(this Self &&self)
Return a snapshot of the underlying Storage.
Utility class to delete copy and move contructors.
Concept for checking that a UART driver exposes the right interface.
#define BITPACK_MEMBER_ADD_ENUM_BOOL_CLEARED_ASSERTED(Type, BitIndex,...)
Define a new boolean scoped enumeration with values named "Cleared" (0) and "Asserted" (1) at the giv...
#define BITPACK_MEMBER_ADD_ENUM(Type, Base,...)
Encapsulate the gyrations required to define an enum class-typed field and its associated field_info_...
#define BITPACK_MEMBER_ADD_ENUM_BOOL(Type, FalseVal, TrueVal, BitIndex,...)
Define a new scoped enumeration type whose underlying type is bool, with the given false and true val...
#define BITPACK_MEMBER_ADD_NUMERIC(Type, Base,...)
Encapsulate the gyrations required to define a Numeric-typed field and its associated field_info_for_...
#define BITPACK_MEMBER_ADD_ENUM_BOOL_DISABLED_ENABLED(Type, BitIndex,...)
Define a new boolean scoped enumeration with values named "Disabled" (0) and "Enabled" (1) at the giv...
#define BITPACK_DERIVED_FIELD_CONST_FOR_TYPE(Type, c)
Modify the constness field information for a type in a derived bitpack.
#define BITPACK_MEMBER_DECLTYPE(b, T)
A convenience macro that presumes the type T is defined within the Bitpack b and finds such a field's...
#define BITPACK_OPERATE_VALUE_DEPENDENT(b, operator,value)
BITPACK_OPERATE_VALUE with dependent qualification for the type of the bitpack.
#define BITPACK_OPERATE_VALUE_DECLTYPE(b, operator,value)
Given a bitpack b – not a Proxy of a Field therein – qualify the given value with the bitpack's type ...
It is occasionally useful to derive one bitpack from another.
UART FIFO Status Register.
void transmit_watermark(FIFOControl::TransmitWatermark level) volatile
Sets the level transmit watermark.
void reset() volatile
Reset the control register to all zeros.
void loopback(bool systemLoopback=true, bool lineLoopback=false) volatile
Configure loopback.
void blocking_write(uint8_t byte) volatile
Write one byte, blocking until the byte is written.
void interrupt_enable(Interrupts interrupt) volatile
Enable the given interrupt(s) by value.
uint32_t alertTest
Alert Test Register (unused).
void interrupt_enable() volatile
Enable the given interrupt by name.
uint32_t timeoutControl
UART Receive Timeout Control.
void parity(bool enableParity=true, bool oddParity=false) volatile
Configure parity.
uint32_t readData
UART Read Data.
void interrupt_disable() volatile
Disable the given interrupt by name.
void fifos_clear() volatile
Clears the contents of the receive and transmit FIFOs.
uint32_t writeData
UART Write Data.
void disable() volatile
Turn off the transceivers.
void receive_watermark(FIFOControl::ReceiveWatermark level) volatile
Sets the level receive watermark.
void interrupt_disable(Interrupts interrupt) volatile
Disable the given interrupt(s) by value.
uint32_t values
UART Oversampled Values.
uint8_t blocking_read() volatile
Read one byte, blocking until a byte is available.
Miscellaneous utility functions and classes.