synth/mbv/apps/timer/timer.cc
Paul Mathieu d91ddeea22 timer: add missing declaration
should probably put that in a bios.h file at some point
2025-06-22 07:11:33 -07:00

52 lines
795 B
C++

#include <cstdint>
#include "intc.h"
#include "interrupts.h"
#include "pol0.h"
#include "timer.h"
extern "C" {
void BiosWozmon();
}
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();
}