arm: async debug wip

This commit is contained in:
Paul Mathieu 2022-06-19 09:50:22 +02:00
parent 02fbb1c671
commit 9721ee69c5
2 changed files with 55 additions and 3 deletions

View File

@ -14,7 +14,8 @@ namespace {
using async::AwaitableType;
void Uart0Isr() {
tracing::trace(tracing::TraceEvent::kUartIsr);
ToggleLed(7);
//tracing::trace(tracing::TraceEvent::kUartIsr);
HandleUartIsr();
}
@ -36,28 +37,73 @@ void SetupTimer() {
NVIC_EnableIRQ(Timer0_IRQn);
}
#if 0 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101133
async::task<> echo() {
async::task<uint8_t> reader = UartReadLoop();
async::gimme<std::span<const std::byte>> feeder;
async::task<> writer = UartWriteLoop(feeder);
writer.h.resume(); // advance to first yield
while (1) {
buffer buff = co_await UartRead(1);
co_await UartWrite(buff.data);
SetLed(1);
uint8_t c = co_await reader;
ClearLed(1);
ToggleLed(2);
co_await feeder.feed(std::as_bytes(std::span{&c, 1}));
}
}
#endif
async::task<> echo() {
async::task<uint8_t> reader = UartReadLoop();
while (1) {
SetLed(1);
uint8_t c = co_await reader;
ClearLed(1);
ToggleLed(2);
co_await UartWrite(std::as_bytes(std::span{&c, 1}));
}
}
async::task<> dump_trace() {
while (1) {
co_await async::delay(5000);
// tracing::dump();
}
}
} // namespace
#define XUL_SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
#define XUL_SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
int main() {
_vector_table[16 + HardFault_IRQn] =
reinterpret_cast<uint32_t>(crash::HardFaultHandler);
SetupUart();
UartWriteBlocking("uart setup done\r\n");
SetupTimer();
UartWriteBlocking("timer setup done\r\n");
async::schedule(echo().h);
async::schedule(dump_trace().h);
tracing::trace(tracing::TraceEvent::kUartIsr);
tracing::trace(tracing::TraceEvent::kUartIsr);
UartWriteBlocking("init done. starting main loop\r\n");
async::main_loop([]() {
static int cnt = 0;
timer0->Pet();
if ((cnt++ % 100000) == 0) {
ToggleLed(0);
ClearLed(7);
ClearLed(2);
ClearLed(3);
ClearLed(4);
LogStuff();
}
return false;
});

View File

@ -42,6 +42,12 @@ def main():
write(s, offset, dat)
jump(s, offset)
while True:
dat = s.read()
if not dat:
break
sys.stdout.buffer.write(dat)
if __name__ == "__main__":
main()