hostServiceCreate

Declaration

MPI_RESULT
    hostServiceCreate(HostService           *hostService,
                      MPIControl            control,
                      HostServiceFunction   serviceFunction,
                      void                  *params,
                      int32_t                  interruptPeriod,
                      MPI_BOOL              enableWatchdog,
                      int32_t                  priority); 
                                            /* -1 => maximum, else platform dependent priority */

 

Required Header: hostservice.h

Change History: Modified in 04.00.

Description

hostServiceCreate creates an SISR thread running at the specified priority for the given control object that executes the serviceFunction every interruptPeriod samples. After the create is called, the Sync interrupt occurs. By default, the service function is disabled from executing. Use hostServiceEnable(...) to enable the execution of the serviceFunction.

*hostService a pointer to a hostService object.
control a handle to a Control object.
serviceFunction a handle to a user defined Sync Interrupt Service Routine (SISR) function.
*params points to a user defined structure that will be passed to serviceFunction.
interruptPeriod specifies the frequency of the Sync Interrupt (where the frequency is a multiple of the controller’s sample rate). This value must be greater that zero.
A value of 1 generates an interrupt every controller sample.
A value of 2 generates an interrupt every other sample, etc.
enableWatchdog if TRUE, the SISR thread sets the HostProcessFlag watchdog flag in the firmware just before executing the serviceFunction. When the serviceFunction is complete,the SISR threadwill clear the watchdog flag. If the watchdog flag is still set when the firmware starts SynqNet transmission, the controller will generate a MPIEventTypeCONTROL_HOST_PROCESS_TIME_EXCEEDED event. The event indicates that the host'sserviceFunction did not complete before SynqNet transmission. This should be used if the host is trying to (for example) process feedback and calculate a new DAC command for a drive located on the network.
priority is a platform specific variable.
If "priority" is
Then
-1
hostServiceCreate will attempt to assign the maximum priority to the hostService thread.
>0
hostServiceCreate will attempt to assign the priority to the hostservice thread.
NOTE: To avoid CPU usage competition, it is recommended that you run this hostService thread at a priority slightly higher than the apputil service thread.
Return Values
handle to a HostService object.
MPIHandleVOID if the HostService could not be created

See Also

hostServiceDelete | hostServiceEnable | hostServiceStatus