I tried to follow your example and it worked great for interfaces that are in Arduino.h such as digital and analog IO. I ran into problems when trying to include other Arduino Libraries.
I noticed that you had included "AFMotor.cpp" and "AFMotor.h" in your examples, which I guess is similar what I am attempting with "DS1307RTC.h" and "DS1307RTC.cpp" which are libraries for keeping time.
I can build the sfunction with the sfunction builder when it is structured like you have it in your examples. When I go to build the applicaiton, however, I run into an issue that seems to be related to cpp code when the compiler is expecting c code. I am using the Arduino integration package found here http://www.mathworks.com/matlabcentral/fileexchange/30277-embedded-coder-support-package-for-arduino
The compiler message I get when it attempts to build the header file with a class definition is this:
C:/ARDUIN~1.3/hardware/tools/avr/bin//avr-gcc -c -mmcu=atmega2560 -I. -DF_CPU=16000000 -Os -Wall -Wstrict-prototypes -std=gnu99 -I. -I.. -IC:/PROGRA~1/MATLAB/R2011a/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2011a/extern/include -IC:/PROGRA~1/MATLAB/R2011a/simulink/include -IC:/PROGRA~1/MATLAB/R2011a/rtw/c/src -IC:/PROGRA~1/MATLAB/R2011a/rtw/c/src/ext_mode/common -Ic:/OU_SYSTEMS_ENG/GH/gh-dev/Simulink_Models/Drivers/GH_TopLevel_Test_arduino -Ic:/OU_SYSTEMS_ENG/GH/gh-dev/Simulink_Models/Drivers -Ic:/OU_SYSTEMS_ENG/GH/gh-dev/Simulink_Models -Ic:/OU_SYSTEMS_ENG/GH/gh-dev/Simulink_Models/Custom_Includes -Ic:/OU_SYSTEMS_ENG/GH/gh-dev/Simulink_Models/ArduinoML/blocks -IC:/arduino-1.0.3/hardware/arduino/variants/mega2560 -IC:/arduino-1.0.3/hardware/arduino/cores/arduino -IC:/arduino-1.0.3/libraries/Time -IC:/arduino-1.0.3/libraries/DS1307RTC -Ireferenced_model_includes -I../slprj/arduino/_sharedutils -IC:/ARDUIN~1.3/hardware/arduino/cores/arduino ../sfun_systime_get_wrapper.c -o sfun_systime_get_wrapper.o
In file included from ../sfun_systime_get_wrapper.c:39:
C:/arduino-1.0.3/libraries/DS1307RTC/DS1307RTC.h:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'DS1307RTC'
../sfun_systime_get_wrapper.c:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sysTime'
Please let me know if you have any thoughts. I am wondering if this is still an issue with the newer Arduino support in later versions of ML/Simulink.
I've gone ahead and created a tutorial for integrating the new Arduino 1.0.3 libraries in with this support package. There are some directions in this post that I have borrowed from to compose it, but I thought it would be useful to keep everything in once place.
I'm trying to run these Embedded Coder Plugin on Matlab2011b with Linux Debian 64bit and Arduino 1.0.5.
I followed the instructions given here in the command section and on the linked websites. But when I'm trying to build the "demo_arudino_blink" model Simulink gives the error:
"makeCmd must default to PC Make command".
In the Matlab Command window I could read:
### Writing header file rtwtypes.h
### Writing source file demo_arduino_blink.c
### Writing header file demo_arduino_blink_private.h
### Writing source file demo_arduino_blink_data.c
### Writing source file ert_main.c
### TLC code generation complete.
### Creating project marker file: rtw_proj.tmw
### Processing Template Makefile: /home/testuser/.Programs/Matlab/simulink_support_package_arduino/arduino/arduino.tmf
### Build procedure for model: 'demo_arduino_blink' aborted due to an error.
so I think the error is caused from an wrong arduino.tmf file. I think the coder is trying to compare the pcMakeCmd with the Arduino makeCmd, but where is the arduino makeCmd located in Linux?
I would appreciate if anyone could help me getting these thing to work.