This page documents the process of figuring out code generation with the Embedded Code Actor for the Mbed Code Generation project.
How to use the Embedded Code Actor
- Drag the EmbeddedCodeActor into the Ptolemy model.
- Configure the EmbeddedCodeActor to use the "generatorPackage"
generic.program.procedural.c
- Add input and output ports to the actor, as desired. Their names will be used in the embedded code.
- Open the actor (right-click > open actor) and fill the preinitBlock such that the code is between the two commented lines. Fill the initBlock in the same manner.
- The fireBlock is where the main code will reside. Write your code in this section, and use the inputs and outputs from the actor as follows:
- To read an input value, use
$get(input)
, where input
is the name of the input port, without quotes.
- To set an output value, use
$put(output, value)
, where output
is the name of the output port, without quotes, and value is the desired output value.
Issues
- There is an issue with the file structure and the way files are included. All of the
#include
directives in the generated files assume that all files are in the same directory level.
- Other compilation issues that I'm currently looking into.