How can I make const pointer in RT code generation?

조회 수: 5 (최근 30일)
Peter Mayer
Peter Mayer 2019년 3월 11일
답변: Yuxuan Hao 2021년 2월 24일
I would like to create constant pointer to variable values to avoid putting the pointer to the RAM.
Are there settings available to achieve this?
  댓글 수: 2
Gokul Karikkat Swamikuttan
Gokul Karikkat Swamikuttan 2020년 5월 22일
I have the same question
Michael Kotthaus
Michael Kotthaus 2021년 1월 13일
I think, I have the same question.
This is what I want to do:
  • A Simulink block should generate a reusable C function.
  • The inputs and outputs are provided to the function as pointers to structs.
  • The input should be a read-only pointer which is expressed by the const qualifier.
  • The output should be a normal pointer because the function has to write to pointer's target.
So, the function's prototype declaration should not look like this:
extern void filter_step(RT_MODEL_filter_T *const filter_M,
ExtU_filter_T *filter_U,
ExtY_filter_T *filter_Y);
It should look like this:
extern void filter_step(RT_MODEL_filter_T *const filter_M,
const ExtU_filter_T *filter_U, // const because read-only
ExtY_filter_T *filter_Y);
Any ideas are welcome!
michaeL

댓글을 달려면 로그인하십시오.

답변 (1개)

Yuxuan Hao
Yuxuan Hao 2021년 2월 24일
Hi,
I am assuming you have embedded coder toolbox, and you can achieve it in the following way.
Step1. Open Embedded code mapping (by selecting embedded coder in app gallery)
Step2. In function section, click Function Preview of the step function you wish to customize.
Check Configure arguments for Step function prototype.
Then click Get Default button.
After that, you can select the style you want.
Best regards,
Yuxuan

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by