11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

OS_DecRI()Short for Decrement and Restore Interrupts. Decrements the counter and enables interrupts if the counter reaches 0.Examplevolatile long lvar;void routine (void) {OS_IncDI();lvar ++;OS_DecRI();}OS_IncDI() increments the interrupt disable counter which is used for the entire OS and is therefore consistent withthe rest of the program in that any routine can be called and the interrupts will not be switched on before the matchingOS_DecRI() has been executed.If you need to disable interrupts for a short moment only where no routine is called, as in the example above, you couldalso use the pair OS_DI() and OS_RestoreI(). These are a bit more efficient because the interrupt disable counterOS_DICnt is not modified twice, but only checked once. They have the disadvantage that they do not work withroutines because the status of OS_DICnt is not actually changed, and they should therefore be used with great care. Incase of doubt, use OS_IncDI() and OS_DecRI().OS_DI() / OS_EI() / OS_RestoreI()OS_DI()Short for Disable Interrupts. Disables interrupts. Does not change the interrupt disable counter.OS_EI()Short for Enable Interrupts. Refrain from using this function directly unless you are sure that the interrupt enablecount has the value zero, because it does not take the interrupt disable counter into account.OS_RestoreI()Short for Restore Interrupts. Restores the status of the interrupt flag, based on the interrupt disable counter.Examplevolatile long lvar;void routine (void) {OS_DI();lvar++;OS_RestoreI();}Definitions of interrupt control macros (in <strong>RTOS</strong>.h)#define OS_IncDI() { OS_ASSERT_DICnt(); OS_DI(); OS_DICnt++; }#define OS_DecRI() { OS_ASSERT_DICnt(); if (--OS_DICnt==0) OS_EI(); }#define OS_RestoreI() { OS_ASSERT_DICnt(); if (OS_DICnt==0) OS_EI(); }104<strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>for ARM CoresPP<strong>RTOS</strong>-2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!