Documentation

Reusable Code Interface

The Reusable function settomg of the model configuration parameter Code interface packaging allows generated code to receive model data by function arguments. The generated code is reentrant. By default, Reusable function is not selected. Global data structures communicate model data to the generated code and access data with direct memory access. The generated code is not reentrant.

With Embedded Coder®, you determine whether the generated code passes root-level input and output as individual arguments, as structure references, or as part of the real-time model data structure. You can control whether the generated code allocates memory for model data statically or dynamically (using malloc).

open_system('rtwdemo_reusable');

To select the Reusable function Code interface packaging option:

  1. From the Simulink Editor, select Simulation > Model Configuration Parameters

  2. Select the Code Generation > Interface pane.

  3. Select the Reusable function Code interface packaging check-box.

  4. Configure the Multi-instance code error diagnostic option.

  5. Configure the Pass root-level I/O as option (Embedded Coder only).

  6. On the All Parameters tab, select Use dynamic memory allocation for model initialization.

bdclose('rtwdemo_reusable');
Was this topic helpful?