mirror of
https://github.com/jscrane/r65emu.git
synced 2024-05-29 03:41:36 +00:00
add ESP32 impl
This commit is contained in:
parent
cde06f03cd
commit
79ac908472
19
timed.cpp
19
timed.cpp
|
@ -1,17 +1,18 @@
|
||||||
#ifdef notdef
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <Energia.h>
|
#if defined(__LM4F120H5QR__)
|
||||||
#include <stdint.h>
|
|
||||||
#include <inc/hw_ints.h>
|
#include <inc/hw_ints.h>
|
||||||
#include <driverlib/interrupt.h>
|
#include <driverlib/interrupt.h>
|
||||||
#include <driverlib/sysctl.h>
|
#include <driverlib/sysctl.h>
|
||||||
#include <driverlib/timer.h>
|
#include <driverlib/timer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "timed.h"
|
#include "timed.h"
|
||||||
|
|
||||||
static Timed *t;
|
static Timed *t;
|
||||||
|
|
||||||
// FIXME: disable timer when tick() returns false
|
// FIXME: disable timer when tick() returns false
|
||||||
|
#if defined(__LM4F120H5QR__)
|
||||||
static void timer0isr(void) {
|
static void timer0isr(void) {
|
||||||
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
t->tick();
|
t->tick();
|
||||||
|
@ -27,4 +28,16 @@ void timer_create(unsigned freq, Timed *client) {
|
||||||
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet() / freq);
|
ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, ROM_SysCtlClockGet() / freq);
|
||||||
}
|
}
|
||||||
|
#elif defined(ESP_PLATFORM)
|
||||||
|
|
||||||
|
void IRAM_ATTR onTimer() {
|
||||||
|
t->tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_create(unsigned freq, Timed *client) {
|
||||||
|
hw_timer_t *timer = timerBegin(3, 80, true); // prescaler of 80
|
||||||
|
timerAttachInterrupt(timer, &onTimer, true);
|
||||||
|
timerAlarmWrite(timer, 1000000 / freq, true);
|
||||||
|
timerAlarmEnable(timer);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user