You can disable interrupts using the ctl_global_interrupts_disable function call.
int en=ctl_global_interrupts_disable();
This function returns the previous global interrupts enabled state.
You can enable interrupts using the ctl_global_interrupts_enable function call.
int en=ctl_global_interrupts_enable();
This function returns the previous global interrupts enabled state.
You can restore the previous global interrupts enabled state you the ctl_global_interrupts_set function call.
int en=ctl_global_interrupts_disable(); ... ctl_set_interrupts(en);
Note that you can call a tasking library function that causes a task switch with global interrupts disabled. The tasking library will ensure that when a task is scheduled that global interrupts are enabled.
You can re-enable global interrupt enables from within an interrupt service routine using the ctl_global_interrupts_re_enable_from_isr function call in order to permit higher priority interrupts to occur. A call to this function must be matched with a call to the ctl_global_interrupts_un_re_enable_from_isr function.
// code of interrupt service routine .... ctl_global_interrupts_re_enable_from_isr(); .... // global interrupts are now enabled so another interrupt can be handled. .... ctl_global_interrupts_un_re_enable_from_isr(); ....