mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-22 03:30:02 +00:00
system timer
This commit is contained in:
parent
8d28a52708
commit
4ff9f685f1
1
r65emu.h
1
r65emu.h
@ -11,6 +11,7 @@
|
|||||||
#include "utftdisplay.h"
|
#include "utftdisplay.h"
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "sdtape.h"
|
#include "sdtape.h"
|
||||||
|
#include "timed.h"
|
||||||
#include "hardware.h"
|
#include "hardware.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
27
timed.cpp
Normal file
27
timed.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <Energia.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <inc/hw_ints.h>
|
||||||
|
#include <driverlib/interrupt.h>
|
||||||
|
#include <driverlib/sysctl.h>
|
||||||
|
#include <driverlib/timer.h>
|
||||||
|
|
||||||
|
#include "timed.h"
|
||||||
|
|
||||||
|
static Timed *t;
|
||||||
|
|
||||||
|
// FIXME: disable timer when tick() returns false
|
||||||
|
static void timer0isr(void) {
|
||||||
|
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
|
t->tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_create(unsigned freq, Timed *client) {
|
||||||
|
t = client;
|
||||||
|
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
|
||||||
|
ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC);
|
||||||
|
TimerIntRegister(TIMER0_BASE, TIMER_A, timer0isr);
|
||||||
|
ROM_TimerEnable(TIMER0_BASE, TIMER_A);
|
||||||
|
ROM_IntEnable(INT_TIMER0A);
|
||||||
|
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
|
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet() / freq);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user