![Vlsi VS1063a Скачать руководство пользователя страница 15](http://html.mh-extra.com/html/vlsi/vs1063a/vs1063a_programmers-manual_1042916015.webp)
PRELIMINARY
VS1063a Prog. Guide
5
WRITING PLUGINS
5.3
Idle Hook Plugin
Whenever VS1063a has spare time, it will first jump to an idle hook, then halt until the next
interrupt is received. The idle hook pointer is located at instruction address 0. Normally the
idle hook pointer contains a jump command to a dummy hook which does nothing. Address 1
contains a “nop” instruction (needed by VS_DSP because it almost always executes the next
instruction after a control transfer instruction).
To take control of the idle hook, first create a function with the following prototype:
void MyIdleHook(void);
Then, write the assembler command “J _MyIdleHook” to instruction address 0. This is done
with the formula
i
= 0
x
28
a
×
0
x
40
, where
a
is the address of MyIdleHook() and
i
is the
resulting instruction codeword.
Example: MyIdleHook() has been compiled to address 0x50.
Load that plugin into RAM memory of VS1063a.
Then modify the idle hook: In this case
d
= 0
x
28 0
x
50
×
0
x
40 = 0
x
28001400
.
Now you can write 0x8000 to register SCI_WRAMADDR to set instruction address 0.
After that write first 0x1400, then 0x2800 to register SCI_WRAM. For more information on how
to use registers SCI_WRAM and SCI_WRAMADDR, see the VS1063a Datasheet.
Alternatively, if changing the vector using VS_DSP code, use the WriteIMem() function (or, if
using assembler, STI).
5.4
Interrupt-Driven Plugin
A plugin can take control of one or more of the system interrupts. However, it needs to take
care that it either replaces the existing interrupt with a version that does essentially the same
things required by the system, or that it finishes by jumping to the original interrupt.
Although more often useful when taking control over the whole system, cooperative plugins
may also sometimes take control of one or more interrupts. To see how to do that, and to see
which interrupts are not used by the operating system, see Chapter 6.2.1.
Version: 0.40, 2011-09-02
15