Main Content

C Caller

Integrate C code in金宝app

  • Library:
  • Simulink / User-Defined Functions

  • C Caller block

Description

TheC Callerblock integrates your external C code into Simulink®. This block imports and lists the functions in your external C code, and allows you to select your resolved C functions to integrate in your Simulink models. TheC Caller块独立的支持代码生成。金宝app为铁道部e complex models, code generation depends on the capabilities of your Simulink model.

To use theC Callerblock, define your source code and any supporting files usingSimulation TargetunderConfiguration Parameters. Then, bring aC Callerblock to the Simulink canvas, usingLibrary Browser>金宝app>User Defined Functions. To change the defined source code file and its dependencies, go toSimulation Targettab inConfiguration Parametersby clicking thefrom the block dialog. After changing your source code or any of its dependencies, refresh the list of functions by clicking theon the block dialog. To browse the function definitions in your source code, use theicon to access your source files.

Ports

Input

expand all

Input argument to theC Callerblock.

Number of input arguments and their names are inferred through the selected function in your external C code. To receive data to aC Callerblock, connect an input signal to the input ports.

Input label has the same name as your input argument unless changed by editing theLabelcolumn underPort Specificationfrom theBlock Dialog. If you rename the label to an input port, theC Callerblock changes the name of the port.

For input variables, you can change the input scope to parameters or constants using theScopecolumn.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|Boolean|fixed point|enumerated|bus

Output

expand all

Output argument from theC Callerblock.

Number of output arguments and their names are inferred through the selected function in your external C code. To send data from yourC Callerblock, connect a block to the output port of yourC Callerblock.

Output port label has the same name as your output argument unless you change it by editing theLabelcolumn underPort Specificationfrom theBlock Dialog. If you rename the label to an input port, theC Callerblock changes the name of the port.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|Boolean|enumerated|bus

Parameters

expand all

Name of the function parsed for theC Callerblock. For a list of available functions, seeAvailable Functions.

Tunable:Yes

Programmatic Use

Block Parameter:FunctionName
Type:character vector

myFunctionName = get_param(gcb,'FunctionName')
myFunctionName = 'mean_filter'

ThePort specificationtable indicates the attributes of each input and output element for the selected block. These properties include Argument name, scope, input/output label, type and size of the input/output variables. Argument name, scope, type, and size are inferred from your source code. If the scope is aninput, you can modify this variable to aparameteror aconstant.

Name— Demonstrates the variable name inferred from your source code.

A bold argument name indicates that the port or parameter is a global argument.

Scope— Indicates the role of the variables from your source code. If the variable is an input argument in theC Callerblock source code, you can change the scope type to a constant or a parameter. If the variable is an output argument in the source code, you cannot change the scope type.

Label— Labels the input or output variable for the Simulink model. You can change the labels using this table. If the scope is a parameter, enter the parameter name in this field. If the scope is a constant, enter the constant value.

Type— Indicates the data type coming from the ports.

Size— Indicates the size of the input and output data.

Programmatic Use

Block Parameter:FunctionPortSpecification
Type:FunctionPortSpecificationobject

List of all available functions that can be mapped to aC Callerblock.

TheC Callerblock in your model imports all functions in your external source code, and shows the function names next to theFunction nameon the block dialog. To select and use a function in your block, confirm that the function name appears in theAvailable Functionstable. If you are missing one of the functions, reload the source code by clickingon the block dialog. To change the names of functions, modify your source code and click theRefreshbutton to reload.

Programmatic Use

Block Parameter:AvailableFunctions
Type:character vector

allAvailableFunctions = get_param(gcb,'AvailableFunctions')
allAvailableFunctions = 1×1 cell array {'add'}

Block Characteristics

Data Types

Booleana|busa|doublea|enumerateda|fixed pointa|integera|singlea

Direct Feedthrough

no

Multidimensional Signals

limiteda

Variable-Size Signals

no

Zero-Crossing Detection

no

aActual data type or capability support depends on block implementation.

Extended Capabilities

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2018b