How can I generate embedded C code from Simulink with get/set functions?
Afficher commentaires plus anciens
I'm generating code from a Simulink model for a software module, and in order to conform to the architecture there are predefined interfaces it must implement. The problem is, I can't find a good way to generate code that implements set/get for a Data Store Memory. For example, say I want to generate code similar to this:
foo.c
double A
boolean Compare (double In1) { return (In1 <= A); }
void setA (double new_A) { if (new_A > 0) { A = new_A; } }
void getA (double *ret_A) { *ret_A = A; }
The best solution I've got this far is an export-function model where I define set and get as Simulink functions (see attachment), but that is not practical when I have multiple variables that I want to set/get individually, and forces me to wrap the module functionality in a function-call subsystem. Using one of the "export" storage classes would be unsafe since it doesn't allow me to validate the input in a set().
Is there an option I'm missing that allows me to do this? If not, what would be a good starting point? My next step is trying to create a custom storage class, but set/get is so commonplace in code that I'm assuming the option is somewhere and I missed it.
Réponses (0)
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!