arm: separate async stuff from main uart
This commit is contained in:
parent
c0cdb7a068
commit
8d81f4f9c4
@ -6,6 +6,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "uart_async.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using async::AwaitableType;
|
using async::AwaitableType;
|
||||||
@ -38,7 +39,6 @@ void SetupTimer() {
|
|||||||
timer0->SetupAsWdt(100000 * 4000);
|
timer0->SetupAsWdt(100000 * 4000);
|
||||||
timer0->EnableT1();
|
timer0->EnableT1();
|
||||||
}
|
}
|
||||||
} // namespace
|
|
||||||
|
|
||||||
async::task<> echo() {
|
async::task<> echo() {
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -46,6 +46,7 @@ async::task<> echo() {
|
|||||||
co_await UartWrite(buff.data);
|
co_await UartWrite(buff.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
SetupUart();
|
SetupUart();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
|
#include "uart_async.h"
|
||||||
|
|
||||||
#include "async.h"
|
#include "async.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
@ -3,17 +3,8 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "async.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
|
|
||||||
void InitUarts();
|
void InitUarts();
|
||||||
|
|
||||||
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()}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// block until the provided buffer is full
|
// block until the provided buffer is full
|
||||||
void UartReadBlocking(std::span<std::byte> data);
|
void UartReadBlocking(std::span<std::byte> data);
|
||||||
inline uint8_t UartReadByteBlocking() {
|
inline uint8_t UartReadByteBlocking() {
|
||||||
|
13
arm/uart_async.h
Normal file
13
arm/uart_async.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <span>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
#include "async.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
|
||||||
|
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()}));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user