1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

cpu/gd32v: allow using TIMER0 as timer device

This commit is contained in:
Gunar Schorcht 2023-01-28 17:46:45 +01:00
parent 596d762806
commit 0dfbdebaf7

View File

@ -111,7 +111,12 @@ int timer_init(tim_t tim, unsigned long freq, timer_cb_t cb, void *arg)
dev(tim)->CAR = timer_config[tim].max;
/* set prescaler */
dev(tim)->PSC = (((periph_apb_clk(timer_config[tim].bus) * 2) / freq) - 1);
if (dev(tim) == TIMER0) {
dev(tim)->PSC = ((periph_apb_clk(timer_config[tim].bus) / freq) - 1);
}
else {
dev(tim)->PSC = (((periph_apb_clk(timer_config[tim].bus) * 2) / freq) - 1);
}
DEBUG("[timer]: %" PRIu32 "/%lu = %" PRIu16 "\n",
periph_apb_clk(timer_config[tim].bus), freq, dev(tim)->PSC);
@ -276,6 +281,11 @@ static void _timer_isr(unsigned irq)
case TIMER_3_IRQN:
_irq_handler(TIMER_DEV(3));
break;
#endif
#ifdef TIMER_4_IRQN
case TIMER_4_IRQN:
_irq_handler(TIMER_DEV(4));
break;
#endif
default:
assert(false);