Software Interrupts
4-34
Figure 4-9. Using SWI_or to Post an SWI.
If the program execution requires that multiple occurrences of the same event
must take place before an SWI is posted, SWI_dec should be used to post
the SWI as shown in Figure 4-10. By configuring the SWI mailbox to be equal
to the number of occurrences of the event before the SWI should be posted
and calling SWI_dec every time the event occurs, the SWI is posted only after
its mailbox reaches 0; that is, after the event has occurred a number of times
equal to the mailbox value.
Program configuration
SWI object myswi Function myswiFxn()
Program
execution
· Calls
SWI_or(&myswi, 0x1)
· myswi is posted
· myswiFxn() is executed
†
· Calls
SWI_or(&myswi, 0x2)
· myswi is posted
· myswiFxn() is executed
Mailbox
value
Value returned by
SWI_getmbox
0
...
0 0
...
0
...
0 1
0
...
0 0
0
...
1 0
0
...
0 0
...
0
...
0 1
...
0
...
1 0
myswiFxn()
{
...
eventType = SWI_getmbox();
switch (eventType) {
case '0x1':
'run processing algorithm 1'
case '0x2':
'run processing algorithm 2'
case '0x4':
'run processing algorithm 3'
...
}
...
}