Main Content

coder.mapping.api.CodeMapping

Model data and function interface configuration for C code generation

Since R2020b

    Description

    A code mappings object and related functions enable you to configure C code generation for data and functions of a Simulink® model. For model data elements, code mappings associate data elements with configurations that consist of a storage class and storage class properties. For functions, code mappings associate entry-point functions with configurations that consist of a function customization template. Reduce the effort of preparing a model for C code generation by specifying default configurations for categories of data elements and functions across a model. Override default configurations by configuring data elements or functions individually. For smaller models, you can choose to configure each data element and function individually. For models with an attached Embedded Coder Dictionary, you can map model elements to service interfaces defined in that dictionary.

    Creation

    When you select a code generation app from the Apps tab in the Simulink Editor, such as the Simulink Coder or Embedded Coder app, the app creates a coder.mapping.api.CodeMapping object if code mappings do not already exist. The app creates code mappings based on code customization settings stored in the model active configuration set object. The configuration set object can specify memory sections for data and functions.

    Create a coder.mapping.api.CodeMapping object programmatically by calling the function coder.mapping.utils.create. Create a mapping based on the active configuration set object or based on the default memory section and shared utility naming rule configurations of another configuration set object.

    Object Functions

    addSignalAdd block output signal to model code mappings
    coder.mapping.api.getGet code mappings for model
    coder.mapping.utils.createCreate code mappings object for configuring data and function interface for C and C++ code generation
    findGet model elements for the category of model code mappings
    getDataDefaultGet default storage class or storage class property setting for model data category
    getDataStoreGet code and calibration configuration from code mappings for local or shared local data store
    getDataTransferGet code configuration from code mappings for signal representing data transfer
    getDeploymentTypeGet deployment type of model
    getFunctionGet code configuration from code mappings for model function
    getFunctionDefaultGet default function customization template or memory section for model functions category
    getInportGet code and calibration configuration from code mappings for root-level inport
    getModelParameterGet code and calibration configuration from code mappings for model parameters
    getOutportGet code and calibration configuration from code mappings for root-level outport
    getSignalGet code and calibration configuration from code mappings for block output signal
    getStateGet code and calibration configuration from code mappings for block state
    removeSignalRemove block output signal from model code mappings
    setDataDefaultSet default storage class and storage class property values for model data category
    setDataStoreConfigure local or shared local data store for code and calibration file (a2l) generation
    setDataTransferSet code configuration in code mappings for signal representing data transfer
    setDeploymentTypeSet deployment type of model
    setFunctionSet code mapping information for model function
    setFunctionDefaultSet default function customization template and memory section for model functions category
    setInportConfigure root-level inports for code and calibration file (a2l) generation
    setModelParameterConfigure model parameter for code and calibration file (a2l) generation
    setOutportConfigure root-level outport for code and calibration file (a2l) generation
    setSignalConfigure block signal data for code and calibration file (a2l) generation
    setStateConfigure block states for code and calibration file (a2l) generation

    Examples

    collapse all

    For model myConfigModel, create the environment for configuring model data and functions for code generation. After calling this function, use calls to other functions listed under Object Functions to configure aspects of code generation for model interface elements.

    coder.mapping.utils.create('myConfigModel');
    

    Version History

    Introduced in R2020b

    expand all