mbv: now with functioning timer interrupts!

And a few other nice things.
The bootloader now has an embedded wozmon!
If you know its offset, you can jump to it from the app.
This commit is contained in:
2025-06-10 23:46:43 -07:00
parent fa6ae7b667
commit 3db383d461
17 changed files with 485 additions and 93 deletions

47
mbv/apps/timer/timer.cc Normal file
View File

@@ -0,0 +1,47 @@
#include <cstdint>
#include "intc.h"
#include "interrupts.h"
#include "pol0.h"
#include "timer.h"
namespace {
struct Gpio {
volatile uint32_t data;
};
Gpio* leds = reinterpret_cast<Gpio*>(GPIO0_BASE);
Timer* timer;
}
void Timer0Isr() {
static int counter = 0;
leds->data = counter++;
timer->Pet();
timer->ClearInterrupt();
}
void SetupTimer() {
timer = Timer::Instance(TIMER0_BASE);
timer->SetupAsWdt(100'000'000);
timer->EnableT1();
SetIsr(TIMER0_IRQN, Timer0Isr);
SetIrqEnabled(TIMER0_IRQN, true);
EnableInterrupts();
}
int main() {
leds->data = 0xa0;
SetupTimer();
SetExternalInterruptHandler(InterruptHandler);
EnableExternalInterrupts();
leds->data = 0xa1;
BiosWozmon();
}