Hi to everybody in the forum, this is my first topic in it, after a lot of reading.
First of all, I'm learning Arduino, but I'm going pretty fast because i used PICs.
My problem is: I went to a Timer library and couldn't understand how it makes it possible to attach different interrupt functions for a Timer OVF, for example. Here is the part of the code where it does what I mention.
void attachInterrupt(void (*isr)()) __attribute__((always_inline)) {
isrCallback = isr;
TIMSK1 = _BV(TOIE1);
}
void attachInterrupt(void (*isr)(), unsigned long microseconds) __attribute__((always_inline)) {
if(microseconds > 0) setPeriod(microseconds);
attachInterrupt(isr);
}
void detachInterrupt() __attribute__((always_inline)) {
TIMSK1 = 0;
}
static void (*isrCallback)();
As I understand, if I call TimerN.attachInterrupt( (my function here) ), I can switch to different ISR, depending on what I need.
The reason why I am asking this is that I want to implement a thing like that for other parts of my code instead of using Timer.attachInterrupt() or Timer.dettachInterrupt because i had some problems with it while sleeping my Arduino and handling some others interrupts, because they "mask" the interrupts instead of disabling them, as I read somewhere.
Thank you in advance