arm: async uart writes & fixes

This commit is contained in:
2022-05-17 10:17:56 -07:00
parent e9f623e754
commit e39cdc5709
13 changed files with 232 additions and 190 deletions

View File

@@ -3,20 +3,37 @@
#include <span>
#include <string_view>
#include "xuartlite.h"
extern XUartLite* uart0;
#include "async.h"
#include "buffer.h"
void InitUarts();
// blocking
void UartSend(std::span<const std::byte> data);
inline void UartSend(std::string_view s) {
return UartSend(std::as_bytes(std::span{s.data(), s.size()}));
async::task<buffer> UartRead(int size);
async::task<> UartWrite(std::span<const std::byte> data);
inline async::task<> UartWrite(std::string_view s) {
co_await UartWrite(std::as_bytes(std::span{s.data(), s.size()}));
}
void UartSendCrash(std::span<const std::byte> data);
inline void UartSendCrash(std::string_view s) {
return UartSendCrash(std::as_bytes(std::span{s.data(), s.size()}));
// block until the provided buffer is full
void UartReadBlocking(std::span<std::byte> data);
inline uint8_t UartReadByteBlocking() {
std::byte byte;
UartReadBlocking(std::span{&byte, 1});
return static_cast<uint8_t>(byte);
}
// send and poll the uart until transmitted
void UartWriteCrash(std::span<const std::byte> 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<const std::byte> 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();