#pragma once #include #include #include "async.h" #include "buffer.h" void InitUarts(); async::task UartRead(int size); async::task<> UartWrite(std::span data); inline async::task<> UartWrite(std::string_view s) { co_await UartWrite(std::as_bytes(std::span{s.data(), s.size()})); } // block until the provided buffer is full void UartReadBlocking(std::span data); inline uint8_t UartReadByteBlocking() { std::byte byte; UartReadBlocking(std::span{&byte, 1}); return static_cast(byte); } // send and poll the uart until transmitted void UartWriteCrash(std::span data); inline void UartWriteCrash(std::string_view s) { return UartWriteCrash(std::as_bytes(std::span{s.data(), s.size()})); } // block until room is available in tx fifo, then send void UartWriteBlocking(std::span data); inline void UartWriteBlocking(std::string_view s) { return UartWriteBlocking(std::as_bytes(std::span{s.data(), s.size()})); } void HandleUartTxFromIsr(void*, unsigned int transmitted); void HandleUartRxFromIsr(void*, unsigned int); void HandleUartIsr();