SWI_dec
Application Program Interface
2-433
C Interface
Syntax
SWI_dec(swi);
Parameters
SWI_Handle swi;
/* SWI object handle*/
Return Value
Void
Reentrant
yes
Description
SWI_dec is used to conditionally post a software interrupt. SWI_dec
decrements the value in SWI’s mailbox by 1. If SWI’s mailbox value
becomes 0, SWI_dec posts the SWI. You can increment a mailbox value
by using SWI_inc, which always posts the SWI.
For example, you would use SWI_dec if you wanted to post a SWI after
a number of occurrences of an event.
You specify a SWI’s initial mailbox value in the configuration. The mailbox
value is automatically reset when the SWI executes.
SWI_dec results in a context switch if the SWI's mailbox becomes zero
and the SWI has higher priority than the currently executing thread.
Constraints and
Calling Context
❏
If this macro (API) is invoked outside the context of an HWI, interrupts
must be enabled.
❏
When called within an HWI, the code sequence calling SWI_dec
must be either wrapped within an HWI_enter/HWI_exit pair or
invoked by the HWI dispatcher.
Example
/* ======== strikeOrBall ======== */
Void strikeOrBall(unsigned int call)
{
if (call == 1) {
/* initial mailbox value is 3 */
SWI_dec(&strikeoutSwi);
}
if (call == 2) {
/* initial mailbox value is 4 */
SWI_dec(&walkSwi);
}
}
See Also
SWI_dec
Decrement SWI’s mailbox value and post if mailbox becomes 0