# OS_SetIrqCheckFlag

## C Specification

  `#include <nitro/os.h>`
  `void OS_SetIrqCheckFlag( OSIrqMask intr );`

## Arguments

intr | The IRQ interrupt cause to be enabled (expressed as a logical sum)

## Return Values

None.

## Description

Sets a check flag for IRQ interrupts Normally, this flag is called by the handler for each interrupt. When individual interrupt processes finish, the check flag is set to indicate that this function has been called by the interrupt. For example, the function that is called by a V-Blank interrupt will be:

> ``OS_SetIrqCheckFlag( OS_IE_V_BLANK );``

and a check flag is set. The table below describes these flags.

The flag set here is used to check whether or not an interrupt occurred with `OS_WaitIntr`, `OS_WaitInterrupt`, or `SVC_WaitVBlankIntr`. Therefore, if there are interrupts that do not wait with those functions, the flags will not be used from anywhere even if they are set, so they do not necessarily have to be set. But if you carry out separate processes for each situation you may forget to write them when they are necessary. It is recommended that you always set the flags for interrupts if doing this creates no problems.

If `OS_WaitIntr`, `OS_WaitInterrupt`, and/or `SVC_WaitVBlankIntr` are carried out for the same interrupt with multiple threads, be aware that a restore can only be performed with one of these threads for one interrupt.

Interrupt Check Flags

OS_IE_V_BLANK | V-blank interrupt
OS_IE_H_BLANK | H-blank interrupt
OS_IE_V_COUNT | V counter interrupt
OS_IE_TIMER0 | Timer0 interrupt
OS_IE_TIMER1 | Timer1 interrupt
OS_IE_TIMER2 | Timer2 interrupt
OS_IE_TIMER3 | Timer3 interrupt
OS_IE_DMA0 | DMA0 interrupt
OS_IE_DMA1 | DMA1 interrupt
OS_IE_DMA2 | DMA2 interrupt
OS_IE_DMA3 | DMA3 interrupt
OS_IE_KEY | Key interrupt *1
OS_IE_CARTRIDGE | Game Pak IREQ/DREQ interrupt
OS_IE_SUBP | ARM7 interrupt
OS_IE_SPFIFO_SEND | ARM9-ARM7 send FIFO empty interrupt
OS_IE_SPFIFO_RECV | ARM9-ARM7 receive FIFO not-empty interrupt
OS_IE_CARD_DATA | Card data transfer end interrupt
OS_IE_CARD_IREQ | Card IREQ interrupt
OS_IE_GXFIFO | Geometry command FIFO interrupt

*1 The hardware specification does not allow the use of the key interrupt. However, it can be used for waking from sleep.

Besides flags for hardware interrupts, there are dummy check flags like those shown below, which can be used freely in the application. In order to obtain synchronization with callback functions, these can replace the processing for polling carried out by volatile variables with a combination of `OS_WaitIrq()`, `OS_ClearIrqCheckFlag()`, and `OS_SetIrqCheckFlag()`.

OS_IE_USER_FLAG0 | Check Flag 0 that can be used freely in the application
OS_IE_USER_FLAG1 | Check Flag 1 that can be used freely in the application

## See Also

`OS_ClearIrqCheckFlag`, `OS_GetIrqCheckFlag`

## Internal Operation

In the ARM9, the predetermined location (`DTCM_END - 8`) in DTCM is designated to be the check flag region. This function operates on this region. In the ARM7, the predetermined location of the ARM7 WRAM (highest address - 8) is designated to be the check flag region. The function operates on this region.

## Revision History

03/08/2005 Standardized the use of the term 'interrupt' in Japanese.
12/08/2004 Added cautions about OS_IE_KEY.
11/24/2004 Deleted OS_IE_SIO.
11/02/2004 Deleted `SVC_WaitIntr()` from See Also.
09/01/2004 Changed 'subprocessor' to 'ARM7' and 'between subprocessors' to 'between ARM9 and ARM7'.
04/22/2004 Added cautions about using multiple threads.
01/09/2003 Initial version.