- Main Page
- Modules
- Data Structures
- Files

# Software Interrupt Functions
[User API: Pico Layer]

## Functions
POSEXTERN void | posSoftInt (UVAR_t intno, UVAR_t param)
POSEXTERN VAR_t | posSoftIntSetHandler (UVAR_t intno, POSINTFUNC_t inthandler)
POSEXTERN VAR_t | posSoftIntDelHandler (UVAR_t intno)

## Detailed Description

pico]OS has a built in mechanism to simulate software interrupts. For example, software interrupts can be used to connect hardware interrupts, that are outside the scope of pico]OS, to the realtime operating system. A hardware interrupt will trigger a software interrupt that can then signalize a semaphore object.
Note that hardware interrupts, that do not call c_pos_intEnter and c_pos_intExit, can't do calls to pico]OS functions, except to the function posSoftInt.
All software interrupts, that are triggered by a call to posSoftInt, are chained into a global list. This list is then executed as soon as possible, but at least when the pico]OS scheduler is called (that is, for example, when a time slice has expired or a task gives of processing time by itself).
A software interrupt runs at interrupt level, that means with interrupts disabled (pico]OS calls POS_SCHED_LOCK before executing the software interrupt handler). The execution of software interrupt handlers can not be inhibited by setting the posTaskSchedLock flag.
Note that software interrupts need additional space on the processors call stack. Make sure to have space for at least 5 additional subroutine calls, plus the calls you will make in the ISR handler routine.

## Function Documentation

POSEXTERN void posSoftInt | ( | UVAR_t | intno,
|  | UVAR_t | param
| ) |

  | Software Interrupt Function. Rises a software interrupt. The software interrupt handler will be executed as soon as possible. See above for a detailed description. Parameters:
  | intno | number of the interrupt to rise. Must be in the range of 0 to POSCFG_SOFTINTERRUPTS - 1.
  | param | optional parameter that will be passed to the software interrupt handler funtion.
Note: POSCFG_FEATURE_SOFTINTS must be defined to 1 to have software interrupt support compiled in. If a software interrupt is triggered from inside the pico]OS scope, usually from application level, it is recommended to do a call to posTaskYield after this function is called. This will immediately start the interrupt handler. See also: posSoftIntSetHandler, posSoftIntDelHandler, POSCFG_SOFTINTQUEUELEN

POSEXTERN VAR_t posSoftIntDelHandler | ( | UVAR_t | intno | ) |

  | Software Interrupt Function. Deletes a software interrupt handler function, that was set with posSoftIntSetHandler before. Parameters:
  | intno | number of the interrupt to rise. Must be in the range of 0 to POSCFG_SOFTINTERRUPTS - 1.
Note: POSCFG_FEATURE_SOFTINTS must be defined to 1 to have software interrupt support compiled in. POSCFG_FEATURE_SOFTINTDEL must be defined to 1 to have this function compiled in. Returns: zero on success. See also: posSoftIntDelHandler, posSoftInt

POSEXTERN VAR_t posSoftIntSetHandler | ( | UVAR_t | intno,
|  | POSINTFUNC_t | inthandler
| ) |

  | Software Interrupt Function. Sets a software interrupt handler function. Before a software interrupt can be rised by a call to posSoftInt, this function must be called to tell pico]OS the handler function for the interrupt. Parameters:
  | intno | number of the interrupt to rise. Must be in the range of 0 to POSCFG_SOFTINTERRUPTS - 1.
  | inthandler | pointer to the interrupt handler function.
Note: POSCFG_FEATURE_SOFTINTS must be defined to 1 to have software interrupt support compiled in. Returns: zero on success. See also: posSoftIntDelHandler, posSoftInt