void on_low_interrupt(void) __interrupt 2;
void on_low_interrupt(void) __interrupt 2
{
#ifdef CONFIG_ENABLE_I2C
i2c_handle_interrupt();
#endif
#ifdef CONFIG_ENABLE_SERIAL
serial_handle_interrupt();
#endif
}
I'm adapting some code to run I2C in slave mode on a PIC18F47Q10.
The code was written for another similar PIC but it does need some adapting.
This is the original code: https://github.com/texane/pic18f_i2c
I don't understand the call before being defined, I also don't get what the '2' is meant to do.
This is from the int.c
file posted in the original. Any help or explanation is appreciated.
For now I'm commenting all of this out and hoping it works without it.
The errors seen are:
"unexpected token: __interrupt
Unable to resolve identifier on_low_interrupt."
"error: expected function body after function declarator"
The
void on_low_interrupt(void) __interrupt 2;
is no function call, this is theon_low_interrupt
function declaration. Below is found theon_low_interrupt
function definition with it's body.Identifiers with leading two underscores are reserved for implementations and are usually used by compilers implementators. So because the
2
is after an identifier with two underscores__interrupt
it is most probably doing something compiler specific and it's meaning is also compiler specific.A good guess would be that the code was written for sdcc compiler. You may read on page 44 in section
3.1. General Information
in sdcc manual that:So the
2
represents the hardware interrupt number the routine is meant to service. The interpretation of what exactly is "interrupt number 2" is dependent on the device. In the repository you linked, there's a18f4550.lkr
file - most probably a linker script forpic18f4550
. The datasheet for the device may guide you further on your quest on understanding the number.