How do I make a device driver block that outputs data from a global array?
古いコメントを表示
I am using Simulink and the Simulink Support Package for Arduino Hardware to generate and run C/C++ code on an Arduino Mega 2560. Everything works great, but I would like to develop a custom device driver. I went through the "Create a Digital Read Block" and I got that working.
For my application I need the source block to output the contents of a global array instead of just a scalar value. Coder.ceval only returns a scaler value.
So my question is how do I modify this function so I can output an array
function y = stepImpl(obj) %#ok<MANU>
y = double(0);
if isempty(coder.target)
% Place simulation output code here
else
% Call C-function implementing device output
y = coder.ceval('source_output');
end
end
採用された回答
その他の回答 (1 件)
Mark McBroom
2020 年 12 月 12 日
0 投票
You will need create the matrix in your MATLAB function and then pass it to your C Function as an argument, encapsultated in teh coder.wref() function so that MATLAB will pass it by reference to your C code. See this link for details and example: https://www.mathworks.com/help/simulink/slref/coder.wref.html
3 件のコメント
Matt Griffith
2020 年 12 月 12 日
Mark McBroom
2020 年 12 月 12 日
I have never tried it, but you might be able to use coder.opaque() to define your array as volatile.
Matt Griffith
2020 年 12 月 15 日
カテゴリ
ヘルプ センター および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!