My code is heavily based upon using ISRs; sometime to synchronize data changes between the main thread and the ISR, the ISR need to be disabled for some period of time. Typically I use the following code to achieve this: uint saved_ipl;
// Enter cr..
// Enter cr..