synth/mbv/apps/timer/timer.cc
2025-06-23 15:21:15 -07:00

47 lines
765 B
C++

#include <cstdint>
#include "bios.h"
#include "gpio.h"
#include "intc.h"
#include "interrupts.h"
#include "pol0.h"
#include "timer.h"
namespace {
Gpio* leds;
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();
}
} // namespace
int main() {
leds = Gpio::Instance(GPIO0_BASE);
leds->data = 0xa0;
SetupTimer();
SetExternalInterruptHandler(InterruptHandler);
EnableExternalInterrupts();
leds->data = 0xa1;
BiosWozmon();
}