Call a Legacy Lookup Table Function Using C Caller block
This example shows how to use the C Caller block to call legacy C functions that implement N-dimensional table lookups.
In this example the legacy C functions are defined inlookupTable.h
, and implemented indirectLookupTableND.c
. The type definitions used in this example can be found inyour_types.h
.
To enable calling the C functions from the C Function block, in the model, specify the header file and the source file in theConfiguration Parameters>Simulation Targetpane. The prototype of the legacy function being called in this example is:
FLT directLookupTableND(const FLT *tableND, const UINT32 nbDims, const UINT32 *tableDims, const UINT32 *tableIdx)
whereFLT
is a type definition to a floating-point type, andUINT32
is a type definition to an unsigned 32-bit integer.
const FLT *tableND
- Tableconst UINT32 nbDims
- Dimensionality of the tableconst UINT32 *tableDims
- Size of the tableconst UINT32 *tableIdx
- Table index
In the C Caller block,tableND
andtableDims
are mapped to C Caller block parameters,nbDims
is a block constant, andtableIdx
is the input to the block. The value returned by the legacy C function is the output of the block.
model ='slexCCallerLookupTable'; open_system(model); sim(model); slcc('clearCustomCodeModules');