diff options
author | siddhu8990 | 2015-12-17 14:48:36 +0530 |
---|---|---|
committer | siddhu8990 | 2015-12-23 11:26:29 +0530 |
commit | 329613eb48542f24bb9014a0a617b05199726e99 (patch) | |
tree | bf571563bb735fc2ccd9a300a952f8557667fd77 /macros/Scilab-Arduino | |
parent | 96b51a5ded447676d493be9721e4480065a5ae7e (diff) | |
download | Scilab2C_fossee_old-329613eb48542f24bb9014a0a617b05199726e99.tar.gz Scilab2C_fossee_old-329613eb48542f24bb9014a0a617b05199726e99.tar.bz2 Scilab2C_fossee_old-329613eb48542f24bb9014a0a617b05199726e99.zip |
Code generation for Arduino changed. DC motor added to Arduino.
Diffstat (limited to 'macros/Scilab-Arduino')
-rw-r--r-- | macros/Scilab-Arduino/GenerateSetupFunction.bin | bin | 0 -> 4288 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/GenerateSetupFunction.sci | 34 | ||||
-rw-r--r-- | macros/Scilab-Arduino/GetArduinoFunctions.bin | bin | 0 -> 1832 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/GetArduinoFunctions.sci | 22 | ||||
-rw-r--r-- | macros/Scilab-Arduino/GetArduinoSetupFunctions.bin | bin | 0 -> 1456 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/GetArduinoSetupFunctions.sci | 17 | ||||
-rw-r--r-- | macros/Scilab-Arduino/InsertSetupInList.bin | bin | 0 -> 6068 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/InsertSetupInList.sci | 58 | ||||
-rw-r--r-- | macros/Scilab-Arduino/IsArduinoFunction.bin | bin | 0 -> 2664 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/IsArduinoFunction.sci | 22 | ||||
-rw-r--r-- | macros/Scilab-Arduino/IsArduinoSetupFunction.bin | bin | 0 -> 2712 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/IsArduinoSetupFunction.sci | 22 | ||||
-rw-r--r-- | macros/Scilab-Arduino/buildmacros.sce | 29 | ||||
-rw-r--r-- | macros/Scilab-Arduino/lib | bin | 0 -> 772 bytes | |||
-rw-r--r-- | macros/Scilab-Arduino/names | 6 |
15 files changed, 210 insertions, 0 deletions
diff --git a/macros/Scilab-Arduino/GenerateSetupFunction.bin b/macros/Scilab-Arduino/GenerateSetupFunction.bin Binary files differnew file mode 100644 index 0000000..7a5052d --- /dev/null +++ b/macros/Scilab-Arduino/GenerateSetupFunction.bin diff --git a/macros/Scilab-Arduino/GenerateSetupFunction.sci b/macros/Scilab-Arduino/GenerateSetupFunction.sci new file mode 100644 index 0000000..db96e19 --- /dev/null +++ b/macros/Scilab-Arduino/GenerateSetupFunction.sci @@ -0,0 +1,34 @@ +function GenerateSetupFunction(FileInfo) + +SetupListFile = FileInfo.SetupListFile; + +load(SetupListFile,'SetupList'); + +SetupArduinoFile = fullfile(FileInfo.CStyleOutCCCodeDir,'setup_arduino.c'); +C_SCI2CHeader(SetupArduinoFile); + +PrintStringInfo('#include ""setup_arduino.h""',SetupArduinoFile,'file','y'); +PrintStringInfo(' ',SetupArduinoFile,'file','y'); +PrintStringInfo('int setup_arduino()',SetupArduinoFile,'file','y'); +PrintStringInfo('{',SetupArduinoFile,'file','y'); + +nelements=size(SetupList); + +for i=1:nelements + funcall = ' '; + funcall = funcall + SetupList(i)(1); + funcall = funcall + '('; + NInArg = size(SetupList(i))-1; + for j=1:NInArg-1 + funcall = funcall + SetupList(i)(j+1); + funcall = funcall + ', '; + end + funcall = funcall + SetupList(i)(NInArg+1); + funcall = funcall + ');'; + PrintStringInfo(funcall,SetupArduinoFile,'file','y'); +end +PrintStringInfo(' ',SetupArduinoFile,'file','y'); +PrintStringInfo(' return (0); ',SetupArduinoFile,'file','y'); +PrintStringInfo('}',SetupArduinoFile,'file','y'); + +endfunction diff --git a/macros/Scilab-Arduino/GetArduinoFunctions.bin b/macros/Scilab-Arduino/GetArduinoFunctions.bin Binary files differnew file mode 100644 index 0000000..82b0d45 --- /dev/null +++ b/macros/Scilab-Arduino/GetArduinoFunctions.bin diff --git a/macros/Scilab-Arduino/GetArduinoFunctions.sci b/macros/Scilab-Arduino/GetArduinoFunctions.sci new file mode 100644 index 0000000..19d59ca --- /dev/null +++ b/macros/Scilab-Arduino/GetArduinoFunctions.sci @@ -0,0 +1,22 @@ +function ArduinoFunctions = GetArduinoFunctions() +// ----------------------------------------------------------------- +// Get list of Arduino functions supported +// +// Input data: +// None +// +// Output data: +// List of Arduino functions supported +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +ArduinoFunctions = [ + "cmd_digital_out" + "cmd_digital_in" + "cmd_analog_out" + "cmd_analog_in" + "cmd_dcmotor_setup" + "cmd_dcmotor_run"]; + +endfunction diff --git a/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin b/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin Binary files differnew file mode 100644 index 0000000..048da7d --- /dev/null +++ b/macros/Scilab-Arduino/GetArduinoSetupFunctions.bin diff --git a/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci b/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci new file mode 100644 index 0000000..f377d38 --- /dev/null +++ b/macros/Scilab-Arduino/GetArduinoSetupFunctions.sci @@ -0,0 +1,17 @@ +function ArduinoSetupFunctions = GetArduinoSetupFunctions() +// ----------------------------------------------------------------- +// Get list of Arduino setup functions supported +// +// Input data: +// None +// +// Output data: +// List of Arduino setup functions supported +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +ArduinoSetupFunctions = [ + "cmd_dcmotor_setup"]; + +endfunction diff --git a/macros/Scilab-Arduino/InsertSetupInList.bin b/macros/Scilab-Arduino/InsertSetupInList.bin Binary files differnew file mode 100644 index 0000000..41c1a3f --- /dev/null +++ b/macros/Scilab-Arduino/InsertSetupInList.bin diff --git a/macros/Scilab-Arduino/InsertSetupInList.sci b/macros/Scilab-Arduino/InsertSetupInList.sci new file mode 100644 index 0000000..5c6be8b --- /dev/null +++ b/macros/Scilab-Arduino/InsertSetupInList.sci @@ -0,0 +1,58 @@ +function InsertSetupInList(FunName,InArg,NInArg,SetupListFile,FunType) + +load(SetupListFile,'SetupList'); + +//Check first if current input function already exists in the list +nelements = size(SetupList); +found=%F; + +if(FunType=='Setup') + for i=1:nelements + if(SetupList(i)(1) == FunName) + for j=1:NInArg + if(SetupList(i)(j+1) ~= InArg(j).Name) + found = %F + break; + else + found = %T; + end + end + end + if (found == %T) + break; //One match found. No need to check further. + end + end + + if(found == %F) + temp = list(FunName); + for i=1:NInArg + temp($+1) = InArg(i).Name; + end + end + SetupList($+1) = temp; +elseif((FunType=='Init')&((FunName=='cmd_digital_out')|(FunName=='cmd_analog_out')|(FunName=='cmd_digital_in'))) + for i=1:nelements + if(SetupList(i)(1) == FunName) + if(SetupList(i)(2) == InArg(2).Name) + found = %T + break; + else + found = %F; + end + end + end + + if(found == %F) + temp = list('pinMode'); + temp($+1) = InArg(2).Name; + if ((FunName=='cmd_digital_out')|(FunName=='cmd_analog_out')) + temp($+1) = 'OUTPUT'; + elseif (FunName == 'cmd_digital_in') + temp($+1) = 'INPUT'; + end + end + SetupList($+1) = temp; +end + +save(SetupListFile,'SetupList'); +endfunction diff --git a/macros/Scilab-Arduino/IsArduinoFunction.bin b/macros/Scilab-Arduino/IsArduinoFunction.bin Binary files differnew file mode 100644 index 0000000..5dbfaca --- /dev/null +++ b/macros/Scilab-Arduino/IsArduinoFunction.bin diff --git a/macros/Scilab-Arduino/IsArduinoFunction.sci b/macros/Scilab-Arduino/IsArduinoFunction.sci new file mode 100644 index 0000000..de1c770 --- /dev/null +++ b/macros/Scilab-Arduino/IsArduinoFunction.sci @@ -0,0 +1,22 @@ +function Output = IsArduinoFunction(FunName) +// ----------------------------------------------------------------- +// Check whether input function name is an Arduino function or not. +// +// Input data: +// FunName: Name of the function to be checked +// +// Output data: +// Output: True or False depending whether given function is an +// Arduino function or not +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +//Get list of supported functions for Arduino +ArduinoFunctions = GetArduinoFunctions(); + +//Check whether input function is present in above list or not +FunNameInArduino = members(FunName,ArduinoFunctions); +Output = bool2s(FunNameInArduino~=0); + +endfunction diff --git a/macros/Scilab-Arduino/IsArduinoSetupFunction.bin b/macros/Scilab-Arduino/IsArduinoSetupFunction.bin Binary files differnew file mode 100644 index 0000000..8948d1a --- /dev/null +++ b/macros/Scilab-Arduino/IsArduinoSetupFunction.bin diff --git a/macros/Scilab-Arduino/IsArduinoSetupFunction.sci b/macros/Scilab-Arduino/IsArduinoSetupFunction.sci new file mode 100644 index 0000000..fae7f62 --- /dev/null +++ b/macros/Scilab-Arduino/IsArduinoSetupFunction.sci @@ -0,0 +1,22 @@ +function Output = IsArduinoSetupFunction(FunName) +// ----------------------------------------------------------------- +// Check whether input function name is an Arduino setup function or not. +// +// Input data: +// FunName: Name of the function to be checked +// +// Output data: +// Output: True or False depending whether given function is an +// Arduino setup function or not +// +// Author: Siddhesh Wani +// ----------------------------------------------------------------- + +//Get list of supported functions for Arduino +ArduinoSetupFunctions = GetArduinoSetupFunctions(); + +//Check whether input function is present in above list or not +FunNameInArduinoSetup = members(FunName,ArduinoSetupFunctions); +Output = bool2s(FunNameInArduinoSetup~=0); + +endfunction diff --git a/macros/Scilab-Arduino/buildmacros.sce b/macros/Scilab-Arduino/buildmacros.sce new file mode 100644 index 0000000..dfeb475 --- /dev/null +++ b/macros/Scilab-Arduino/buildmacros.sce @@ -0,0 +1,29 @@ +// This file is released into the public domain + +Directories = [ "ASTManagement", ... + "CCodeGeneration", ... + "ErrorMessages", ... + "findDeps", ... + "FunctionAnnotation", ... + "FunctionList", ... + "GeneralFunctions", ... + "SymbolTable", ... + "ToolInitialization"... + "Hardware/AVR"... + "Scilab-Arduino" ]; + + +current_path_buildmacros = get_absolute_file_path("buildmacros.sce"); + +for K=1:size(Directories,"*") + myfile = current_path_buildmacros + filesep() + Directories(K) + filesep() + "buildmacros.sce"; + if isfile(myfile) then + exec(myfile); + end +end + +clear current_path_buildmacros; + +tbx_build_macros(TOOLBOX_NAME, get_absolute_file_path('buildmacros.sce')); + +clear tbx_build_macros; diff --git a/macros/Scilab-Arduino/lib b/macros/Scilab-Arduino/lib Binary files differnew file mode 100644 index 0000000..bd0cb70 --- /dev/null +++ b/macros/Scilab-Arduino/lib diff --git a/macros/Scilab-Arduino/names b/macros/Scilab-Arduino/names new file mode 100644 index 0000000..55eb6fe --- /dev/null +++ b/macros/Scilab-Arduino/names @@ -0,0 +1,6 @@ +GenerateSetupFunction +GetArduinoFunctions +GetArduinoSetupFunctions +InsertSetupInList +IsArduinoFunction +IsArduinoSetupFunction |