2019-12-16 16:25:13 +01:00
|
|
|
#include <kernel/hardware/tmu.h>
|
2020-02-24 23:30:49 +01:00
|
|
|
#include <kernel/drivers/timer.h>
|
2019-12-16 16:25:13 +01:00
|
|
|
|
2020-05-03 23:10:49 +02:00
|
|
|
void sh7305_tmu_handler(void)
|
2019-12-16 16:25:13 +01:00
|
|
|
{
|
|
|
|
extern struct timer_cache_s timercache[TIMER_NUMBER];
|
|
|
|
uint32_t intevt;
|
|
|
|
int timer_ID;
|
|
|
|
|
|
|
|
// Get timer ID
|
|
|
|
// @note: tricky way to get timer ID
|
|
|
|
// TODO: find better way !
|
|
|
|
intevt = *(uint32_t*)0xff000028;
|
2020-02-05 21:09:39 +01:00
|
|
|
timer_ID = (intevt - 0x400) / 0x20;
|
2019-12-16 16:25:13 +01:00
|
|
|
|
2020-02-05 21:09:39 +01:00
|
|
|
// Clear interrupt flags.
|
2019-12-16 16:25:13 +01:00
|
|
|
SH7305_TMU.TIMER[timer_ID].TCR.UNF = 0;
|
|
|
|
|
|
|
|
// Execute callback if possible.
|
|
|
|
if (timercache[timer_ID].status != TIMER_UNUSED &&
|
2020-05-03 23:10:49 +02:00
|
|
|
timercache[timer_ID].callback != NULL) {
|
2019-12-16 16:25:13 +01:00
|
|
|
((void (*)(volatile void *))timercache[timer_ID].callback)(timercache[timer_ID].arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|