Main Content

Configure Entry-Point Function Interfaces

Define Function Customization Templates

Unless someone has defined function customization templates for a model, the Code Mappings editor presents Default as the only template option. To define a template, use the Embedded Coder® Dictionary.

  1. Open the Embedded Coder Dictionary. In the C Code tab, select Settings > Embedded Coder Dictionary.

  2. In the Embedded Coder Dictionary, click the Function Customization Templates tab.

  3. Click Add.

  4. In the new row of the table, name the template.

  5. As required by your function interface:

    • In the Function Name column, specify a default naming rule for entry-point functions.

    • In the Memory Section column, specify the name of an available memory section.

    The preview shows the results of your changes and additions.

  6. Close the dictionary.

Configure Default Code Generation for Entry-Point Functions

  1. Define a function customization template in the Embedded Coder Dictionary.

  2. In the Code Mappings editor, click the Function Defaults tab.

  3. In the Function Defaults table, select a row for a model function category.

  4. In the Function Customization Template column, select a customization template. If a Simulink® data dictionary that includes a shared coder dictionary for which defaults are set up is attached to your model, you can select Dictionary Default. For information on using dictionary defaults, see Configure Model Elements for Code Generation with Definitions Stored in Shared Data Dictionary. If you need to define a new customization template, for more information, see Define Service Interfaces, Storage Classes, Memory Sections, and Function Templates for Software Architecture.

  5. Save the model.

Override Default Code Generation for Entry-Point Functions

  1. In the Code Mappings editor, click the Functions tab.

  2. In the Source column, select an entry-point function for which you want to override the default interface configuration.

  3. As required by your function interface:

    • Select a function customization template.

    • Specify a unique function name.

  4. If your entry-point function is an execution function, you can customize the interface arguments. By default, the code generator produces a void-void interface (without arguments) and assumes variables are global. To configure the interface to pass arguments, in the Function Preview column, click the prototype hyperlink to open a configuration dialog box.

  5. In the function interface configuration dialog box, select Configure arguments for Step function prototype.

  6. Click Get Default. A table shows a list of current argument settings.

  7. In the table, you can change C type qualifiers, identifier names, and argument order as required by the function interface. Change the order of the arguments by dragging them to locations in the list. As you make changes, use the prototype preview near the top of the dialog box to verify the results.

  8. Validate your changes and save the model.