Assume I have following code sequence:
2. some code
4. some code
6. some code
disable_interrupts() is done by __asm("cpsid i")
enable_interrupts() is done by __asm("cpsie i")
When will interrupts become enabled back in the above sequence, at 5. or at 7.? Does S32K148 keep track of nested "cpsid" and "cpsie"?
It's safe in the sense that the documentation doesn't state not to do it.
If you want to enable interrupt nesting, calling CPSIE inside the ISR (like you would on an S12X) is not the way to go, since PRIMASK and FAULTMASK are unchanged upon exception entry. It won't have any effect. You can make use of the priority levels. Higher priority exceptions can interrupt lower priority exceptions.
If you want to prevent interrupts from interrupting your ISR, you can safely call CPSID and then re-enable with CPSIE when you're done.