# HG changeset patch # User Paul Boddie # Date 1540494682 -7200 # Node ID ddc36d3c6fbb52bde2ad21f3d40e9a2d54f3608b # Parent 58339bbc2e28756821fb13c95f1c24d1073b4685 Added a function to produce interrupt numbers from timer numbers. diff -r 58339bbc2e28 -r ddc36d3c6fbb include/init.h --- a/include/init.h Wed Oct 24 18:15:08 2018 +0200 +++ b/include/init.h Thu Oct 25 21:11:22 2018 +0200 @@ -142,6 +142,8 @@ void timer_init_interrupt(int timer, uint8_t pri, uint8_t sub); +int timer_interrupt_number(int timer); + void timer_on(int timer); int TIMER_INT_FLAGS(int timer, uint8_t flags); diff -r 58339bbc2e28 -r ddc36d3c6fbb include/pic32.h --- a/include/pic32.h Wed Oct 24 18:15:08 2018 +0200 +++ b/include/pic32.h Thu Oct 25 21:11:22 2018 +0200 @@ -301,6 +301,9 @@ #define TIMER5IPC IPC5 #define TIMERIPCBASE 0 +#define TIMERINTNUMBASE 4 +#define TIMERINTNUMSTEP 5 + /* UART conveniences. */ #define U1MODE 0xBF806000 diff -r 58339bbc2e28 -r ddc36d3c6fbb lib/init.c --- a/lib/init.c Wed Oct 24 18:15:08 2018 +0200 +++ b/lib/init.c Thu Oct 25 21:11:22 2018 +0200 @@ -505,6 +505,13 @@ SET_REG(TIMERIEC, TIMER_INT_FLAGS(timer, TxIE)); } +/* Return a timer's interrupt number. */ + +int timer_interrupt_number(int timer) +{ + return TIMERINTNUMBASE + (timer - TIMERMIN) * TIMERINTNUMSTEP; +} + /* Enable a timer. */ void timer_on(int timer)