The CTL provides an optional set of functions for establishing C functions as interrupt service routines. These functions are available on systems that have programmable interrupt controller hardware. On systems that have fixed interrupt schemes you should use the facilities described in Low-level interrupt handling when you create your interrupt service routines.

The function ctl_set_isr is used to establish a C function as an interrupt service routine.

You must enable an interrupt source using ctl_unmask_isr and you can disable an interrupt source using ctl_mask_isr.

The C function you have established is called when the interrupt occurs. On entry to this function interrupts will still be disabled. To allow interrupts of a higher priority to occur you should enable interrupts on entry by calling ctl_global_interrupts_re_enable_from_isr and disable interrupts on exit by calling ctl_global_interrupts_un_re_enable_from_isr. Note that the pending interrupt flag in the interrupt controller hardware will be cleared by the CTL when your interrupt service routine returns.

###### Interrupt Service Routine example

    void isr(void)
    {
      ctl_global_interrupts_re_enable_from_isr();
      …
      // do interrupt handling stuff in here
      // including clearing the source of the interrupt
      …
      ctl_global_interrupts_un_re_enable_from_isr();
    }

    int main(void)
    {
      …
      ctl_set_isr(11, 11, CTL_ISR_TRIGGER_FIXED, isr, 0);
      ctl_unmask_isr(11);
      …
    }

The isr function is triggered from interrupt vector 11 and will run at priority 11. When the function is run it enables interrupts which will allow higher priority interrupts to trigger whilst it is executing.