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:
47
mbv/apps/timer/timer.cc
Normal file
47
mbv/apps/timer/timer.cc
Normal 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();
|
||||
}
|
Reference in New Issue
Block a user