1.1 Purpose
- It's about managing interrupts.
1.2 Overview
- Interrupt register Access management, interrupt processing routine registration, and reference.
1.3 Functional overview
- [Interrupt register access management]
- The interrupt mask register is write-only, so its value cannot be read. Therefore, the value written in the interrupt mask register is held in the library. Specifically, the method is as follows.
- Prepare a memory that always has the same contents as the interrupt mask register (hereinafter, mask storage memory).
- Whenever there is a write to the interrupt mask register, the same content is also written to the mask storage memory.
- When reading the interrupt mask register, read the contents of the mask storage memory.
- [Registration and reference of interrupt processing routine]
- You can register interrupt functions and SCU functions in the interrupt vector table, and refer to the registered contents of the current interrupt vector.
The SCU interrupt function is registered as an initial value in the SCU interrupt vector table. The SCU interrupt function has the function of making a subroutine call to the registered SCU function. The registered SCU function is executed each time the SCU interrupt function is executed.
As initial values, a dummy function (executes only return processing) is registered in the interrupt function, and an SCU dummy function (executes only return processing) is registered in the SCU interrupt function. 1.4 Terms of use
- [Interrupt register access management]
- Since the library holds the value of the interrupt mask register, use the function provided by the library to write to the interrupt mask register. If you write directly, the mask storage memory and interrupt mask register will not be consistent, and correct processing will not be possible.
1.5 Calling sequence
- [Interrupt register access management]
void sysInit ()
{
INT_SetMsk ((INT_MSK_HBLK_IN | INT_MSK_VBLK_OUT),
(INT_MSK_SPR | INT_MSK_DMA1));
/ * Enable "H-Blank-IN" and "V-Blank-OUT" * /
/ * Disable "Sprite drawing end" and "Level 0-DMA" * /
...
}
void anyPrg ()
{
Uint32 status_bit;
status_bit = INT_GET_STAT (); / * Get status * /
if (INT_JudgeStat (status_bit, INT_ST_VBLK_OUT, INT_ST_VBLK_IN) == TRUE) {
/ * V-blank-OUT interrupt occurs, * /
/ * When V-blank-IN interrupt has not occurred * /
...
}
}
- [Registration and reference of interrupt processing routine]
- File A
#pragma interrupt (vblkIn) / * Let the vblkIn function be an interrupt function * /
void vblkIn (void)
{
...
}
- File B
void systemInit (void)
{
INT_SetFunc (INT_SCU_VBLK_IN, vblkIn);
/ * vblkIn interrupt function V-blank-IN interrupt block * /
/ * Register in the table. * /
INT_SetScuFunc (INT_SCU_VBLK_OUT, vblkOut);
/ * vblkOut function to V-blank-OUT interrupt vector * /
/ * Register with the SCU interrupt function. * /
...
}
void vblkOut (void)
{
...
}