synth/arm/uart.h

35 lines
946 B
C
Raw Normal View History

#pragma once
2022-05-17 03:56:25 +00:00
#include <span>
#include <string_view>
void InitUarts();
2022-05-17 03:56:25 +00:00
2022-05-17 17:17:56 +00:00
// 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);
2022-05-17 03:56:25 +00:00
}
2022-05-17 17:17:56 +00:00
// 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()}));
2022-05-17 03:56:25 +00:00
}
void HandleUartTxFromIsr(void*, unsigned int transmitted);
2022-05-17 17:17:56 +00:00
void HandleUartRxFromIsr(void*, unsigned int);
void HandleUartIsr();
2022-06-19 07:45:04 +00:00
uint8_t UartStatus();
void LogStuff();