Hi all,
I have a number of Simulink function which encapsulate Matlab functions. I have split these function up in different models and I code generate them one at a time. Lets call the first model ModelA and the second ModelB. Both models require to use the CMSIS ARM library. Also ModelB has dependencies on ModelA.
ModelA seems to code generate fine, but when ModelB tries to code generate it spits out an error:
"C:\Program Files\MATLAB\R2017b\bin\win64\mex.exe" -c COPTIMFLAGS="-O2" -DMATLAB_MEX_FILE -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\mathfunctions" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab" -I"C:\sw_dev\trunk_latest\development\G3\common\include" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\mathfunctions_ert_rtw" -I"C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\_sharedutils" -I"C:\Program Files\MATLAB\R2017b\extern\include" -I"C:\Program Files\MATLAB\R2017b\simulink\include" -I"C:\Program Files\MATLAB\R2017b\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2017b\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src" -I"C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src" DFPI_sfun.c
Building with 'MinGW64 Compiler (C)'.
In file included from C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\mathfunctions_ert_rtw/MathFunctions.h:26:0,
from C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src\DFPI_sfun.h:30,
from C:\sw_dev\trunk_latest\Development\G3\RTU\AMM\Matlab\slprj\_sfprj\DFPI\_self\sfun\src\DFPI_sfun.c:4:
C:\sw_dev\trunk_latest\development\G3\RTU\AMM\Matlab\slprj\ert\_sharedutils/mw_cmsis.h:12:22: fatal error: arm_math.h: No such file or directory
compilation terminated.
If I add an include (in the Simulation Target model Configuration file) pointing to the CMSIS support package where the arm_math.h is located then I get a whole host of errors:
"C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:314:4: "error: #error Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
#error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:387:11: error: unknown type name 'int8_t'
typedef int8_t q7_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:392:11: error: unknown type name 'int16_t'
typedef int16_t q15_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:397:11: error: unknown type name 'int32_t'
typedef int32_t q31_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:402:11: error: unknown type name 'int64_t'
typedef int64_t q63_t;
^
C:\programdata\MATLAB\supportpackages\R2017b\3p.instrset\cmsis.instrset\CMSIS\Include/arm_math.h:484:10: error: unknown type name '__INLINE'
static __INLINE q31_t clip_q63_to_q31( "
If I set the code replacement library to the GNU C99 externsions I do not get this error. It seems this problem stems from the fact that ModelB depends on ModelA, where ModelA I use as a library of common function. I do this in order to avoid code duplication.
For example ModelA contains the function definitions for sin, cos, modulo, remainder, etc... which other models depend on. Typically the naming convention I use is "ModelA_cos", "ModelA_Sin", etc... and the functions in other models call them by this name. I was hoping this was a good way to avoid code duplication.
If I remove this 'type' of calling convention from ModelB and I simply use Matlabs' own sin, cos, etc... I can code generate fine using CMSIS as the code replacement library, but code is duplicate across models, which is something I would like to avoid.
Any ideas? Couldn't find much info online.
Thanks Alex