How to compile C2000 driverlib calls into an S function

21 visualizaciones (últimos 30 días)
Chris
Chris el 19 de Oct. de 2023
Respondida: Mark McBroom el 21 de Oct. de 2023
I have a F2837xD c2000 control card and we are using simulink to develop some control models. The control models need data from an external ADC and I hoped to use an S function to grab the ADC data.
The ADC's are read via SPI and I have a working CCS project which reads those ADC's via DMA.
I now want to put this into an S function block using S function builder.
When I include the driver libary include directory path, the S function builder compiler complains about a header file (hw_types.h) redefining some types (uint16_t and uint8_t).
I cannot modify the driver libary header files (that would be pointless since they are provided by TI and work). I do not understand why the s function builder throws this error and the ccs compiler does not.
Any help greatly appreciated
In file included from C:\Code\XXX\Embedded\custom_code\C\c2000_external_adc\external_adc.c:7:0: C:\ti\c2000\C2000Ware_4_00_00_00\driverlib\f2837xd\driverlib/inc/hw_types.h:72:18: error: conflicting types for 'uint8_t' typedef uint16_t uint8_t; ^~~~~~~ In file included from C:/ProgramData/MATLAB/SupportPackages/R2023a/3P.instrset/mingw_w64.instrset/lib/gcc/x86_64-w64-mingw32/6.3.0/include/stdint.h:9:0, from C:\Code\XXX\Embedded\custom_code\C\c2000_external_adc\external_adc.c:2: C:/ProgramData/MATLAB/SupportPackages/R2023a/3P.instrset/mingw_w64.instrset/x86_64-w64-mingw32/include/stdint.h:36:25: note: previous declaration of 'uint8_t' was here typedef unsigned char uint8_t; ^~~~~~~

Respuestas (1)

Mark McBroom
Mark McBroom el 21 de Oct. de 2023
S-Function builder assumes that you want to use the external C code for both Simulink simulation and code generation. For simulation, Simulink tries to compile your external C code using the mingw compiler for Windows. To support your use case, you need to instruct Simulink/Simulink Coder to only use your external C code when generating code. One approach is to use a MATLAB function block with the functions coder.target() and coder.ceval() as shown in this example:
Thanks.
Mark.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by