FMSW_RegisterRandomDispatch

Registers a Custom Command handler routine to the HSM. When a custom request is sent to the HSM with a FM ID equal to the fmNumber, the Dispatch function is called.

The type FMSW_RandomDispatchFn_t is a pointer to a function such as the following.

void RandomDispatchHandler(FmMsgHandle token, 
			    void *reqBuffer, 
			    uint32_t reqLength);

The token is an opaque handle value identifying the request. The same token must be passed to SVC_Xxx() functions.

The Dispatch function returns void – it is the responsibility of the Dispatch function to call SVC_SendReply() to return the request response and to specify the return error code for the command.

The pair (reqBuffer, reqLength) defines the concatenated data that has been received on the request. See Message Dispatch API Reference function for details on custom request dispatching.

This function is used when an FM exports a custom API. It is usually called from the startup() function.

Synopsis
#include <fmsw.h>
FMSW_STATUS FMSW_RegisterRandomDispatch(
FMSW_FmNumber_t fmNumber,
FMSW_RandomDispatchFn_t dispatch);
Input Parameters
fmNumber The FM identification number
dispatch Pointer on custom request handler function
Output Requirements

Return Value:

FMSW_OK The function was registered successfully
FMSW_BAD_POINTER The function pointer is invalid
FMSW_INSUFFICIENT_RESOURCES Not enough memory to complete operation
FMSW_BAD_FM_NUMBER The FM number is incorrect
FMSW_ALREADY REGISTERED A dispatch function was already registered