Menu

Forward declaration of interrupts ...again

2020-05-27
2020-07-19
  • Stepan Novotny

    Stepan Novotny - 2020-05-27

    SDCC requires that all interrupts be prototyped in "main", at minimum by #including the prototype in a header file. Sure, this does work but it means I have to

    (1) specify like so in my uart.h file:

    void uartIsr(void) __interrupt (4) __using (0);
    

    (2) repeat the above in my uart.c file where I additionally define the actual code:

    void uartIsr(void) __interrupt (4) __using (0)
    {
        magick
    }
    

    That leaves two places in two different files where I must faithfully duplicate both the interrupt number and register set, which isn't all that sterile squeaky clean IMHO.

    Has anyone found a way to prototype the function only once, and then define the code without having to repeat the interrupt number and register set spec?

     

    Last edit: Stepan Novotny 2020-05-27
  • Philipp Klaus Krause

    I guess you could have the interrupt handler in "main", andhave it contain only a single function call, e.g.:

    void int4(void) __interrupt(4)
    {
        uart_int();
    }
    
     
  • Maarten Brock

    Maarten Brock - 2020-07-19

    First of all I suggest to make sure you include uart.h in uart.c so the prototype is checked against the implementation and you get warned if it's not.

    Second, this isn't any different from any other extern function with a prototype declaration in a header file.

     

Log in to post a comment.

MongoDB Logo MongoDB