Mark the beginning and end of an ISR, so that TiROS can appropriately perform task scheduling if needed. Interrupt service routines are notoriusly hardware and compiler dependent, so use the instructions for your hardware/compiler port.
TiROS supports three ways of servicing interrupts:
function ISR( ) { stkptr = save_context_of_task(); // See port instructions. // stkptr = pointer to stack of saved task. perform_functions(); newstkptr = osint_taskswitcher(stkptr); load_context_of_newtask(newstkptr); }
void ISR_function(void) { int x; OS_CRITICAL_ENABLE(); // Only needed if any critical sections // will be used and interrupt nesting is enabled. OS_ISR_BEGIN(); // Mark the beginning of an ISR. Note // that if OS_CRITICAL_ENABLE() is also // present, then this comes after // that. x = 3; Do more stuff .... OS_ISR_END(); }
To use nested interrupts, write code as below:
extern uint8_t os_isr_nesting; // Internal TiROS variable that keeps track // of nesting level. void ISR_function(void) { int x; OS_CRITICAL_ENABLE(); // Only needed if any critical sections // will be used and interrupt nesting is enabled. OS_ISR_BEGIN(); // Mark the beginning of an ISR. Note // that if OS_CRITICAL_ENABLE() is also // present, then this comes after // that. if (os_isr_nesting < TIROS_MAX_ISR_NESTING) { // Interrupts should only be reenabled if the current nesting level // is less than or equal to the maximum configured nesting level. renable_interrupts(); } x = 3; Do more stuff .... OS_ISR_END(); }
Defines | |
#define | OS_ISR_BEGIN() OS_PORT_ISR_BEGIN() |
Functions | |
void | OS_ISR_END (void) |
#define OS_ISR_BEGIN | ( | ) | OS_PORT_ISR_BEGIN() |
Enable this within ISRs immediately after any variable declarations, and after any OS_CRITICAL_ENABLE().
void OS_ISR_END | ( | void | ) |
Mark the end of an ISR.
This should be called at the end of an ISR. There must exist a corresponding OS_ISR_BEGIN() statement.