mbv: async debugging in progres...

This commit is contained in:
2025-07-21 10:06:12 +02:00
parent f0f26af791
commit dd51b5d610
7 changed files with 78 additions and 88 deletions

View File

@@ -11,14 +11,28 @@
namespace {
Timer* timer0;
constexpr uint32_t kTicksPerSecond = 100'000'000;
constexpr uint32_t kTicksPerMicrosecond = 100;
constexpr uint32_t kOverflowSeconds = (1ULL << 32) / kTicksPerSecond;
constexpr uint32_t kOverflowMicroseconds =
((1ULL << 32) % kTicksPerSecond) / kTicksPerMicrosecond;
void Uart0Isr() {
HandleUartIsr();
}
Timer* timer0;
volatile uint32_t t1overflowsecs = 0;
volatile uint32_t t1overflowusecs = 0;
void Uart0Isr() { HandleUartIsr(); }
void Timer0Isr() {
if (timer0->HasT1Overflowed()) {
UartWriteCrash("t1 overflow\r\n");
t1overflowsecs += kOverflowSeconds;
t1overflowusecs += kOverflowMicroseconds;
timer0->ClearT1Overflow();
return;
}
SetLed(6);
UartWriteCrash("blarg\r\n");
__builtin_trap();
}
@@ -63,6 +77,8 @@ async::task<> blink() {
co_await async::delay(500);
ToggleLed(0);
timer0->Pet();
co_await UartWrite(".");
}
}
@@ -77,12 +93,16 @@ int main() {
gpio0->data = 0;
SetupInterrupts();
async::schedule(echo().h);
async::schedule(blink().h);
auto e = echo();
auto b = blink();
async::schedule(e.h);
async::schedule(b.h);
UartWriteBlocking("init done. starting main loop\r\n");
async::main_loop(nullptr);
async::main_loop([]() {
return false;
});
// should never get here
}
@@ -111,8 +131,9 @@ extern "C" void* _sbrk(int increment) {
extern "C" int _gettimeofday(struct timeval* tv, void* tzvp) {
(void)tzvp;
uint32_t ticks = timer0->GetT1Ticks();
tv->tv_sec = ticks / 100000000;
tv->tv_usec = (ticks % 100000000) / 100;
tv->tv_sec = ticks / kTicksPerSecond + t1overflowsecs;
tv->tv_usec =
(ticks % kTicksPerSecond) / kTicksPerMicrosecond + t1overflowusecs;
return 0;
}