summaryrefslogtreecommitdiff
path: root/Modelica-Arduino-MDD_Arduino_Revised/MDD_build
diff options
context:
space:
mode:
authorSiddharth112352019-09-03 18:09:16 +0530
committerSiddharth112352019-09-03 18:09:16 +0530
commitb4b6aa36e3486a3544acc52419149b5671f841e9 (patch)
tree66c1783158f23e6d21c77324156fc57e18d4ac67 /Modelica-Arduino-MDD_Arduino_Revised/MDD_build
parentf5266f634f4fb4fd39933a83551a01cf446256b8 (diff)
downloadOpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.tar.gz
OpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.tar.bz2
OpenModelica_HIL-b4b6aa36e3486a3544acc52419149b5671f841e9.zip
Pushing entire Modelica HIL Tasks repoHEADmaster
Diffstat (limited to 'Modelica-Arduino-MDD_Arduino_Revised/MDD_build')
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_bothbin0 -> 24150 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.hex121
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both_main.c217
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clockbin0 -> 22099 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.hex101
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock_main.c213
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loopbin0 -> 25914 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.hex135
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop_main.c217
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_both.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_clock.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_loop.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_ledbin0 -> 23828 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.hex120
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led_main.c243
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_read.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_led.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_read.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blinkbin0 -> 23721 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.hex114
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink_main.c212
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_bluebin0 -> 4964 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.hex93
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delaybin0 -> 22109 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.hex100
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay_main.c212
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_main.c212
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_redbin0 -> 5364 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.hex108
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red_main.c215
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blinkbin0 -> 5900 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.hex131
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink_main.c212
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blink.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_delay.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_red.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_green_blink.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_thresholdbin0 -> 6052 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.hex150
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold_main.c264
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/runMDD_pot_threshold.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_buttonbin0 -> 21147 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.hex94
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button_main.c234
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_statusbin0 -> 21092 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.hex91
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status_main.c219
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_led_push_button.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_push_button_status.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_init.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_loop.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_pot.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_reverse.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_initbin0 -> 21112 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.hex94
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init_main.c213
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop_main.c235
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot_main.c244
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reversebin0 -> 22099 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.hex101
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse_main.c213
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_buzzer.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_read.mos11
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzerbin0 -> 23856 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.hex121
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer_main.c253
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_readbin0 -> 5388 bytes
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.hex114
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.sh61
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read_main.c226
88 files changed, 7210 insertions, 0 deletions
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both
new file mode 100755
index 0000000..49bd982
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.hex
new file mode 100755
index 0000000..6092d32
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.hex
@@ -0,0 +1,121 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C942C0140
+:100020000C9451000C9451000C9451000C94FB0062
+:100030000C9451000C9451000C94CA000C94510083
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E4E5F7E002C0F3
+:1000800005900D92A831B107D9F711E0A8E1B1E0D0
+:1000900001C01D92AD31B107E1F70E94A4010C949B
+:1000A000A8030C940000CF92DF92EF92FF92CF93BF
+:1000B000DF93EC01C880D980EA80FB80C701B601DC
+:1000C0000E9479029B01AC01C701B6010E94D301D5
+:1000D0006B017C0120E030E040E05FE30E944103DF
+:1000E00087FD03C084E690E002C080E090E09D833D
+:1000F0008C8320E030E040E05FE3C701B6010E945E
+:10010000380287FF03C084E690E002C080E090E000
+:100110009F838E838E899F898230910561F0833021
+:10012000910599F00197C9F416BC80916E00826028
+:1001300080936E0016C0109285001092840080910A
+:100140006F00826080936F000CC01092B2008091AB
+:10015000700082608093700004C081E090E00E9493
+:10016000A80378949FB7F89480911A019FBF8823C1
+:10017000C9F310921A01EE85FF858C818083EA898C
+:10018000FB898E818083DF91CF91FF90EF90DF908C
+:10019000CF9008951F920F920FB60F9211242F93B4
+:1001A0003F938F939F93809118019091190101962D
+:1001B000909319018093180180911A01813091F078
+:1001C000209118013091190180911B0190911C011F
+:1001D0002817390738F081E080931A01109219012D
+:1001E000109218019F918F913F912F910F900FBE08
+:1001F0000F901F9018951F920F920FB60F92112417
+:100200002F933F938F939F938091180190911901A1
+:100210000196909319018093180180911A01813001
+:1002200091F0209118013091190180911B0190915A
+:100230001C012817390738F081E080931A011092C9
+:100240001901109218019F918F913F912F910F905A
+:100250000FBE0F901F9018951F920F920FB60F921E
+:1002600011242F933F938F939F9380911801909126
+:1002700019010196909319018093180180911A0138
+:10028000813091F0209118013091190180911B016A
+:1002900090911C012817390738F081E080931A01EA
+:1002A00010921901109218019F918F913F912F91F7
+:1002B0000F900FBE0F901F901895CF93DF93FC0106
+:1002C000C1E8D0E088818D60888322E030E0318B06
+:1002D000208B229A40E850E0DA018C9181628C9365
+:1002E0008AE890E0DC0111961C921E921C92938B7E
+:1002F000828B88818D60888335872487219ADA01F3
+:100300008C9181688C93A8E8B0E011961C921E92A3
+:100310001C92B787A68785B5836085BD81E090E094
+:10032000958B848B2AE030E030931C0120931B01D5
+:1003300024B5226024BD29EF27BD978B868B80E0F2
+:1003400090E0DF91CF910895CF92DF92EF92FF92EC
+:1003500080E091E00E945D01C12CD12C760160E02B
+:1003600070E0CB0160930001709301018093020162
+:100370009093030180E091E00E9453008FEFC81A30
+:10038000D80AE80AF80AC701B6010E943C022FE623
+:1003900032E143E05BE30E94450320E030E0A90145
+:1003A0000E94D401DFCF5058BB27AA270ED018C116
+:1003B00009D130F00ED120F031F49F3F11F41EF43A
+:1003C000FEC00EF4E095E7FBCBC0E92F1AD180F315
+:1003D000BA17620773078407950718F071F49EF542
+:1003E00049C10EF4E0950B2EBA2FA02D0B01B901D7
+:1003F00090010C01CA01A0011124FF27591B99F09B
+:10040000593F50F4503E68F11A16F040A22F232FA6
+:10041000342F4427585FF3CF469537952795A795F6
+:10042000F0405395C9F77EF41F16BA0B620B730B9D
+:10043000840BBAF09150A1F0FF0FBB1F661F771F0E
+:10044000881FC2F70EC0BA0F621F731F841F48F4C3
+:10045000879577956795B795F7959E3F08F0B3CF49
+:100460009395880F08F09927EE0F97958795089533
+:1004700053D008F481E00895E89409C097FB3EF456
+:1004800090958095709561957F4F8F4F9F4F9923E1
+:10049000A9F0F92F96E9BB279395F695879577955F
+:1004A0006795B795F111F8CFFAF4BB0F11F460FF1F
+:1004B0001BC06F5F7F4F8F4F9F4F16C0882311F077
+:1004C00096E911C0772321F09EE8872F762F05C08B
+:1004D000662371F096E8862F70E060E02AF09A9526
+:1004E000660F771F881FDAF7880F9695879597F91B
+:1004F0000895A9D080F09F3740F491110EF0BBC051
+:1005000060E070E080E89FEB089526F41B16611D03
+:10051000711D811D2BC045C0990F0008550FAA0BF6
+:10052000E0E8FEEF16161706E807F907C0F0121606
+:100530001306E407F50798F0621B730B840B950B09
+:1005400039F40A2661F0232B242B252B21F408955E
+:100550000A2609F4A140A6958FEF811D811D0895FB
+:1005600097F99F6780E870E060E00895882371F450
+:10057000772321F09850872B762F07C0662311F43C
+:1005800099270DC09051862B70E060E02AF09A9573
+:10059000660F771F881FDAF7880F9695879597F96A
+:1005A00008959F3F31F0915020F487957795679596
+:1005B000B795880F911D9695879597F908959FEFA8
+:1005C00080EC089500240A941616170618060906EA
+:1005D000089500240A9412161306140605060895B9
+:1005E000092E0394000C11F4882352F0BB0F40F441
+:1005F000BF2B11F460FF04C06F5F7F4F8F4F9F4F81
+:10060000089557FD9058440F551F59F05F3F71F002
+:100610004795880F97FB991F61F09F3F79F0879569
+:100620000895121613061406551FF2CF4695F1DFF2
+:1006300008C0161617061806991FF1CF8695710582
+:10064000610508940895E5DFA0F0BEE7B91788F4C6
+:10065000BB279F3860F41616B11D672F782F8827A7
+:10066000985FF7CF869577956795B11D93959639E5
+:10067000C8F30895E894BB2766277727CB0197F93D
+:1006800008954ADF08F48FEF08950BD0A9CF9ADFC1
+:1006900028F09FDF18F0952309F062CF90CF112446
+:1006A000EACFAFDFA0F3959FD1F3950F50E0551F30
+:1006B000629FF001729FBB27F00DB11D639FAA27B7
+:1006C000F00DB11DAA1F649F6627B00DA11D661F06
+:1006D000829F2227B00DA11D621F739FB00DA11D27
+:1006E000621F839FA00D611D221F749F3327A00DE1
+:1006F000611D231F849F600D211D822F762F6A2F7D
+:1007000011249F5750408AF0E1F088234AF0EE0F01
+:10071000FF1FBB1F661F771F881F91505040A9F70E
+:100720009E3F510570F01CCFA6CF5F3FECF3983E83
+:10073000DCF3869577956795B795F795E7959F5F75
+:10074000C1F7FE2B880F911D9695879597F908950F
+:04075000F894FFCF4B
+:1007540000000000000000000AD7233C0000000055
+:0807640000000000000000008D
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
new file mode 100755
index 0000000..762735b
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_dcmotor_both.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_dcmotor_both.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections dcmotor_both_main.c -o dcmotor_both -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom dcmotor_both dcmotor_both.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:dcmotor_both.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both_main.c
new file mode 100755
index 0000000..dbf03a2
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both_main.c
@@ -0,0 +1,217 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct dcmotor_both_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct dcmotor_both_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[2];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[6];
+} dcmotor_both_fmi2Component;
+
+dcmotor_both_fmi2Component dcmotor_both_component = {
+ .fmi2IntegerVars = {
+ 0 /*pwm._u[1]*/,
+ 0 /*pwm1._u[1]*/,
+ },
+ .fmi2RealParameter = {
+ 0.01 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component dcmotor_both_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &dcmotor_both_component;
+}
+
+fmi2Status dcmotor_both_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_both_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[2] /* pwm1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[3] /* pwm1._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[2] /* pwm1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 2, 0, fmi2False);
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 10);
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_both_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status dcmotor_both_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status dcmotor_both_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */ = ((om_mod(comp->currentTime,1.0))>=(0.5)) ? (100) : (0); /* equation 4 */
+ comp->fmi2IntegerVars[1] /* pwm1._u[1] DISCRETE */ = ((om_mod(comp->currentTime,1.0))<(0.5)) ? (100) : (0); /* equation 5 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[3] /* pwm1._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[1] /* pwm1._u[1] DISCRETE */);
+}
+
+fmi2Status dcmotor_both_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ dcmotor_both_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = dcmotor_both_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ dcmotor_both_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ dcmotor_both_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ dcmotor_both_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = dcmotor_both_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock
new file mode 100755
index 0000000..0e58a0e
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.hex
new file mode 100755
index 0000000..f752eb8
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.hex
@@ -0,0 +1,101 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E50088
+:100020000C9451000C9451000C9451000C94B400A9
+:100030000C9451000C9451000C9483000C945100CA
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0ECE1F6E002C0F0
+:1000800005900D92A231B107D9F711E0A2E1B1E0DC
+:1000900001C01D92A731B107E1F70E9445010C9400
+:1000A0000C030C9400008230910561F083309105BF
+:1000B00099F00197C9F416BC80916E00826080931C
+:1000C0006E0016C0109285001092840080916F001F
+:1000D000826080936F000CC01092B200809170001B
+:1000E00082608093700004C081E090E00E940C0365
+:1000F00078949FB7F894809114019FBF8823C9F327
+:100100001092140108951F920F920FB60F921124AE
+:100110002F933F938F939F9380911201909113019E
+:100120000196909313018093120180911401813004
+:1001300091F020911201309113018091150190915D
+:1001400016012817390738F081E0809314011092C6
+:100150001301109212019F918F913F912F910F9057
+:100160000FBE0F901F9018951F920F920FB60F920F
+:1001700011242F933F938F939F938091120190911D
+:100180001301019690931301809312018091140141
+:10019000813091F02091120130911301809115016D
+:1001A000909116012817390738F081E080931401E7
+:1001B00010921301109212019F918F913F912F91F4
+:1001C0000F900FBE0F901F9018951F920F920FB6B1
+:1001D0000F9211242F933F938F939F93809112013D
+:1001E00090911301019690931301809312018091D5
+:1001F0001401813091F0209112013091130180910E
+:100200001501909116012817390738F081E0809385
+:10021000140110921301109212019F918F913F913E
+:100220002F910F900FBE0F901F901895FC01A1E821
+:10023000B0E08C918D608C9382E090E09387828710
+:10024000229AA0E8B0E08C9181628C93AAE8B0E099
+:1002500011961C921E921C92B587A48785B5836067
+:1002600085BD81E090E0978786872AE030E0309373
+:1002700016012093150124B5226024BD29EF27BD66
+:10028000918B808B80E090E00895CF92DF92EF9287
+:10029000FF9280E091E00E941601C12CD12C7601E2
+:1002A00060E070E0CB0160930001709301018093E6
+:1002B00002019093030120E030E040E85FE30E94F8
+:1002C000F30187FF03C08FEF90E002C080E090E071
+:1002D0009093050180930401809110019091110188
+:1002E0000E945300E0910C01F0910D0180910401F6
+:1002F00080838FEFC81AD80AE80AF80AC701B60146
+:100300000E94F7012FE632E143E05BE30E94A9027D
+:1003100020E030E0A9010E948F01C5CF5058BB27D3
+:10032000AA270ED0DCC0CDD030F0D2D020F031F4EE
+:100330009F3F11F41EF4C2C00EF4E095E7FBB8C075
+:10034000E92FDED080F3BA17620773078407950799
+:1003500018F071F49EF5F6C00EF4E0950B2EBA2F4E
+:10036000A02D0B01B90190010C01CA01A0011124BB
+:10037000FF27591B99F0593F50F4503E68F11A1667
+:10038000F040A22F232F342F4427585FF3CF4695F8
+:1003900037952795A795F0405395C9F77EF41F161A
+:1003A000BA0B620B730B840BBAF09150A1F0FF0FE4
+:1003B000BB1F661F771F881FC2F70EC0BA0F621FD0
+:1003C000731F841F48F4879577956795B795F795C0
+:1003D0009E3F08F0B3CF9395880F08F09927EE0F52
+:1003E00097958795089540D008F481E00895E894A2
+:1003F00009C097FB3EF490958095709561957F4F6D
+:100400008F4F9F4F9923A9F0F92F96E9BB2793951A
+:10041000F695879577956795B795F111F8CFFAF42A
+:10042000BB0F11F460FF1BC06F5F7F4F8F4F9F4F5B
+:1004300016C0882311F096E911C0772321F09EE8B9
+:10044000872F762F05C0662371F096E8862F70E01F
+:1004500060E02AF09A95660F771F881FDAF7880FF9
+:100460009695879597F90895990F0008550FAA0B4F
+:10047000E0E8FEEF16161706E807F907C0F01216B7
+:100480001306E407F50798F0621B730B840B950BBA
+:1004900039F40A2661F0232B242B252B21F408950F
+:1004A0000A2609F4A140A6958FEF811D811D0895AC
+:1004B00097F99F6780E870E060E008959FEF80EC17
+:1004C000089500240A9416161706180609060895BA
+:1004D00000240A9412161306140605060895092E20
+:1004E0000394000C11F4882352F0BB0F40F4BF2B8F
+:1004F00011F460FF04C06F5F7F4F8F4F9F4F0895CF
+:1005000057FD9058440F551F59F05F3F71F04795C4
+:10051000880F97FB991F61F09F3F79F087950895A9
+:10052000121613061406551FF2CF4695F1DF08C0C8
+:10053000161617061806991FF1CF869571056105E5
+:1005400008940895E894BB2766277727CB0197F98D
+:1005500008950BD0C4CFB5DF28F0BADF18F095238B
+:1005600009F0A6CFABCF1124EECFCADFA0F3959F41
+:10057000D1F3950F50E0551F629FF001729FBB278A
+:10058000F00DB11D639FAA27F00DB11DAA1F649F36
+:100590006627B00DA11D661F829F2227B00DA11DE9
+:1005A000621F739FB00DA11D621F839FA00D611D6F
+:1005B000221F749F3327A00D611D231F849F600D90
+:1005C000211D822F762F6A2F11249F5750408AF0C9
+:1005D000E1F088234AF0EE0FFF1FBB1F661F771F55
+:1005E000881F91505040A9F79E3F510570F060CF91
+:1005F000AACF5F3FECF3983EDCF38695779567953D
+:10060000B795F795E7959F5FC1F7FE2B880F911D72
+:0C0610009695879597F90895F894FFCF10
+:10061C0000000000FF000AD7233C0000000000008F
+:02062C000000CC
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.sh
new file mode 100755
index 0000000..9ef5c4d
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_dcmotor_clock.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_dcmotor_clock.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections dcmotor_clock_main.c -o dcmotor_clock -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom dcmotor_clock dcmotor_clock.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:dcmotor_clock.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock_main.c
new file mode 100755
index 0000000..ae3eff7
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_clock_main.c
@@ -0,0 +1,213 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct dcmotor_clock_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct dcmotor_clock_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[4];
+} dcmotor_clock_fmi2Component;
+
+dcmotor_clock_fmi2Component dcmotor_clock_component = {
+ .fmi2IntegerVars = {
+ 255 /*pwm._u[1]*/,
+ },
+ .fmi2RealParameter = {
+ 0.01 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component dcmotor_clock_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &dcmotor_clock_component;
+}
+
+fmi2Status dcmotor_clock_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_clock_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 2, 0, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 10);
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_clock_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status dcmotor_clock_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status dcmotor_clock_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */ = ((comp->currentTime)<(1.0)) ? (255) : (0); /* equation 3 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */);
+}
+
+fmi2Status dcmotor_clock_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ dcmotor_clock_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = dcmotor_clock_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ dcmotor_clock_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ dcmotor_clock_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ dcmotor_clock_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = dcmotor_clock_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop
new file mode 100755
index 0000000..36d8f3b
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.hex
new file mode 100755
index 0000000..119035b
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.hex
@@ -0,0 +1,135 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94380134
+:100020000C9451000C9451000C9451000C94070155
+:100030000C9451000C9451000C94D6000C94510077
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E8E3F8E002C0F0
+:1000800005900D92A831B107D9F711E0A8E1B1E0D0
+:1000900001C01D92AD31B107E1F70E94AE010C9491
+:1000A0001A040C940000CF92DF92EF92FF92CF934C
+:1000B000DF93EC01C880D980EA80FB8020E030E04B
+:1000C00040EC50E4C701B6010E9446020E94EB02D8
+:1000D00020E030E040EC50E40E94B7039B01AC010B
+:1000E000C701B6010E94DD016B017C0120E030E018
+:1000F00040E450E40E94420287FF03C08FEF90E08B
+:1001000002C080E090E09D838C8320E030E040E4FA
+:1001100050E4C701B6010E94B30318161CF48FEF18
+:1001200090E002C080E090E09F838E838E899F895B
+:100130008230910561F08330910599F00197C9F4FF
+:1001400016BC80916E00826080936E0016C0109283
+:1001500085001092840080916F00826080936F0010
+:100160000CC01092B2008091700082608093700089
+:1001700004C081E090E00E941A0478949FB7F8943C
+:1001800080911A019FBF8823C9F310921A01EE854E
+:10019000FF858C818083EA89FB898E818083DF9152
+:1001A000CF91FF90EF90DF90CF9008951F920F9224
+:1001B0000FB60F9211242F933F938F939F938091AB
+:1001C00018019091190101969093190180931801DB
+:1001D00080911A01813091F020911801309119011C
+:1001E00080911B0190911C012817390738F081E09C
+:1001F00080931A0110921901109218019F918F910A
+:100200003F912F910F900FBE0F901F9018951F9246
+:100210000F920FB60F9211242F933F938F939F93BA
+:100220008091180190911901019690931901809382
+:10023000180180911A01813091F0209118013091BC
+:10024000190180911B0190911C012817390738F082
+:1002500081E080931A0110921901109218019F9168
+:100260008F913F912F910F900FBE0F901F90189577
+:100270001F920F920FB60F9211242F933F938F93DB
+:100280009F93809118019091190101969093190103
+:100290008093180180911A01813091F0209118010A
+:1002A0003091190180911B0190911C012817390789
+:1002B00038F081E080931A01109219011092180110
+:1002C0009F918F913F912F910F900FBE0F901F9094
+:1002D0001895CF93DF93FC01C1E8D0E088818D6051
+:1002E000888382E090E0918B808B229A40E850E0F6
+:1002F000DA012C9121622C932AE830E0D901119681
+:100300001C921E921C92338B228B28812D60288395
+:1003100095878487219ADA012C9121682C93A8E88B
+:10032000B0E011961C921E921C92B787A68725B545
+:10033000236025BD21E030E0358B248B90931C0198
+:1003400080931B0184B5826084BD89EF87BD378BA4
+:10035000268B80E090E0DF91CF910895CF92DF92DD
+:10036000EF92FF9280E091E00E946901C12CD12CB4
+:10037000760160E070E0CB016093000170930101B1
+:10038000809302019093030180E091E00E9453006A
+:100390008FEFC81AD80AE80AF80AC701B6010E9406
+:1003A000AE022FE632E143E05BE30E94B70320E0B8
+:1003B00030E0A9010E94DE01DFCF5058BB27AA27F9
+:1003C0000ED080C171D130F076D120F031F49F3F52
+:1003D00011F41EF466C10EF4E095E7FB33C1E92F7A
+:1003E00082D180F3BA17620773078407950718F064
+:1003F00071F49EF5B1C10EF4E0950B2EBA2FA02D2D
+:100400000B01B90190010C01CA01A0011124FF27C1
+:10041000591B99F0593F50F4503E68F11A16F040BC
+:10042000A22F232F342F4427585FF3CF46953795BB
+:100430002795A795F0405395C9F77EF41F16BA0B80
+:10044000620B730B840BBAF09150A1F0FF0FBB1F2E
+:10045000661F771F881FC2F70EC0BA0F621F731F77
+:10046000841F48F4879577956795B795F7959E3FD4
+:1004700008F0B3CF9395880F08F09927EE0F979562
+:1004800087950895BBD008F481E008950CD01AC177
+:1004900012D140F009D130F021F45F3F19F0D2C001
+:1004A00051115BC1FEC01FD198F39923C9F35523A5
+:1004B000B1F3951B550BBB27AA2762177307840757
+:1004C00038F09F5F5F4F220F331F441FAA1FA9F30D
+:1004D00033D00E2E3AF0E0E830D091505040E695FF
+:1004E000001CCAF729D0FE2F27D0660F771F881F60
+:1004F000BB1F261737074807AB07B0E809F0BB0B4F
+:10050000802DBF01FF2793585F4F2AF09E3F510572
+:1005100068F098C022C15F3FECF3983EDCF386950B
+:1005200077956795B795F7959F5FC9F7880F911DE8
+:100530009695879597F90895E1E0660F771F881FD4
+:10054000BB1F621773078407BA0720F0621B730B87
+:10055000840BBA0BEE1F88F7E0950895E89409C064
+:1005600097FB3EF490958095709561957F4F8F4FE6
+:100570009F4F9923A9F0F92F96E9BB279395F695FC
+:10058000879577956795B795F111F8CFFAF4BB0F7A
+:1005900011F460FF1BC06F5F7F4F8F4F9F4F16C0DE
+:1005A000882311F096E911C0772321F09EE8872F68
+:1005B000762F05C0662371F096E8862F70E060E024
+:1005C0002AF09A95660F771F881FDAF7880F96959D
+:1005D000879597F90895A9D080F09F3740F491113D
+:1005E0000EF0BBC060E070E080E89FEB089526F459
+:1005F0001B16611D711D811D2BC045C0990F000880
+:10060000550FAA0BE0E8FEEF16161706E807F907E4
+:10061000C0F012161306E407F50798F0621B730B7F
+:10062000840B950B39F40A2661F0232B242B252B00
+:1006300021F408950A2609F4A140A6958FEF811DA3
+:10064000811D089597F99F6780E870E060E0089544
+:10065000882371F4772321F09850872B762F07C0D9
+:10066000662311F499270DC09051862B70E060E04D
+:100670002AF09A95660F771F881FDAF7880F9695EC
+:10068000879597F908959F3F31F0915020F4879511
+:1006900077956795B795880F911D9695879597F9EA
+:1006A00008959FEF80EC089500240A94161617060B
+:1006B00018060906089500240A9412161306140653
+:1006C00005060895092E0394000C11F4882352F0B6
+:1006D000BB0F40F4BF2B11F460FF04C06F5F7F4F6E
+:1006E0008F4F9F4F089557FD9058440F551F59F055
+:1006F0005F3F71F04795880F97FB991F61F09F3F0F
+:1007000079F087950895121613061406551FF2CF37
+:100710004695F1DF08C0161617061806991FF1CF87
+:1007200086957105610508940895E5DFA0F0BEE7A0
+:10073000B91788F4BB279F3860F41616B11D672FD0
+:10074000782F8827985FF7CF869577956795B11DA5
+:1007500093959639C8F30895E894BB2766277727C1
+:10076000CB0197F908954ADF08F48FEF08950BD075
+:10077000A9CF9ADF28F09FDF18F0952309F062CF08
+:1007800090CF1124EACFAFDFA0F3959FD1F3950F5F
+:1007900050E0551F629FF001729FBB27F00DB11D05
+:1007A000639FAA27F00DB11DAA1F649F6627B00D95
+:1007B000A11D661F829F2227B00DA11D621F739F7E
+:1007C000B00DA11D621F839FA00D611D221F749F8C
+:1007D0003327A00D611D231F849F600D211D822FD3
+:1007E000762F6A2F11249F5750408AF0E1F088231A
+:1007F0004AF0EE0FFF1FBB1F661F771F881F915027
+:100800005040A9F79E3F510570F01CCFA6CF5F3F27
+:10081000ECF3983EDCF3869577956795B795F79559
+:10082000E7959F5FC1F7FE2B880F911D96958795E1
+:0808300097F90895F894FFCF39
+:1008380000000000000000006F12033B00000000F1
+:080848000000000000000000A8
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.sh
new file mode 100755
index 0000000..38ca771
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_dcmotor_loop.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_dcmotor_loop.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections dcmotor_loop_main.c -o dcmotor_loop -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom dcmotor_loop dcmotor_loop.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:dcmotor_loop.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop_main.c
new file mode 100755
index 0000000..581a9d6
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_loop_main.c
@@ -0,0 +1,217 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct dcmotor_loop_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct dcmotor_loop_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[2];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[6];
+} dcmotor_loop_fmi2Component;
+
+dcmotor_loop_fmi2Component dcmotor_loop_component = {
+ .fmi2IntegerVars = {
+ 0 /*pwm._u[1]*/,
+ 0 /*pwm1._u[1]*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component dcmotor_loop_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &dcmotor_loop_component;
+}
+
+fmi2Status dcmotor_loop_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_loop_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[2] /* pwm1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[3] /* pwm1._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[2] /* pwm1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 2, 0, fmi2False);
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status dcmotor_loop_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status dcmotor_loop_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status dcmotor_loop_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */ = ((om_mod(comp->currentTime,6.0))<(3.0)) ? (255) : (0); /* equation 4 */
+ comp->fmi2IntegerVars[1] /* pwm1._u[1] DISCRETE */ = ((om_mod(comp->currentTime,6.0))>(3.0)) ? (255) : (0); /* equation 5 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[3] /* pwm1._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[1] /* pwm1._u[1] DISCRETE */);
+}
+
+fmi2Status dcmotor_loop_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ dcmotor_loop_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = dcmotor_loop_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ dcmotor_loop_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ dcmotor_loop_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ dcmotor_loop_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = dcmotor_loop_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_both.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_both.mos
new file mode 100755
index 0000000..c776b9a
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_both.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_dcmotor.MDD_dcmotor_both, fileNamePrefix="dcmotor_both");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_clock.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_clock.mos
new file mode 100755
index 0000000..4f2e6ed
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_clock.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_dcmotor.MDD_dcmotor_clock, fileNamePrefix="dcmotor_clock");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_loop.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_loop.mos
new file mode 100755
index 0000000..05800fc
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/runMDD_dcmotor_loop.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_dcmotor.MDD_dcmotor_loop, fileNamePrefix="dcmotor_loop");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led
new file mode 100755
index 0000000..08ef23c
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.hex
new file mode 100755
index 0000000..cc58777
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.hex
@@ -0,0 +1,120 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C9431013B
+:100020000C9451000C9451000C9451000C9400015C
+:100030000C9451000C9451000C94CF000C9451007E
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E4E4F7E002C0F4
+:1000800005900D92AE31B107D9F711E0AEE1B1E0C4
+:1000900001C01D92A332B107E1F70E948B010C94BD
+:1000A000A0030C9400000F931F93CF93DF93EC01F8
+:1000B00080917C00857E856080937C0080917A00B1
+:1000C000806480937A0080917A0086FDFCCF6091F5
+:1000D00078007091790080E090E00E94870220E033
+:1000E00030E040E854E40E94190320E030EC4FE790
+:1000F00054E40E941F026C837D838E839F8301E002
+:1001000010E02E853F85488959890E9415031816ED
+:1001100014F000E010E01D870C878C8D9D8D8230DF
+:10012000910561F08330910599F00197C9F416BCEF
+:1001300080916E00826080936E0016C010928500E0
+:100140001092840080916F00826080936F000CC0D9
+:100150001092B2008091700082608093700004C0A1
+:1001600081E090E00E94A00378949FB7F89480917A
+:1001700020019FBF8823C9F310922001E88DF98DDB
+:100180008C859D85892B19F08081826002C08081D9
+:100190008D7F8083DF91CF911F910F9108951F92E2
+:1001A0000F920FB60F9211242F933F938F939F932B
+:1001B00080911E0190911F01019690931F018093E1
+:1001C0001E0180912001813091F020911E0130911B
+:1001D0001F0180912101909122012817390738F0E1
+:1001E00081E08093200110921F0110921E019F91C7
+:1001F0008F913F912F910F900FBE0F901F901895E8
+:100200001F920F920FB60F9211242F933F938F934B
+:100210009F9380911E0190911F01019690931F0161
+:1002200080931E0180912001813091F020911E0168
+:1002300030911F01809121019091220128173907E7
+:1002400038F081E08093200110921F0110921E016E
+:100250009F918F913F912F910F900FBE0F901F9004
+:1002600018951F920F920FB60F9211242F933F9360
+:100270008F939F9380911E0190911F0101969093FF
+:100280001F0180931E0180912001813091F0209107
+:100290001E0130911F0180912101909122012817A8
+:1002A000390738F081E08093200110921F011092ED
+:1002B0001E019F918F913F912F910F900FBE0F9034
+:1002C0001F901895FC01ACE7B0E08C91806C8C938A
+:1002D000AAE7B0E08C9187688C93178A168A219AD6
+:1002E00085E290E0918F808F85B5836085BD81E048
+:1002F00090E0938F828F22E030E0309322012093B0
+:10030000210124B5226024BD29EF27BD958F848F5C
+:1003100080E090E00895CF92DF92EF92FF9280E02C
+:1003200091E00E946201C12CD12C760160E070E066
+:10033000CB016093000170930101809302019093BF
+:10034000030180E091E00E9453008FEFC81AD80AA1
+:10035000E80AF80AC701B6010E9487022FE632E1D7
+:1003600043E05BE30E94190320E030E0A9010E9412
+:10037000BB01DFCF5058BB27AA270ED01CC10DD11F
+:1003800030F012D120F031F49F3F11F41EF402C17D
+:100390000EF4E095E7FBF8C0E92F1ED180F3BA1701
+:1003A000620773078407950718F071F49EF536C14C
+:1003B0000EF4E0950B2EBA2FA02D0B01B901900180
+:1003C0000C01CA01A0011124FF27591B99F0593FC4
+:1003D00050F4503E68F11A16F040A22F232F342F0C
+:1003E0004427585FF3CF469537952795A795F0405A
+:1003F0005395C9F77EF41F16BA0B620B730B840B6F
+:10040000BAF09150A1F0FF0FBB1F661F771F881F26
+:10041000C2F70EC0BA0F621F731F841F48F487957E
+:1004200077956795B795F7959E3F08F0B3CF93956D
+:10043000880F08F09927EE0F9795879508950CD0AF
+:10044000BAC0B2D040F0A9D030F021F45F3F19F02B
+:100450009BC05111E4C09EC0BFD098F39923C9F34B
+:100460005523B1F3951B550BBB27AA2762177307BA
+:10047000840738F09F5F5F4F220F331F441FAA1F6E
+:10048000A9F333D00E2E3AF0E0E830D0915050402E
+:10049000E695001CCAF729D0FE2F27D0660F771FDC
+:1004A000881FBB1F261737074807AB07B0E809F0BE
+:1004B000BB0B802DBF01FF2793585F4F2AF09E3F53
+:1004C000510568F061C0ABC05F3FECF3983EDCF3D0
+:1004D000869577956795B795F7959F5FC9F7880FCC
+:1004E000911D9695879597F90895E1E0660F771F1E
+:1004F000881FBB1F621773078407BA0720F0621BAF
+:10050000730B840BBA0BEE1F88F7E0950895E894FF
+:1005100009C097FB3EF490958095709561957F4F4B
+:100520008F4F9F4F9923A9F0F92F96E9BB279395F9
+:10053000F695879577956795B795F111F8CFFAF409
+:10054000BB0F11F460FF1BC06F5F7F4F8F4F9F4F3A
+:1005500016C0882311F096E911C0772321F09EE898
+:10056000872F762F05C0662371F096E8862F70E0FE
+:1005700060E02AF09A95660F771F881FDAF7880FD8
+:100580009695879597F9089597F99F6780E870E0A9
+:1005900060E008959FEF80EC089500240A941616F9
+:1005A000170618060906089500240A941216130661
+:1005B000140605060895092E0394000C11F48823EF
+:1005C00052F0BB0F40F4BF2B11F460FF04C06F5F0B
+:1005D0007F4F8F4F9F4F089557FD9058440F551FE1
+:1005E00059F05F3F71F04795880F97FB991F61F0B5
+:1005F0009F3F79F087950895121613061406551F2C
+:10060000F2CF4695F1DF08C0161617061806991F97
+:10061000F1CF86957105610508940895E894BB278C
+:1006200066277727CB0197F9089566D008F48FEFF6
+:1006300008950BD0C0CFB1DF28F0B6DF18F09523B6
+:1006400009F0A2CFA7CF1124EACFC6DFA0F3959F70
+:10065000D1F3950F50E0551F629FF001729FBB27A9
+:10066000F00DB11D639FAA27F00DB11DAA1F649F55
+:100670006627B00DA11D661F829F2227B00DA11D08
+:10068000621F739FB00DA11D621F839FA00D611D8E
+:10069000221F749F3327A00D611D231F849F600DAF
+:1006A000211D822F762F6A2F11249F5750408AF0E8
+:1006B000E1F088234AF0EE0FFF1FBB1F661F771F74
+:1006C000881F91505040A9F79E3F510570F05CCFB4
+:1006D000A6CF5F3FECF3983EDCF386957795679560
+:1006E000B795F795E7959F5FC1F7FE2B880F911D92
+:1006F0009695879597F90895990F0008550FAA0BBD
+:10070000E0E8FEEF16161706E807F907C0F0121624
+:100710001306E407F50798F0621B730B840B950B27
+:1007200039F40A2661F0232B242B252B21F408957C
+:100730000A2609F4A140A6958FEF811D811D089519
+:04074000F894FFCF5B
+:1007440000000000000000000000000000000000A5
+:0E07540016446F12033B00000000000000007E
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.sh
new file mode 100755
index 0000000..d968dcb
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_ldr_led.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_ldr_led.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections ldr_led_main.c -o ldr_led -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom ldr_led ldr_led.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:ldr_led.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led_main.c
new file mode 100755
index 0000000..3b4bcd7
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_led_main.c
@@ -0,0 +1,243 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct ldr_led_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct ldr_led_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Real fmi2RealVars[1];
+ fmi2Boolean fmi2BooleanVars[3];
+ fmi2Real fmi2RealParameter[2];
+ void* extObjs[4];
+} ldr_led_fmi2Component;
+
+ldr_led_fmi2Component ldr_led_component = {
+ .fmi2RealVars = {
+ 0.0 /*adc._y*/,
+ },
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ fmi2False /*booleanExpression2._y*/,
+ fmi2False /*digitalWriteBoolean1._u*/,
+ },
+ .fmi2RealParameter = {
+ 600.0 /*greaterThreshold1._threshold*/,
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+static const char * const OMCLIT0 = "ElectricPotential";
+static const char * const OMCLIT1 = "V";
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+#include "MDDAVRAnalog.h"
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution)
+{
+ fmi2Real om_value;
+ om_value = MDD_avr_analog_read(om_analogPort, om_vref, om_voltageResolution);
+ return om_value;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage)
+{
+ void* om_avr;
+ om_avr = MDD_avr_analog_init(om_divisionFactor, om_referenceVoltage);
+ return om_avr;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr)
+{
+ MDD_avr_analog_close(om_avr);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component ldr_led_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &ldr_led_component;
+}
+
+fmi2Status ldr_led_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status ldr_led_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* adc._analog EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Analog.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(comp, 7, 4);
+ comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status ldr_led_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status ldr_led_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status ldr_led_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2RealVars[0] /* adc._y variable */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(comp, 6, 1024.0, 10); /* equation 6 */
+ comp->fmi2BooleanVars[2] /* digitalWriteBoolean1._u DISCRETE */ = (comp->fmi2RealVars[0] /* adc._y variable */)>(comp->fmi2RealParameter[0] /* greaterThreshold1._threshold PARAM */); /* equation 7 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[2] /* digitalWriteBoolean1._u DISCRETE */);
+}
+
+fmi2Status ldr_led_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ ldr_led_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = ldr_led_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ ldr_led_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ ldr_led_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ ldr_led_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = ldr_led_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_read.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_read.sh
new file mode 100755
index 0000000..d465596
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/ldr_read.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_ldr_read.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_ldr_read.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections ldr_read_main.c -o ldr_read -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom ldr_read ldr_read.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:ldr_read.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_led.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_led.mos
new file mode 100755
index 0000000..76aef31
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_led.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_ldr.MDD_ldr_led, fileNamePrefix="ldr_led");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_read.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_read.mos
new file mode 100755
index 0000000..76aef31
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/ldr/runMDD_ldr_read.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_ldr.MDD_ldr_led, fileNamePrefix="ldr_led");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink
new file mode 100755
index 0000000..3953004
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.hex
new file mode 100755
index 0000000..89858ca
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.hex
@@ -0,0 +1,114 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C942A0142
+:100020000C9451000C9451000C9451000C94F90064
+:100030000C9451000C9451000C94C8000C94510085
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E4EFF6E002C0EA
+:1000800005900D92A031B107D9F711E0A0E1B1E0E0
+:1000900001C01D92A531B107E1F70E9478010C94CF
+:1000A00078030C940000CF92DF92EF92FF920F93AF
+:1000B0001F93CF93DF93EC01C880D980EA80FB8047
+:1000C00020E030E040E05FE3C701B6010E94F102AA
+:1000D0000E9449029B01AC010E94A8019B01AC0156
+:1000E000C701B6010E94A70101E010E020E030E066
+:1000F00040E85FE30E94ED0287FF02C000E010E0ED
+:100100001D830C838E859F858230910561F083303D
+:10011000910599F00197C9F416BC80916E00826038
+:1001200080936E0016C0109285001092840080911A
+:100130006F00826080936F000CC01092B2008091BB
+:10014000700082608093700004C081E090E00E94A3
+:10015000780378949FB7F894809112019FBF882309
+:10016000C9F310921201EA85FB858C819D81892B50
+:1001700019F08081806202C080818F7D8083DF9151
+:10018000CF911F910F91FF90EF90DF90CF90089546
+:100190001F920F920FB60F9211242F933F938F93BC
+:1001A0009F938091100190911101019690931101FC
+:1001B0008093100180911201813091F02091100103
+:1001C0003091110180911301909114012817390782
+:1001D00038F081E080931201109211011092100109
+:1001E0009F918F913F912F910F900FBE0F901F9075
+:1001F00018951F920F920FB60F9211242F933F93D1
+:100200008F939F938091100190911101019690938B
+:1002100011018093100180911201813091F02091A1
+:100220001001309111018091130190911401281750
+:10023000390738F081E08093120110921101109279
+:1002400010019F918F913F912F910F900FBE0F90B2
+:100250001F9018951F920F920FB60F9211242F9393
+:100260003F938F939F93809110019091110101967C
+:10027000909311018093100180911201813091F0CF
+:10028000209110013091110180911301909114017E
+:100290002817390738F081E080931201109211017C
+:1002A000109210019F918F913F912F910F900FBE4F
+:1002B0000F901F901895FC0185B5836085BD81E086
+:1002C00090E09587848722E030E0309314012093FA
+:1002D000130124B5226024BD29EF27BD97878687A7
+:1002E000259A85E290E09387828780E090E00895E8
+:1002F000CF92DF92EF92FF9280E091E00E945B014B
+:10030000C12CD12C760160E070E0CB01609300013C
+:1003100070930101809302019093030180E091E0CA
+:100320000E9453008FEFC81AD80AE80AF80AC701DA
+:10033000B6010E940C022FE632E143E05BE30E942B
+:10034000F10220E030E0A9010E94A801DFCF50585F
+:10035000BB27AA270ED0F0C0E1D030F0E6D020F0C5
+:1003600031F49F3F11F41EF4D6C00EF4E095E7FB84
+:10037000A3C0E92FF2D080F3BA176207730784078E
+:10038000950718F071F49EF521C10EF4E0950B2E3F
+:10039000BA2FA02D0B01B90190010C01CA01A001D7
+:1003A0001124FF27591B99F0593F50F4503E68F132
+:1003B0001A16F040A22F232F342F4427585FF3CF73
+:1003C000469537952795A795F0405395C9F77EF444
+:1003D0001F16BA0B620B730B840BBAF09150A1F08D
+:1003E000FF0FBB1F661F771F881FC2F70EC0BA0F13
+:1003F000621F731F841F48F4879577956795B7959B
+:10040000F7959E3F08F0B3CF9395880F08F0992792
+:10041000EE0F979587950895E89409C097FB3EF4F1
+:1004200090958095709561957F4F8F4F9F4F992341
+:10043000A9F0F92F96E9BB279395F69587957795BF
+:100440006795B795F111F8CFFAF4BB0F11F460FF7F
+:100450001BC06F5F7F4F8F4F9F4F16C0882311F0D7
+:1004600096E911C0772321F09EE8872F762F05C0EB
+:10047000662371F096E8862F70E060E02AF09A9586
+:10048000660F771F881FDAF7880F9695879597F97B
+:10049000089585D080F09F3740F491110EF097C0F9
+:1004A00060E070E080E89FEB089526F41B16611D64
+:1004B000711D811D07C021C097F99F6780E870E01A
+:1004C00060E00895882371F4772321F09850872BFA
+:1004D000762F07C0662311F499270DC09051862B03
+:1004E00070E060E02AF09A95660F771F881FDAF7B0
+:1004F000880F9695879597F908959F3F31F0915011
+:1005000020F4879577956795B795880F911D9695F7
+:10051000879597F908959FEF80EC089500240A9439
+:100520001616170618060906089500240A941216CE
+:100530001306140605060895092E0394000C11F401
+:10054000882352F0BB0F40F4BF2B11F460FF04C0AE
+:100550006F5F7F4F8F4F9F4F089557FD9058440F07
+:10056000551F59F05F3F71F04795880F97FB991F12
+:1005700061F09F3F79F087950895121613061406CF
+:10058000551FF2CF4695F1DF08C01616170618065C
+:10059000991FF1CF86957105610508940895E5DFEF
+:1005A000A0F0BEE7B91788F4BB279F3860F4161691
+:1005B000B11D672F782F8827985FF7CF869577959D
+:1005C0006795B11D93959639C8F30895E894BB27B4
+:1005D00066277727CB0197F9089566D008F48FEF47
+:1005E00008950BD0A9CF9ADF28F09FDF18F095234C
+:1005F00009F062CF90CF1124EACFAFDFA0F3959F2F
+:10060000D1F3950F50E0551F629FF001729FBB27F9
+:10061000F00DB11D639FAA27F00DB11DAA1F649FA5
+:100620006627B00DA11D661F829F2227B00DA11D58
+:10063000621F739FB00DA11D621F839FA00D611DDE
+:10064000221F749F3327A00D611D231F849F600DFF
+:10065000211D822F762F6A2F11249F5750408AF038
+:10066000E1F088234AF0EE0FFF1FBB1F661F771FC4
+:10067000881F91505040A9F79E3F510570F01CCF44
+:10068000A6CF5F3FECF3983EDCF3869577956795B0
+:10069000B795F795E7959F5FC1F7FE2B880F911DE2
+:1006A0009695879597F90895990F0008550FAA0B0D
+:1006B000E0E8FEEF16161706E807F907C0F0121675
+:1006C0001306E407F50798F0621B730B840B950B78
+:1006D00039F40A2661F0232B242B252B21F40895CD
+:1006E0000A2609F4A140A6958FEF811D811D08956A
+:0406F000F894FFCFAC
+:1006F4000000000000006F12033B00000000000037
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.sh
new file mode 100755
index 0000000..cd9e818
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_blink.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_blink.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_blink_main.c -o led_blink -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_blink led_blink.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_blink.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink_main.c
new file mode 100755
index 0000000..bcf2661
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blink_main.c
@@ -0,0 +1,212 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_blink_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_blink_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[3];
+} led_blink_fmi2Component;
+
+led_blink_fmi2Component led_blink_component = {
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_blink_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_blink_component;
+}
+
+fmi2Status led_blink_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_blink_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 6);
+ return fmi2OK;
+}
+
+fmi2Status led_blink_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_blink_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_blink_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */ = (om_mod(comp->currentTime,2.0))>=(1.0); /* equation 3 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 6, comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */);
+}
+
+fmi2Status led_blink_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_blink_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_blink_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_blink_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_blink_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_blink_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_blink_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue
new file mode 100755
index 0000000..75a1347
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.hex
new file mode 100755
index 0000000..05d7448
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.hex
@@ -0,0 +1,93 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E50088
+:100020000C9451000C9451000C9451000C94B400A9
+:100030000C9451000C9451000C9483000C945100CA
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0EAEAF5E002C0EA
+:1000800005900D92A031B107D9F721E0A0E1B1E0D0
+:1000900001C01D92A531B207E1F70E9433010C9413
+:1000A000D3020C9400008230910561F083309105F9
+:1000B00099F00197C9F416BC80916E00826080931C
+:1000C0006E0016C0109285001092840080916F001F
+:1000D000826080936F000CC01092B200809170001B
+:1000E00082608093700004C081E090E00E94D3029F
+:1000F00078949FB7F894809112019FBF8823C9F329
+:100100001092120108951F920F920FB60F921124B0
+:100110002F933F938F939F938091100190911101A2
+:10012000019690931101809310018091120181300A
+:1001300091F0209110013091110180911301909163
+:1001400014012817390738F081E0809312011092CA
+:100150001101109210019F918F913F912F910F905B
+:100160000FBE0F901F9018951F920F920FB60F920F
+:1001700011242F933F938F939F938091100190911F
+:100180001101019690931101809310018091120149
+:10019000813091F020911001309111018091130173
+:1001A000909114012817390738F081E080931201EB
+:1001B00010921101109210019F918F913F912F91F8
+:1001C0000F900FBE0F901F9018951F920F920FB6B1
+:1001D0000F9211242F933F938F939F93809110013F
+:1001E00090911101019690931101809310018091DB
+:1001F0001201813091F02091100130911101809114
+:100200001301909114012817390738F081E0809389
+:10021000120110921101109210019F918F913F9144
+:100220002F910F900FBE0F901F901895FC01219AEF
+:1002300085E290E09387828785B5836085BD21E064
+:1002400030E03587248782E090E09093140180931A
+:10025000130184B5826084BD89EF87BD3787268707
+:1002600080E090E00895CF92DF92EF92FF9280E0DD
+:1002700091E00E941601C12CD12C760160E070E063
+:10028000CB01609300017093010180930201909370
+:10029000030180910E0190910F010E945300E091A3
+:1002A0000A01F0910B018081826080838FEFC81A70
+:1002B000D80AE80AF80AC701B6010E94D8012FE659
+:1002C00032E143E05BE30E94660220E030E0A901F6
+:1002D0000E946C01D6CF5058BB27AA270E948301E9
+:1002E0000C942C020E941E0238F00E94250220F07D
+:1002F00039F49F3F19F426F40C941B020EF4E09598
+:10030000E7FB0C941502E92F0E943D0258F3BA173F
+:10031000620773078407950720F079F4A6F50C941B
+:100320005F020EF4E0950B2EBA2FA02D0B01B90140
+:1003300090010C01CA01A0011124FF27591B99F05B
+:10034000593F50F4503E68F11A16F040A22F232F67
+:10035000342F4427585FF3CF469537952795A795B7
+:10036000F0405395C9F77EF41F16BA0B620B730B5E
+:10037000840BBAF09150A1F0FF0FBB1F661F771FCF
+:10038000881FC2F70EC0BA0F621F731F841F48F484
+:10039000879577956795B795F7959E3F08F0B0CF0D
+:1003A0009395880F08F09927EE0F979587950895F4
+:1003B000E89409C097FB3EF49095809570956195FF
+:1003C0007F4F8F4F9F4F9923A9F0F92F96E9BB27B5
+:1003D0009395F695879577956795B795F111F8CF31
+:1003E000FAF4BB0F11F460FF1BC06F5F7F4F8F4F9C
+:1003F0009F4F16C0882311F096E911C0772321F092
+:100400009EE8872F762F05C0662371F096E8862F29
+:1004100070E060E02AF09A95660F771F881FDAF780
+:10042000880F9695879597F9089597F99F6780E8C3
+:1004300070E060E008959FEF80EC089500240A9436
+:100440001616170618060906089500240A941216AF
+:100450001306140605060895092E0394000C11F4E2
+:10046000882352F0BB0F40F4BF2B11F460FF04C08F
+:100470006F5F7F4F8F4F9F4F089557FD9058440FE8
+:10048000551F59F05F3F71F04795880F97FB991FF3
+:1004900061F09F3F79F087950895121613061406B0
+:1004A000551FF2CF4695F1DF08C01616170618063D
+:1004B000991FF1CF86957105610508940895E89418
+:1004C000BB2766277727CB0197F908950E94790209
+:1004D0000C942C020E941E0238F00E94250220F08B
+:1004E000952311F00C9415020C941B0211240C940A
+:1004F00060020E943D0270F3959FC1F3950F50E09A
+:10050000551F629FF001729FBB27F00DB11D639FC5
+:10051000AA27F00DB11DAA1F649F6627B00DA11D6B
+:10052000661F829F2227B00DA11D621F739FB00D11
+:10053000A11D621F839FA00D611D221F749F332781
+:10054000A00D611D231F849F600D211D822F762F1A
+:100550006A2F11249F5750409AF0F1F088234AF0F7
+:10056000EE0FFF1FBB1F661F771F881F9150504063
+:10057000A9F79E3F510580F00C9415020C9460027F
+:100580005F3FE4F3983ED4F3869577956795B795EA
+:10059000F795E7959F5FC1F7FE2B880F911D969504
+:0A05A000879597F90895F894FFCFAE
+:1005AA000000000000006F12033B00000000000082
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.sh
new file mode 100755
index 0000000..b2a9b7d
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_blue.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_blue.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_blue_main.c -o led_blue -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_blue led_blue.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_blue.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay
new file mode 100755
index 0000000..154b3fe
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.hex
new file mode 100755
index 0000000..eaa1eaa
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.hex
@@ -0,0 +1,100 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C940E015E
+:100020000C9451000C9451000C9451000C94DD0080
+:100030000C9451000C9451000C94AC000C945100A1
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E6E1F6E002C0F6
+:1000800005900D92A031B107D9F711E0A0E1B1E0E0
+:1000900001C01D92A531B107E1F70E945C010C94EB
+:1000A00009030C9400000F931F93CF93DF93EC018F
+:1000B00001E010E020E030E040EA50E4688179811E
+:1000C0008A819B810E94F00187FD02C000E010E060
+:1000D0001D830C838E859F858230910561F083306E
+:1000E000910599F00197C9F416BC80916E00826069
+:1000F00080936E0016C0109285001092840080914B
+:100100006F00826080936F000CC01092B2008091EB
+:10011000700082608093700004C081E090E00E94D3
+:10012000090378949FB7F894809112019FBF8823A8
+:10013000C9F310921201EA85FB858C819D81892B80
+:1001400019F08081826002C080818D7F8083DF9181
+:10015000CF911F910F9108951F920F920FB60F929A
+:1001600011242F933F938F939F938091100190912F
+:100170001101019690931101809310018091120159
+:10018000813091F020911001309111018091130183
+:10019000909114012817390738F081E080931201FB
+:1001A00010921101109210019F918F913F912F9108
+:1001B0000F900FBE0F901F9018951F920F920FB6C1
+:1001C0000F9211242F933F938F939F93809110014F
+:1001D00090911101019690931101809310018091EB
+:1001E0001201813091F02091100130911101809124
+:1001F0001301909114012817390738F081E080939A
+:10020000120110921101109210019F918F913F9154
+:100210002F910F900FBE0F901F9018951F920F9265
+:100220000FB60F9211242F933F938F939F9380913A
+:10023000100190911101019690931101809310018A
+:1002400080911201813091F02091100130911101C3
+:1002500080911301909114012817390738F081E03B
+:100260008093120110921101109210019F918F91B1
+:100270003F912F910F900FBE0F901F901895FC018A
+:10028000219A85E290E09387828785B5836085BD5A
+:1002900081E090E09587848722E030E0309314017C
+:1002A0002093130124B5226024BD29EF27BD978731
+:1002B000868780E090E00895CF92DF92EF92FF92E0
+:1002C00080E091E00E943F01C12CD12C760160E0DA
+:1002D00070E0CB01609300017093010180930201F3
+:1002E0009093030180E091E00E9453008FEFC81AC1
+:1002F000D80AE80AF80AC701B6010E94F4012FE6FD
+:1003000032E143E05BE30E94A60220E030E0A90175
+:100310000E948C01DFCF5058BB27AA270ED0DCC02B
+:10032000CDD030F0D2D020F031F49F3F11F41EF444
+:10033000C2C00EF4E095E7FBB8C0E92FDED080F331
+:10034000BA17620773078407950718F071F49EF5D2
+:10035000F6C00EF4E0950B2EBA2FA02D0B01B901BB
+:1003600090010C01CA01A0011124FF27591B99F02B
+:10037000593F50F4503E68F11A16F040A22F232F37
+:10038000342F4427585FF3CF469537952795A79587
+:10039000F0405395C9F77EF41F16BA0B620B730B2E
+:1003A000840BBAF09150A1F0FF0FBB1F661F771F9F
+:1003B000881FC2F70EC0BA0F621F731F841F48F454
+:1003C000879577956795B795F7959E3F08F0B3CFDA
+:1003D0009395880F08F09927EE0F979587950895C4
+:1003E00040D008F481E00895E89409C097FB3EF4FA
+:1003F00090958095709561957F4F8F4F9F4F992372
+:10040000A9F0F92F96E9BB279395F69587957795EF
+:100410006795B795F111F8CFFAF4BB0F11F460FFAF
+:100420001BC06F5F7F4F8F4F9F4F16C0882311F007
+:1004300096E911C0772321F09EE8872F762F05C01B
+:10044000662371F096E8862F70E060E02AF09A95B6
+:10045000660F771F881FDAF7880F9695879597F9AB
+:100460000895990F0008550FAA0BE0E8FEEF161645
+:100470001706E807F907C0F012161306E407F50798
+:1004800098F0621B730B840B950B39F40A2661F00C
+:10049000232B242B252B21F408950A2609F4A140AF
+:1004A000A6958FEF811D811D089597F99F6780E8BC
+:1004B00070E060E008959FEF80EC089500240A94B6
+:1004C0001616170618060906089500240A9412162F
+:1004D0001306140605060895092E0394000C11F462
+:1004E000882352F0BB0F40F4BF2B11F460FF04C00F
+:1004F0006F5F7F4F8F4F9F4F089557FD9058440F68
+:10050000551F59F05F3F71F04795880F97FB991F72
+:1005100061F09F3F79F0879508951216130614062F
+:10052000551FF2CF4695F1DF08C0161617061806BC
+:10053000991FF1CF86957105610508940895E89497
+:10054000BB2766277727CB0197F908950BD0C4CF37
+:10055000B5DF28F0BADF18F0952309F0A6CFABCFAE
+:100560001124EECFCADFA0F3959FD1F3950F50E091
+:10057000551F629FF001729FBB27F00DB11D639F55
+:10058000AA27F00DB11DAA1F649F6627B00DA11DFB
+:10059000661F829F2227B00DA11D621F739FB00DA1
+:1005A000A11D621F839FA00D611D221F749F332711
+:1005B000A00D611D231F849F600D211D822F762FAA
+:1005C0006A2F11249F5750408AF0E1F088234AF0A7
+:1005D000EE0FFF1FBB1F661F771F881F91505040F3
+:1005E000A9F79E3F510570F060CFAACF5F3FECF3B3
+:1005F000983EDCF3869577956795B795F795E795DF
+:100600009F5FC1F7FE2B880F911D9695879597F9EF
+:060610000895F894FFCFED
+:100616000000000001006F12033B00000000000014
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.sh
new file mode 100755
index 0000000..53c7838
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_blue_delay.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_blue_delay.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_blue_delay_main.c -o led_blue_delay -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_blue_delay led_blue_delay.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_blue_delay.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay_main.c
new file mode 100755
index 0000000..80930a6
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_delay_main.c
@@ -0,0 +1,212 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_blue_delay_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_blue_delay_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[3];
+} led_blue_delay_fmi2Component;
+
+led_blue_delay_fmi2Component led_blue_delay_component = {
+ .fmi2BooleanVars = {
+ fmi2True /*booleanExpression1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_blue_delay_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_blue_delay_component;
+}
+
+fmi2Status led_blue_delay_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_blue_delay_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status led_blue_delay_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_blue_delay_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_blue_delay_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */ = (comp->currentTime)<(5.0); /* equation 3 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */);
+}
+
+fmi2Status led_blue_delay_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_blue_delay_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_blue_delay_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_blue_delay_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_blue_delay_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_blue_delay_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_blue_delay_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_main.c
new file mode 100755
index 0000000..048f6c8
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_main.c
@@ -0,0 +1,212 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_blue_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_blue_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[3];
+} led_blue_fmi2Component;
+
+led_blue_fmi2Component led_blue_component = {
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_blue_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_blue_component;
+}
+
+fmi2Status led_blue_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_blue_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status led_blue_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_blue_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_blue_functionOutputs(fmi2Component comp)
+{
+ Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, fmi2True);
+}
+
+fmi2Status led_blue_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_blue_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_blue_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_blue_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_blue_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_blue_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_blue_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red
new file mode 100755
index 0000000..c608b41
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.hex
new file mode 100755
index 0000000..e95094d
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.hex
@@ -0,0 +1,108 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94340138
+:100020000C9451000C9451000C9451000C94030159
+:100030000C9451000C9451000C94D2000C9451007B
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0EEE8F6E002C0E7
+:1000800005900D92A431B107D9F721E0A4E1B1E0C8
+:1000900001C01D92A931B207E1F70E9485010C94BD
+:1000A00045030C940000CF92DF92EF92FF920F93E2
+:1000B0001F93CF93DF93EC01C880D980EA80FB8047
+:1000C00001E010E020E030E040EA50E4C701B60172
+:1000D0000E94210287FD02C000E010E01D830C8316
+:1000E00001E010E020E030E040E051E4C701B6015B
+:1000F0000E94210287FD02C000E010E01F830E83F2
+:100100008A899B898230910561F08330910599F04D
+:100110000197C9F416BC80916E00826080936E00D6
+:1001200016C0109285001092840080916F0082604A
+:1001300080936F000CC01092B200809170008260BA
+:100140008093700004C081E090E00E9445037894A1
+:100150009FB7F894809116019FBF8823C9F310922E
+:100160001601EC85FD858C819D81892B19F080819C
+:10017000826002C080818D7F8083EE85FF858E81C5
+:100180009F81892B19F08081886002C08081877FE0
+:100190008083DF91CF911F910F91FF90EF90DF90BF
+:1001A000CF9008951F920F920FB60F9211242F93A4
+:1001B0003F938F939F938091140190911501019625
+:1001C000909315018093140180911601813091F074
+:1001D000209114013091150180911701909118011F
+:1001E0002817390738F081E0809316011092150125
+:1001F000109214019F918F913F912F910F900FBEFC
+:100200000F901F9018951F920F920FB60F92112406
+:100210002F933F938F939F93809114019091150199
+:1002200001969093150180931401809116018130FD
+:1002300091F0209114013091150180911701909156
+:1002400018012817390738F081E0809316011092C1
+:100250001501109214019F918F913F912F910F9052
+:100260000FBE0F901F9018951F920F920FB60F920E
+:1002700011242F933F938F939F938091140190911A
+:100280001501019690931501809314018091160138
+:10029000813091F020911401309115018091170166
+:1002A000909118012817390738F081E080931601E2
+:1002B00010921501109214019F918F913F912F91EF
+:1002C0000F900FBE0F901F901895FC01239A25E206
+:1002D00030E03787268785B5836085BD41E050E0F3
+:1002E000518B408B82E090E090931801809317012E
+:1002F00084B5826084BD89EF87BD538B428B219A80
+:100300003587248780E090E00895CF92DF92EF92C6
+:10031000FF9280E091E00E946501C12CD12C760112
+:1003200060E070E0CB016093000170930101809365
+:1003300002019093030180E091E00E9453008FEF4F
+:10034000C81AD80AE80AF80AC701B6010E942602AC
+:100350002FE632E143E05BE30E94D80220E030E088
+:10036000A9010E94B501DFCF5058BB27AA270E94E0
+:10037000CC010C949E020E94900238F00E949702D9
+:1003800020F039F49F3F19F426F40C948D020EF4FA
+:10039000E095E7FB0C948702E92F0E94AF0258F327
+:1003A000BA17620773078407950720F079F4A6F55A
+:1003B0000C94D1020EF4E0950B2EBA2FA02D0B0158
+:1003C000B90190010C01CA01A0011124FF27591B9A
+:1003D00099F0593F50F4503E68F11A16F040A22FA0
+:1003E000232F342F4427585FF3CF46953795279511
+:1003F000A795F0405395C9F77EF41F16BA0B620B10
+:10040000730B840BBAF09150A1F0FF0FBB1F661F56
+:10041000771F881FC2F70EC0BA0F621F731F841F99
+:1004200048F4879577956795B795F7959E3F08F0BF
+:10043000B0CF9395880F08F09927EE0F9795879581
+:1004400008950E94630208F481E00895E89409C0C9
+:1004500097FB3EF490958095709561957F4F8F4FF7
+:100460009F4F9923A9F0F92F96E9BB279395F6950D
+:10047000879577956795B795F111F8CFFAF4BB0F8B
+:1004800011F460FF1BC06F5F7F4F8F4F9F4F16C0EF
+:10049000882311F096E911C0772321F09EE8872F79
+:1004A000762F05C0662371F096E8862F70E060E035
+:1004B0002AF09A95660F771F881FDAF7880F9695AE
+:1004C000879597F90895990F0008550FAA0BE0E852
+:1004D000FEEF16161706E807F907C0F01216130606
+:1004E000E407F50798F0621B730B840B950B39F446
+:1004F0000A2661F0232B242B252B21F408950A26AC
+:1005000009F4A140A6958FEF811D811D089597F9EB
+:100510009F6780E870E060E008959FEF80EC0895A9
+:1005200000240A94161617061806090608950024D2
+:100530000A9412161306140605060895092E03944C
+:10054000000C11F4882352F0BB0F40F4BF2B11F4C0
+:1005500060FF04C06F5F7F4F8F4F9F4F089557FD1F
+:100560009058440F551F59F05F3F71F04795880F21
+:1005700097FB991F61F09F3F79F0879508951216B8
+:1005800013061406551FF2CF4695F1DF08C0161664
+:1005900017061806991FF1CF869571056105089415
+:1005A0000895E894BB2766277727CB0197F908952C
+:1005B0000E94EB020C949E020E94900238F00E946E
+:1005C000970220F0952311F00C9487020C948D0271
+:1005D00011240C94D2020E94AF0270F3959FC1F3D4
+:1005E000950F50E0551F629FF001729FBB27F00DE1
+:1005F000B11D639FAA27F00DB11DAA1F649F662736
+:10060000B00DA11D661F829F2227B00DA11D621F84
+:10061000739FB00DA11D621F839FA00D611D221F3E
+:10062000749F3327A00D611D231F849F600D211D22
+:10063000822F762F6A2F11249F5750409AF0F1F0A5
+:1006400088234AF0EE0FFF1FBB1F661F771F881F0E
+:1006500091505040A9F79E3F510580F00C948702BD
+:100660000C94D2025F3FE4F3983ED4F386957795DD
+:100670006795B795F795E7959F5FC1F7FE2B880FB4
+:0E068000911D9695879597F90895F894FFCFF0
+:10068E0000000000010001006F12033B000000009B
+:04069E000000000058
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.sh
new file mode 100755
index 0000000..7de1e2c
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_blue_red.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_blue_red.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_blue_red_main.c -o led_blue_red -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_blue_red led_blue_red.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_blue_red.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red_main.c
new file mode 100755
index 0000000..c9668e8
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_blue_red_main.c
@@ -0,0 +1,215 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_blue_red_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_blue_red_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[2];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[4];
+} led_blue_red_fmi2Component;
+
+led_blue_red_fmi2Component led_blue_red_component = {
+ .fmi2BooleanVars = {
+ fmi2True /*booleanExpression1._y*/,
+ fmi2True /*booleanExpression2._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_blue_red_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_blue_red_component;
+}
+
+fmi2Status led_blue_red_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_blue_red_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* digitalWriteBoolean2._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 4);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ return fmi2OK;
+}
+
+fmi2Status led_blue_red_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_blue_red_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_blue_red_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */ = (comp->currentTime)<(5.0); /* equation 4 */
+ comp->fmi2BooleanVars[1] /* booleanExpression2._y DISCRETE */ = (comp->currentTime)<(8.0); /* equation 5 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[1] /* digitalWriteBoolean2._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 4, comp->fmi2BooleanVars[1] /* booleanExpression2._y DISCRETE */);
+}
+
+fmi2Status led_blue_red_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_blue_red_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_blue_red_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_blue_red_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_blue_red_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_blue_red_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_blue_red_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink
new file mode 100755
index 0000000..424aaf8
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.hex
new file mode 100755
index 0000000..d512cd3
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.hex
@@ -0,0 +1,131 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C942C0140
+:100020000C9451000C9451000C9451000C94FB0062
+:100030000C9451000C9451000C94CA000C94510083
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0ECE0F8E002C0EF
+:1000800005900D92A031B107D9F721E0A0E1B1E0D0
+:1000900001C01D92A531B207E1F70E947A010C94CC
+:1000A00004040C940000CF92DF92EF92FF920F9322
+:1000B0001F93CF93DF93EC01C880D980EA80FB8047
+:1000C0002DEC3CEC4CE45EE3C701B6010E94160245
+:1000D0000E94C5022DEC3CEC4CE45EE30E947303ED
+:1000E0009B01AC01C701B6010E94A90101E010E02B
+:1000F0002DEC3CEC4CEC5DE30E946E0387FF02C0EC
+:1001000000E010E01D830C838E859F858230910571
+:1001100061F08330910599F00197C9F416BC809184
+:100120006E00826080936E0016C01092850010925F
+:10013000840080916F00826080936F000CC01092E9
+:10014000B2008091700082608093700004C081E0F2
+:1001500090E00E94040478949FB7F8948091120173
+:100160009FBF8823C9F310921201EA85FB858C8119
+:100170009D81892B19F08081826002C080818D7FF2
+:100180008083DF91CF911F910F91FF90EF90DF90CF
+:10019000CF9008951F920F920FB60F9211242F93B4
+:1001A0003F938F939F93809110019091110101963D
+:1001B000909311018093100180911201813091F090
+:1001C000209110013091110180911301909114013F
+:1001D0002817390738F081E080931201109211013D
+:1001E000109210019F918F913F912F910F900FBE10
+:1001F0000F901F9018951F920F920FB60F92112417
+:100200002F933F938F939F938091100190911101B1
+:100210000196909311018093100180911201813019
+:1002200091F0209110013091110180911301909172
+:1002300014012817390738F081E0809312011092D9
+:100240001101109210019F918F913F912F910F906A
+:100250000FBE0F901F9018951F920F920FB60F921E
+:1002600011242F933F938F939F938091100190912E
+:100270001101019690931101809310018091120158
+:10028000813091F020911001309111018091130182
+:10029000909114012817390738F081E080931201FA
+:1002A00010921101109210019F918F913F912F9107
+:1002B0000F900FBE0F901F901895FC0185B58360BD
+:1002C00085BD21E030E03587248782E090E090937F
+:1002D00014018093130184B5826084BD89EF87BDCA
+:1002E00037872687219A85E290E09387828780E08E
+:1002F00090E00895CF92DF92EF92FF9280E091E03C
+:100300000E945D01C12CD12C760160E070E0CB0130
+:1003100060930001709301018093020190930301A7
+:1003200080E091E00E9453008FEFC81AD80AE80AD3
+:10033000F80AC701B6010E9488022FE632E143E0C5
+:100340005BE30E94730320E030E0A9010E94AA0150
+:10035000DFCF5058BB27AA270E94C1010C941C0371
+:100360000E940E0338F00E94150320F039F49F3FDD
+:1003700019F426F40C940B030EF4E095E7FB0C94AF
+:10038000DC02E92F0E942D0358F3BA1762077307A6
+:100390008407950720F079F4A6F50C9467030EF412
+:1003A000E0950B2EBA2FA02D0B01B90190010C0185
+:1003B000CA01A0011124FF27591B99F0593F50F49D
+:1003C000503E68F11A16F040A22F232F342F4427F5
+:1003D000585FF3CF469537952795A795F0405395ED
+:1003E000C9F77EF41F16BA0B620B730B840BBAF0BD
+:1003F0009150A1F0FF0FBB1F661F771F881FC2F728
+:100400000EC0BA0F621F731F841F48F4879577953B
+:100410006795B795F7959E3F08F0B0CF9395880FF5
+:1004200008F09927EE0F9795879508950E942A0264
+:100430000C941C030E94150358F00E940E0340F018
+:1004400029F45F3F29F00C94DC0251110C946803ED
+:100450000C940B030E942D0368F39923B1F35523E9
+:1004600091F3951B550BBB27AA27621773078407C7
+:1004700038F09F5F5F4F220F331F441FAA1FA9F35D
+:1004800035D00E2E3AF0E0E832D091505040E6954B
+:10049000001CCAF72BD0FE2F29D0660F771F881FAC
+:1004A000BB1F261737074807AB07B0E809F0BB0B9F
+:1004B000802DBF01FF2793585F4F3AF09E3F5105B3
+:1004C00078F00C94DC020C9468035F3FE4F3983EF0
+:1004D000D4F3869577956795B795F7959F5FC9F79C
+:1004E000880F911D9695879597F90895E1E0660F1D
+:1004F000771F881FBB1F621773078407BA0720F096
+:10050000621B730B840BBA0BEE1F88F7E0950895FE
+:10051000E89409C097FB3EF490958095709561959D
+:100520007F4F8F4F9F4F9923A9F0F92F96E9BB2753
+:100530009395F695879577956795B795F111F8CFCF
+:10054000FAF4BB0F11F460FF1BC06F5F7F4F8F4F3A
+:100550009F4F16C0882311F096E911C0772321F030
+:100560009EE8872F762F05C0662371F096E8862FC8
+:1005700070E060E02AF09A95660F771F881FDAF71F
+:10058000880F9695879597F908950E944F0390F0EC
+:100590009F3748F4911116F00C94680360E070E006
+:1005A00080E89FEB089526F41B16611D711D811DC7
+:1005B0000C94E2020C94FD0297F99F6780E870E0CA
+:1005C00060E00895882371F4772321F09850872BF9
+:1005D000762F07C0662311F499270DC09051862B02
+:1005E00070E060E02AF09A95660F771F881FDAF7AF
+:1005F000880F9695879597F908959F3F31F0915010
+:1006000020F4879577956795B795880F911D9695F6
+:10061000879597F908959FEF80EC089500240A9438
+:100620001616170618060906089500240A941216CD
+:100630001306140605060895092E0394000C11F400
+:10064000882352F0BB0F40F4BF2B11F460FF04C0AD
+:100650006F5F7F4F8F4F9F4F089557FD9058440F06
+:10066000551F59F05F3F71F04795880F97FB991F11
+:1006700061F09F3F79F087950895121613061406CE
+:10068000551FF2CF4695F1DF08C01616170618065B
+:10069000991FF1CF869571056105089408950E9410
+:1006A0003503A0F0BEE7B91788F4BB279F3860F484
+:1006B0001616B11D672F782F8827985FF7CF86957C
+:1006C00077956795B11D93959639C8F30895E89489
+:1006D000BB2766277727CB0197F908950E94E0038F
+:1006E00008F48FEF08950E9486030C941C030E9467
+:1006F0000E0338F00E94150320F0952311F00C949E
+:10070000DC020C940B0311240C9468030E942D034B
+:1007100070F3959FC1F3950F50E0551F629FF00154
+:10072000729FBB27F00DB11D639FAA27F00DB11D6D
+:10073000AA1F649F6627B00DA11D661F829F2227F6
+:10074000B00DA11D621F739FB00DA11D621F839F7D
+:10075000A00D611D221F749F3327A00D611D231F53
+:10076000849F600D211D822F762F6A2F11249F57A1
+:1007700050409AF0F1F088234AF0EE0FFF1FBB1FA4
+:10078000661F771F881F91505040A9F79E3F510563
+:1007900080F00C94DC020C9468035F3FE4F3983E15
+:1007A000D4F3869577956795B795F795E7959F5F0D
+:1007B000C1F7FE2B880F911D9695879597F908959F
+:1007C000990F0008550FAA0BE0E8FEEF1616170662
+:1007D000E807F907C0F012161306E407F50798F0CA
+:1007E000621B730B840B950B39F40A2661F0232BE3
+:1007F000242B252B21F408950A2609F4A140A6955F
+:0C0800008FEF811D811D0895F894FFCF3B
+:10080C000000000000006F12033B0000000000001D
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.sh
new file mode 100755
index 0000000..a30543c
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_green_blink.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_green_blink.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_green_blink_main.c -o led_green_blink -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_green_blink led_green_blink.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_green_blink.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink_main.c
new file mode 100755
index 0000000..5999083
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/led_green_blink_main.c
@@ -0,0 +1,212 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_green_blink_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_green_blink_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[3];
+} led_green_blink_fmi2Component;
+
+led_green_blink_fmi2Component led_green_blink_component = {
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_green_blink_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_green_blink_component;
+}
+
+fmi2Status led_green_blink_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_green_blink_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ return fmi2OK;
+}
+
+fmi2Status led_green_blink_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_green_blink_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_green_blink_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */ = (om_mod(comp->currentTime,0.2))>=(0.1); /* equation 3 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[0] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[0] /* booleanExpression1._y DISCRETE */);
+}
+
+fmi2Status led_green_blink_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_green_blink_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_green_blink_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_green_blink_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_green_blink_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_green_blink_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_green_blink_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blink.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blink.mos
new file mode 100755
index 0000000..0ff4be4
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blink.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_led.MDD_led_blink, fileNamePrefix="led_blink");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue.mos
new file mode 100755
index 0000000..8b26945
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_led.MDD_led_blue, fileNamePrefix="led_blue");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_delay.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_delay.mos
new file mode 100755
index 0000000..62b9250
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_delay.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_led.MDD_led_blue_delay, fileNamePrefix="led_blue_delay");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_red.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_red.mos
new file mode 100755
index 0000000..f60dfc6
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_blue_red.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_led.MDD_led_blue_red, fileNamePrefix="led_blue_red");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_green_blink.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_green_blink.mos
new file mode 100755
index 0000000..eeb79c1
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/led/runMDD_led_green_blink.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_led.MDD_led_green_blink, fileNamePrefix="led_green_blink");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold
new file mode 100755
index 0000000..3b86efe
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.hex
new file mode 100755
index 0000000..2d477aa
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.hex
@@ -0,0 +1,150 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E30189
+:100020000C9451000C9451000C9451000C94B201AA
+:100030000C9451000C9451000C9481010C945100CB
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0ECEFF8E002C0E0
+:1000800005900D92A834B107D9F721E0A8E4B1E0BA
+:1000900001C01D92AD34B207E1F70E944A020C94F0
+:1000A0007C040C9400004F925F926F927F928F922B
+:1000B0009F92AF92BF92CF92DF92EF92FF920F93F7
+:1000C0001F93CF93DF93EC0180917C00857E82604B
+:1000D00080937C0080917A00806480937A00809184
+:1000E0007A0086FDFCCF609178007091790080E005
+:1000F00090E00E94580320E030E040E854E40E9481
+:10010000EB0320E030EC4FE754E40E94E6026B0181
+:100110007C016C837D838E839F8311E028A939A99C
+:100120004AA95BA90E94E60387FD10E0812F90E0B9
+:100130009FA38EA3111104C0812C912C540106C0E1
+:10014000812C912C90E8A92E9FE3B92E8C869D8658
+:10015000AE86BF8601E010E02CA93DA94EA95FA99B
+:10016000C501B4010E94E60387FF02C000E010E071
+:1001700019A308A311E02CA53DA54EA55FA5C701B5
+:10018000B6010E94E60387FD10E0812F90E09DA359
+:100190008CA3111104C0412C512C320106C0412CFA
+:1001A000512C80E8682E8FE3782E488659866A861F
+:1001B0007B8601E010E0A5019401C301B2010E9419
+:1001C000E603181614F000E010E01F8F0E8F11E008
+:1001D00028A539A54AA55BA5C701B6010E94E6037B
+:1001E00087FD10E0812F90E09BA38AA3111104C02A
+:1001F00060E070E0CB0104C060E070E080E89FE365
+:10020000688B798B8A8B9B8B01E010E0A3019201B4
+:100210000E94E603181614F000E010E01D8F0C8F0A
+:10022000FE01EA5BFF4F808191818230910561F090
+:100230008330910599F00197C9F416BC80916E0046
+:10024000826080936E0016C0109285001092840028
+:1002500080916F00826080936F000CC01092B2009A
+:100260008091700082608093700004C081E090E013
+:100270000E947C0478949FB7F89480914A019FBFB4
+:100280008823C9F310924A01EEADFFAD8C8D9D8D90
+:10029000892B19F08081826002C080818D7F8083EC
+:1002A000FE01E05CFF4F0190F081E02D8E8D9F8D6F
+:1002B000892B19F08081846002C080818B7F8083CC
+:1002C000FE01EE5BFF4F0190F081E02D88A199A126
+:1002D000892B19F08081886002C08081877F8083AC
+:1002E000DF91CF911F910F91FF90EF90DF90CF9012
+:1002F000BF90AF909F908F907F906F905F904F9046
+:1003000008951F920F920FB60F9211242F933F93CF
+:100310008F939F938091480190914901019690930A
+:1003200049018093480180914A01813091F02091E8
+:1003300048013091490180914B0190914C0128175F
+:10034000390738F081E080934A01109249011092F8
+:1003500048019F918F913F912F910F900FBE0F9069
+:100360001F9018951F920F920FB60F9211242F9382
+:100370003F938F939F9380914801909149010196FB
+:10038000909349018093480180914A01813091F016
+:10039000209148013091490180914B0190914C018D
+:1003A0002817390738F081E080934A0110924901FB
+:1003B000109248019F918F913F912F910F900FBE06
+:1003C0000F901F9018951F920F920FB60F92112445
+:1003D0002F933F938F939F93809148019091490170
+:1003E0000196909349018093480180914A018130A0
+:1003F00091F0209148013091490180914B019091F9
+:100400004C012817390738F081E080934A01109297
+:100410004901109248019F918F913F912F910F9028
+:100420000FBE0F901F901895ECE7F0E02081206C34
+:100430002083EAE7F0E0208127682083FC0115AEE5
+:1004400014AE239AEE5BFF4F25E230E03183208328
+:10045000229A329731832083219AFC0137AF26AF4D
+:1004600025B5236025BDEC5BFF4F41E050E0518393
+:10047000408322E030E030934C0120934B0124B5BF
+:10048000226024BD29EF27BD32965183408380E04E
+:1004900090E00895CF92DF92EF92FF9280E091E09A
+:1004A0000E941402C12CD12C760160E070E0CB01D7
+:1004B0006093000170930101809302019093030106
+:1004C00080E091E00E9453008FEFC81AD80AE80A32
+:1004D000F80AC701B6010E9458032FE632E143E053
+:1004E0005BE30E94EB0320E030E0A9010E947A0266
+:1004F000DFCF5058BB27AA270E9491020C94AC036F
+:100500000E949E0338F00E94A50320F039F49F3F1B
+:1005100019F426F40C949B030EF4E095E7FB0C947D
+:100520009503E92F0E94BD0358F3BA1762077307BA
+:100530008407950720F079F4A6F50C94DF030EF4F8
+:10054000E0950B2EBA2FA02D0B01B90190010C01E3
+:10055000CA01A0011124FF27591B99F0593F50F4FB
+:10056000503E68F11A16F040A22F232F342F442753
+:10057000585FF3CF469537952795A795F04053954B
+:10058000C9F77EF41F16BA0B620B730B840BBAF01B
+:100590009150A1F0FF0FBB1F661F771F881FC2F786
+:1005A0000EC0BA0F621F731F841F48F4879577959A
+:1005B0006795B795F7959E3F08F0B0CF9395880F54
+:1005C00008F09927EE0F9795879508950E94FA02F3
+:1005D0000C94AC030E94A50358F00E949E0340F0C7
+:1005E00029F45F3F29F00C94950351110C94E0031A
+:1005F0000C949B030E94BD0368F39923B1F3552328
+:1006000091F3951B550BBB27AA2762177307840725
+:1006100038F09F5F5F4F220F331F441FAA1FA9F3BB
+:1006200035D00E2E3AF0E0E832D091505040E695A9
+:10063000001CCAF72BD0FE2F29D0660F771F881F0A
+:10064000BB1F261737074807AB07B0E809F0BB0BFD
+:10065000802DBF01FF2793585F4F3AF09E3F510511
+:1006600078F00C9495030C94E0035F3FE4F3983E1C
+:10067000D4F3869577956795B795F7959F5FC9F7FA
+:10068000880F911D9695879597F90895E1E0660F7B
+:10069000771F881FBB1F621773078407BA0720F0F4
+:1006A000621B730B840BBA0BEE1F88F7E09508955D
+:1006B000E89409C097FB3EF49095809570956195FC
+:1006C0007F4F8F4F9F4F9923A9F0F92F96E9BB27B2
+:1006D0009395F695879577956795B795F111F8CF2E
+:1006E000FAF4BB0F11F460FF1BC06F5F7F4F8F4F99
+:1006F0009F4F16C0882311F096E911C0772321F08F
+:100700009EE8872F762F05C0662371F096E8862F26
+:1007100070E060E02AF09A95660F771F881FDAF77D
+:10072000880F9695879597F9089597F99F6780E8C0
+:1007300070E060E008959FEF80EC089500240A9433
+:100740001616170618060906089500240A941216AC
+:100750001306140605060895092E0394000C11F4DF
+:10076000882352F0BB0F40F4BF2B11F460FF04C08C
+:100770006F5F7F4F8F4F9F4F089557FD9058440FE5
+:10078000551F59F05F3F71F04795880F97FB991FF0
+:1007900061F09F3F79F087950895121613061406AD
+:1007A000551FF2CF4695F1DF08C01616170618063A
+:1007B000991FF1CF86957105610508940895E89415
+:1007C000BB2766277727CB0197F908950E94580425
+:1007D00008F48FEF08950E94FE030C94AC030E946E
+:1007E0009E0338F00E94A50320F0952311F00C948D
+:1007F00095030C949B0311240C94E0030E94BD0309
+:1008000070F3959FC1F3950F50E0551F629FF00163
+:10081000729FBB27F00DB11D639FAA27F00DB11D7C
+:10082000AA1F649F6627B00DA11D661F829F222705
+:10083000B00DA11D621F739FB00DA11D621F839F8C
+:10084000A00D611D221F749F3327A00D611D231F62
+:10085000849F600D211D822F762F6A2F11249F57B0
+:1008600050409AF0F1F088234AF0EE0FFF1FBB1FB3
+:10087000661F771F881F91505040A9F79E3F510572
+:1008800080F00C9495030C94E0035F3FE4F3983EF2
+:10089000D4F3869577956795B795F795E7959F5F1C
+:1008A000C1F7FE2B880F911D9695879597F90895AE
+:1008B000990F0008550FAA0BE0E8FEEF1616170671
+:1008C000E807F907C0F012161306E407F50798F0D9
+:1008D000621B730B840B950B39F40A2661F0232BF2
+:1008E000242B252B21F408950A2609F4A140A6956E
+:0C08F0008FEF811D811D0895F894FFCF4B
+:1008FC0000000000000000000000000000000000EC
+:10090C0000000000000000000000000000000000DB
+:10091C000000000000000000000000000000A043E8
+:10092C00000061440000003F6F12033B0000000018
+:08093C000000000000000000B3
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.sh
new file mode 100755
index 0000000..cbebfb4
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_pot_threshold.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_pot_threshold.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections pot_threshold_main.c -o pot_threshold -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom pot_threshold pot_threshold.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:pot_threshold.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold_main.c
new file mode 100755
index 0000000..537dcbd
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/pot_threshold_main.c
@@ -0,0 +1,264 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct pot_threshold_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct pot_threshold_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Real fmi2RealVars[6];
+ fmi2Boolean fmi2BooleanVars[6];
+ fmi2Real fmi2RealParameter[5];
+ void* extObjs[6];
+} pot_threshold_fmi2Component;
+
+pot_threshold_fmi2Component pot_threshold_component = {
+ .fmi2RealVars = {
+ 0.0 /*adc._y*/,
+ 0.0 /*greater1._u1*/,
+ 0.0 /*greater1._u2*/,
+ 0.0 /*greater2._u1*/,
+ 0.0 /*realExpression1._y*/,
+ 0.0 /*realExpression2._y*/,
+ },
+ .fmi2BooleanVars = {
+ fmi2False /*digitalWriteBoolean1._u*/,
+ fmi2False /*digitalWriteBoolean2._u*/,
+ fmi2False /*digitalWriteBoolean3._u*/,
+ fmi2False /*greaterEqualThreshold1._y*/,
+ fmi2False /*greaterEqualThreshold2._y*/,
+ fmi2False /*greaterEqualThreshold3._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.0 /*greaterEqualThreshold1._threshold*/,
+ 320.0 /*greaterEqualThreshold2._threshold*/,
+ 900.0 /*greaterEqualThreshold3._threshold*/,
+ 0.5 /*realToBoolean1._threshold*/,
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+static const char * const OMCLIT0 = "ElectricPotential";
+static const char * const OMCLIT1 = "V";
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+#include "MDDAVRAnalog.h"
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution)
+{
+ fmi2Real om_value;
+ om_value = MDD_avr_analog_read(om_analogPort, om_vref, om_voltageResolution);
+ return om_value;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage)
+{
+ void* om_avr;
+ om_avr = MDD_avr_analog_init(om_divisionFactor, om_referenceVoltage);
+ return om_avr;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr)
+{
+ MDD_avr_analog_close(om_avr);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component pot_threshold_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &pot_threshold_component;
+}
+
+fmi2Status pot_threshold_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status pot_threshold_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* adc._analog EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Analog.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(comp, 7, 4);
+ comp->extObjs[3] /* digitalWriteBoolean3._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 4);
+ comp->extObjs[2] /* digitalWriteBoolean2._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 3);
+ comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[4] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status pot_threshold_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status pot_threshold_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status pot_threshold_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2RealVars[0] /* adc._y variable */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(comp, 3, 1024.0, 10); /* equation 14 */
+ comp->fmi2BooleanVars[5] /* greaterEqualThreshold3._y DISCRETE */ = (comp->fmi2RealVars[0] /* adc._y variable */)>=(comp->fmi2RealParameter[2] /* greaterEqualThreshold3._threshold PARAM */); /* equation 15 */
+ comp->fmi2RealVars[2] /* greater1._u2 variable */ = (comp->fmi2BooleanVars[5] /* greaterEqualThreshold3._y DISCRETE */) ? (1.0) : (0.0); /* equation 16 */
+ comp->fmi2BooleanVars[2] /* digitalWriteBoolean3._u DISCRETE */ = (comp->fmi2RealVars[2] /* greater1._u2 variable */)>=(comp->fmi2RealParameter[3] /* realToBoolean1._threshold PARAM */); /* equation 17 */
+ comp->fmi2BooleanVars[4] /* greaterEqualThreshold2._y DISCRETE */ = (comp->fmi2RealVars[0] /* adc._y variable */)>=(comp->fmi2RealParameter[1] /* greaterEqualThreshold2._threshold PARAM */); /* equation 18 */
+ comp->fmi2RealVars[1] /* greater1._u1 variable */ = (comp->fmi2BooleanVars[4] /* greaterEqualThreshold2._y DISCRETE */) ? (1.0) : (0.0); /* equation 19 */
+ comp->fmi2BooleanVars[1] /* digitalWriteBoolean2._u DISCRETE */ = (comp->fmi2RealVars[1] /* greater1._u1 variable */)>(comp->fmi2RealVars[2] /* greater1._u2 variable */); /* equation 20 */
+ comp->fmi2BooleanVars[3] /* greaterEqualThreshold1._y DISCRETE */ = (comp->fmi2RealVars[0] /* adc._y variable */)>=(comp->fmi2RealParameter[0] /* greaterEqualThreshold1._threshold PARAM */); /* equation 21 */
+ comp->fmi2RealVars[3] /* greater2._u1 variable */ = (comp->fmi2BooleanVars[3] /* greaterEqualThreshold1._y DISCRETE */) ? (1.0) : (0.0); /* equation 22 */
+ comp->fmi2BooleanVars[0] /* digitalWriteBoolean1._u DISCRETE */ = (comp->fmi2RealVars[3] /* greater2._u1 variable */)>(comp->fmi2RealVars[1] /* greater1._u1 variable */); /* equation 23 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[5] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[0] /* digitalWriteBoolean1._u DISCRETE */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[2] /* digitalWriteBoolean2._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 3, comp->fmi2BooleanVars[1] /* digitalWriteBoolean2._u DISCRETE */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[3] /* digitalWriteBoolean3._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 4, comp->fmi2BooleanVars[2] /* digitalWriteBoolean3._u DISCRETE */);
+}
+
+fmi2Status pot_threshold_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ pot_threshold_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = pot_threshold_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ pot_threshold_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ pot_threshold_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ pot_threshold_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = pot_threshold_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/runMDD_pot_threshold.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/runMDD_pot_threshold.mos
new file mode 100755
index 0000000..457b89c
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/pot/runMDD_pot_threshold.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_pot.MDD_pot_threshold, fileNamePrefix="pot_threshold");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button
new file mode 100755
index 0000000..a9402e5
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.hex
new file mode 100755
index 0000000..0059548
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.hex
@@ -0,0 +1,94 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94FB0072
+:100020000C9451000C9451000C9451000C94CA0093
+:100030000C9451000C9451000C9499000C945100B4
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E6EAF5E002C0EE
+:1000800005900D92A631B107D9F711E0A6E1B1E0D4
+:1000900001C01D92AB31B107E1F70E944C010C94F5
+:1000A000D1020C940000DC0154968D919C915597DF
+:1000B0008230910561F08330910599F00197C9F480
+:1000C00016BC80916E00826080936E0016C0109204
+:1000D00085001092840080916F00826080936F0091
+:1000E0000CC01092B200809170008260809370000A
+:1000F00004C081E090E00E94D10278949FB7F89408
+:10010000809118019FBF8823C9F31092180150965F
+:10011000ED91FC91519718968D919C9119970097AC
+:1001200021F0808182608083089580818D7F80832B
+:1001300008951F920F920FB60F9211242F933F93A1
+:100140008F939F9380911601909117010196909340
+:1001500017018093160180911801813091F0209150
+:100160001601309117018091190190911A012817F9
+:10017000390738F081E0809318011092170110922E
+:1001800016019F918F913F912F910F900FBE0F906D
+:100190001F9018951F920F920FB60F9211242F9354
+:1001A0003F938F939F938091160190911701019631
+:1001B000909317018093160180911801813091F07E
+:1001C00020911601309117018091190190911A0127
+:1001D0002817390738F081E0809318011092170131
+:1001E000109216019F918F913F912F910F900FBE0A
+:1001F0000F901F9018951F920F920FB60F92112417
+:100200002F933F938F939F938091160190911701A5
+:100210000196909317018093160180911801813007
+:1002200091F0209116013091170180911901909160
+:100230001A012817390738F081E0809318011092CD
+:100240001701109216019F918F913F912F910F905E
+:100250000FBE0F901F901895FC01219A85E290E047
+:10026000918B808B24989787868785B5836085BD21
+:1002700081E090E0938B828B22E030E030931A0192
+:100280002093190124B5226024BD29EF27BD958B49
+:10029000848B80E090E00895CF92DF92EF92FF92FE
+:1002A00080E091E00E942C01C12CD12C760160E00D
+:1002B00070E0CB0160930001709301018093020113
+:1002C0009093030180E091E00E9453008FEFC81AE1
+:1002D000D80AE80AF80AC701B6010E94E0012FE631
+:1002E00032E143E05BE30E946E0220E030E0A901CE
+:1002F0000E947C01DFCF5058BB27AA270ED0B4C084
+:10030000A5D030F0AAD020F031F49F3F11F41EF4B4
+:100310009AC00EF4E095E7FB90C0E92FB6D080F3C9
+:10032000BA17620773078407950718F071F49EF5F2
+:10033000CEC00EF4E0950B2EBA2FA02D0B01B90103
+:1003400090010C01CA01A0011124FF27591B99F04B
+:10035000593F50F4503E68F11A16F040A22F232F57
+:10036000342F4427585FF3CF469537952795A795A7
+:10037000F0405395C9F77EF41F16BA0B620B730B4E
+:10038000840BBAF09150A1F0FF0FBB1F661F771FBF
+:10039000881FC2F70EC0BA0F621F731F841F48F474
+:1003A000879577956795B795F7959E3F08F0B3CFFA
+:1003B0009395880F08F09927EE0F979587950895E4
+:1003C000E89409C097FB3EF49095809570956195EF
+:1003D0007F4F8F4F9F4F9923A9F0F92F96E9BB27A5
+:1003E0009395F695879577956795B795F111F8CF21
+:1003F000FAF4BB0F11F460FF1BC06F5F7F4F8F4F8C
+:100400009F4F16C0882311F096E911C0772321F081
+:100410009EE8872F762F05C0662371F096E8862F19
+:1004200070E060E02AF09A95660F771F881FDAF770
+:10043000880F9695879597F9089597F99F6780E8B3
+:1004400070E060E008959FEF80EC089500240A9426
+:100450001616170618060906089500240A9412169F
+:100460001306140605060895092E0394000C11F4D2
+:10047000882352F0BB0F40F4BF2B11F460FF04C07F
+:100480006F5F7F4F8F4F9F4F089557FD9058440FD8
+:10049000551F59F05F3F71F04795880F97FB991FE3
+:1004A00061F09F3F79F087950895121613061406A0
+:1004B000551FF2CF4695F1DF08C01616170618062D
+:1004C000991FF1CF86957105610508940895E89408
+:1004D000BB2766277727CB0197F908950BD0C4CFA8
+:1004E000B5DF28F0BADF18F0952309F0A6CFABCF1F
+:1004F0001124EECFCADFA0F3959FD1F3950F50E002
+:10050000551F629FF001729FBB27F00DB11D639FC5
+:10051000AA27F00DB11DAA1F649F6627B00DA11D6B
+:10052000661F829F2227B00DA11D621F739FB00D11
+:10053000A11D621F839FA00D611D221F749F332781
+:10054000A00D611D231F849F600D211D822F762F1A
+:100550006A2F11249F5750408AF0E1F088234AF017
+:10056000EE0FFF1FBB1F661F771F881F9150504063
+:10057000A9F79E3F510570F060CFAACF5F3FECF323
+:10058000983EDCF3869577956795B795F795E7954F
+:100590009F5FC1F7FE2B880F911D9695879597F960
+:0605A0000895F894FFCF5E
+:1005A600000000000000000000006F12033B000086
+:0605B6000000000000003F
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.sh
new file mode 100755
index 0000000..1428171
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_led_push_button.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_led_push_button.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections led_push_button_main.c -o led_push_button -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom led_push_button led_push_button.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:led_push_button.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button_main.c
new file mode 100755
index 0000000..7b155ad
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/led_push_button_main.c
@@ -0,0 +1,234 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct led_push_button_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct led_push_button_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[3];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[4];
+} led_push_button_fmi2Component;
+
+led_push_button_fmi2Component led_push_button_component = {
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ fmi2False /*booleanExpression2._y*/,
+ fmi2False /*digitalReadBoolean1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline fmi2Boolean Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_read(fmi2Component comp, void* om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_destructor(fmi2Component comp, void* om_digital);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Boolean Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_read(fmi2Component comp, void* om_port, fmi2Integer om_pin)
+{
+ fmi2Boolean om_b;
+ om_b = MDD_avr_digital_pin_read(om_port, om_pin);
+ return om_b;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2False);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component led_push_button_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &led_push_button_component;
+}
+
+fmi2Status led_push_button_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status led_push_button_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 2, 2);
+ comp->extObjs[0] /* digitalReadBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitRead */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(comp, 2, 5);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status led_push_button_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status led_push_button_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status led_push_button_functionOutputs(fmi2Component comp)
+{
+ Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 2, comp->fmi2BooleanVars[2] /* digitalReadBoolean1._y DISCRETE */);
+}
+
+fmi2Status led_push_button_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ led_push_button_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = led_push_button_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ led_push_button_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ led_push_button_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ led_push_button_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = led_push_button_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status
new file mode 100755
index 0000000..5b91980
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.hex
new file mode 100755
index 0000000..ab8dde5
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.hex
@@ -0,0 +1,91 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E50088
+:100020000C9451000C9451000C9451000C94B400A9
+:100030000C9451000C9451000C9483000C945100CA
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E8E7F5E002C0EF
+:1000800005900D92A431B107D9F711E0A4E1B1E0D8
+:1000900001C01D92A931B107E1F70E9433010C9410
+:1000A000BA020C9400008230910561F08330910512
+:1000B00099F00197C9F416BC80916E00826080931C
+:1000C0006E0016C0109285001092840080916F001F
+:1000D000826080936F000CC01092B200809170001B
+:1000E00082608093700004C081E090E00E94BA02B8
+:1000F00078949FB7F894809116019FBF8823C9F325
+:100100001092160108951F920F920FB60F921124AC
+:100110002F933F938F939F9380911401909115019A
+:1001200001969093150180931401809116018130FE
+:1001300091F0209114013091150180911701909157
+:1001400018012817390738F081E0809316011092C2
+:100150001501109214019F918F913F912F910F9053
+:100160000FBE0F901F9018951F920F920FB60F920F
+:1001700011242F933F938F939F938091140190911B
+:100180001501019690931501809314018091160139
+:10019000813091F020911401309115018091170167
+:1001A000909118012817390738F081E080931601E3
+:1001B00010921501109214019F918F913F912F91F0
+:1001C0000F900FBE0F901F9018951F920F920FB6B1
+:1001D0000F9211242F933F938F939F93809114013B
+:1001E00090911501019690931501809314018091CF
+:1001F0001601813091F02091140130911501809108
+:100200001701909118012817390738F081E0809381
+:10021000160110921501109214019F918F913F9138
+:100220002F910F900FBE0F901F901895FC012498EE
+:1002300083E290E09787868785B5836085BD81E0FE
+:1002400090E0918B808B22E030E030931801209376
+:10025000170124B5226024BD29EF27BD938B828B23
+:1002600080E090E00895CF92DF92EF92FF9280E0DD
+:1002700091E00E941601C12CD12C760160E070E063
+:10028000CB01609300017093010180930201909370
+:10029000030180911201909113010E9453008FEF8E
+:1002A000C81AD80AE80AF80AC701B6010E94C901AB
+:1002B0002FE632E143E05BE30E94570220E030E0AA
+:1002C000A9010E946501DDCF5058BB27AA270ED097
+:1002D000B4C0A5D030F0AAD020F031F49F3F11F483
+:1002E0001EF49AC00EF4E095E7FB90C0E92FB6D05B
+:1002F00080F3BA17620773078407950718F071F443
+:100300009EF5CEC00EF4E0950B2EBA2FA02D0B015A
+:10031000B90190010C01CA01A0011124FF27591B4A
+:1003200099F0593F50F4503E68F11A16F040A22F50
+:10033000232F342F4427585FF3CF469537952795C1
+:10034000A795F0405395C9F77EF41F16BA0B620BC0
+:10035000730B840BBAF09150A1F0FF0FBB1F661F07
+:10036000771F881FC2F70EC0BA0F621F731F841F4A
+:1003700048F4879577956795B795F7959E3F08F070
+:10038000B3CF9395880F08F09927EE0F979587952F
+:100390000895E89409C097FB3EF490958095709578
+:1003A00061957F4F8F4F9F4F9923A9F0F92F96E9C1
+:1003B000BB279395F695879577956795B795F11136
+:1003C000F8CFFAF4BB0F11F460FF1BC06F5F7F4FD3
+:1003D0008F4F9F4F16C0882311F096E911C07723E5
+:1003E00021F09EE8872F762F05C0662371F096E8EE
+:1003F000862F70E060E02AF09A95660F771F881FBD
+:10040000DAF7880F9695879597F9089597F99F677A
+:1004100080E870E060E008959FEF80EC089500248C
+:100420000A941616170618060906089500240A9459
+:1004300012161306140605060895092E0394000CDF
+:1004400011F4882352F0BB0F40F4BF2B11F460FF6E
+:1004500004C06F5F7F4F8F4F9F4F089557FD905897
+:10046000440F551F59F05F3F71F04795880F97FB78
+:10047000991F61F09F3F79F0879508951216130632
+:100480001406551FF2CF4695F1DF08C01616170661
+:100490001806991FF1CF8695710561050894089596
+:1004A000E894BB2766277727CB0197F908950BD0EF
+:1004B000C4CFB5DF28F0BADF18F0952309F0A6CF36
+:1004C000ABCF1124EECFCADFA0F3959FD1F3950FE8
+:1004D00050E0551F629FF001729FBB27F00DB11DC8
+:1004E000639FAA27F00DB11DAA1F649F6627B00D58
+:1004F000A11D661F829F2227B00DA11D621F739F41
+:10050000B00DA11D621F839FA00D611D221F749F4E
+:100510003327A00D611D231F849F600D211D822F95
+:10052000762F6A2F11249F5750408AF0E1F08823DC
+:100530004AF0EE0FFF1FBB1F661F771F881F9150E9
+:100540005040A9F79E3F510570F060CFAACF5F3FA2
+:10055000ECF3983EDCF3869577956795B795F7951C
+:10056000E7959F5FC1F7FE2B880F911D96958795A4
+:0805700097F90895F894FFCFFC
+:1005780000000000000000006F12033B01000000B3
+:04058800000000006F
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.sh
new file mode 100755
index 0000000..404eced
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_push_button_status.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_push_button_status.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections push_button_status_main.c -o push_button_status -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom push_button_status push_button_status.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:push_button_status.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status_main.c
new file mode 100755
index 0000000..f732e8a
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/push_button_status_main.c
@@ -0,0 +1,219 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct push_button_status_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct push_button_status_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Boolean fmi2BooleanVars[2];
+ fmi2Real fmi2RealParameter[1];
+ fmi2Boolean fmi2BooleanParameter[1];
+ void* extObjs[3];
+} push_button_status_fmi2Component;
+
+push_button_status_fmi2Component push_button_status_component = {
+ .fmi2BooleanVars = {
+ fmi2False /*booleanValue1._active*/,
+ fmi2False /*digitalReadBoolean1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+ .fmi2BooleanParameter = {
+ fmi2True /*booleanValue1._use_activePort*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+
+static inline fmi2Boolean Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_read(fmi2Component comp, void* om_port, fmi2Integer om_pin);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Boolean Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_read(fmi2Component comp, void* om_port, fmi2Integer om_pin)
+{
+ fmi2Boolean om_b;
+ om_b = MDD_avr_digital_pin_read(om_port, om_pin);
+ return om_b;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2False);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component push_button_status_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &push_button_status_component;
+}
+
+fmi2Status push_button_status_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status push_button_status_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* digitalReadBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitRead */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitRead_constructor(comp, 2, 5);
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status push_button_status_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status push_button_status_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status push_button_status_functionOutputs(fmi2Component comp)
+{
+ Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);
+}
+
+fmi2Status push_button_status_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ push_button_status_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = push_button_status_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ push_button_status_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ push_button_status_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ push_button_status_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = push_button_status_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_led_push_button.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_led_push_button.mos
new file mode 100755
index 0000000..3e2d70f
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_led_push_button.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_push.MDD_led_push_button, fileNamePrefix="led_push_button");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_push_button_status.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_push_button_status.mos
new file mode 100755
index 0000000..c8b8d45
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/push/runMDD_push_button_status.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_push.MDD_push_button_status, fileNamePrefix="push_button_status");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_init.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_init.mos
new file mode 100755
index 0000000..be5ff81
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_init.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_servo.MDD_servo_init, fileNamePrefix="servo_init");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_loop.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_loop.mos
new file mode 100755
index 0000000..23b035f
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_loop.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_servo.MDD_servo_loop, fileNamePrefix="servo_loop");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_pot.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_pot.mos
new file mode 100755
index 0000000..a7e6ac1
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_pot.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_servo.MDD_servo_pot, fileNamePrefix="servo_pot");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_reverse.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_reverse.mos
new file mode 100755
index 0000000..4d6b950
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/runMDD_servo_reverse.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_servo.MDD_servo_reverse, fileNamePrefix="servo_reverse");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init
new file mode 100755
index 0000000..ba1b63b
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.hex
new file mode 100755
index 0000000..667f2cc
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.hex
@@ -0,0 +1,94 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E50088
+:100020000C9451000C9451000C9451000C94B400A9
+:100030000C9451000C9451000C9483000C945100CA
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E6EAF5E002C0EE
+:1000800005900D92A231B107D9F711E0A2E1B1E0DC
+:1000900001C01D92A731B107E1F70E9443010C9402
+:1000A000D1020C9400008230910561F083309105FB
+:1000B00099F00197C9F416BC80916E00826080931C
+:1000C0006E0016C0109285001092840080916F001F
+:1000D000826080936F000CC01092B200809170001B
+:1000E00082608093700004C081E090E00E94D102A1
+:1000F00078949FB7F894809114019FBF8823C9F327
+:100100001092140108951F920F920FB60F921124AE
+:100110002F933F938F939F9380911201909113019E
+:100120000196909313018093120180911401813004
+:1001300091F020911201309113018091150190915D
+:1001400016012817390738F081E0809314011092C6
+:100150001301109212019F918F913F912F910F9057
+:100160000FBE0F901F9018951F920F920FB60F920F
+:1001700011242F933F938F939F938091120190911D
+:100180001301019690931301809312018091140141
+:10019000813091F02091120130911301809115016D
+:1001A000909116012817390738F081E080931401E7
+:1001B00010921301109212019F918F913F912F91F4
+:1001C0000F900FBE0F901F9018951F920F920FB6B1
+:1001D0000F9211242F933F938F939F93809112013D
+:1001E00090911301019690931301809312018091D5
+:1001F0001401813091F0209112013091130180910E
+:100200001501909116012817390738F081E0809385
+:10021000140110921301109212019F918F913F913E
+:100220002F910F900FBE0F901F901895FC01A1E821
+:10023000B0E08C918D608C9322E030E03387228790
+:10024000219AA0E8B0E08C9181688C93A8E8B0E096
+:1002500011961C921E921C92B587A48785B5836067
+:1002600085BD81E090E097878687309316012093C3
+:10027000150124B5226024BD29EF27BD918B808B09
+:1002800080E090E00895CF92DF92EF92FF92CF93BB
+:1002900080E091E00E941601C12CD12C760160E033
+:1002A00070E0CB01CEE16093000170930101809377
+:1002B00002019093030180911001909111010E941D
+:1002C0005300E0910C01F0910D01C0838FEFC81A2B
+:1002D000D80AE80AF80AC701B6010E94E0012FE631
+:1002E00032E143E05BE30E946E0220E030E0A901CE
+:1002F0000E947C01D8CF5058BB27AA270ED0B4C08B
+:10030000A5D030F0AAD020F031F49F3F11F41EF4B4
+:100310009AC00EF4E095E7FB90C0E92FB6D080F3C9
+:10032000BA17620773078407950718F071F49EF5F2
+:10033000CEC00EF4E0950B2EBA2FA02D0B01B90103
+:1003400090010C01CA01A0011124FF27591B99F04B
+:10035000593F50F4503E68F11A16F040A22F232F57
+:10036000342F4427585FF3CF469537952795A795A7
+:10037000F0405395C9F77EF41F16BA0B620B730B4E
+:10038000840BBAF09150A1F0FF0FBB1F661F771FBF
+:10039000881FC2F70EC0BA0F621F731F841F48F474
+:1003A000879577956795B795F7959E3F08F0B3CFFA
+:1003B0009395880F08F09927EE0F979587950895E4
+:1003C000E89409C097FB3EF49095809570956195EF
+:1003D0007F4F8F4F9F4F9923A9F0F92F96E9BB27A5
+:1003E0009395F695879577956795B795F111F8CF21
+:1003F000FAF4BB0F11F460FF1BC06F5F7F4F8F4F8C
+:100400009F4F16C0882311F096E911C0772321F081
+:100410009EE8872F762F05C0662371F096E8862F19
+:1004200070E060E02AF09A95660F771F881FDAF770
+:10043000880F9695879597F9089597F99F6780E8B3
+:1004400070E060E008959FEF80EC089500240A9426
+:100450001616170618060906089500240A9412169F
+:100460001306140605060895092E0394000C11F4D2
+:10047000882352F0BB0F40F4BF2B11F460FF04C07F
+:100480006F5F7F4F8F4F9F4F089557FD9058440FD8
+:10049000551F59F05F3F71F04795880F97FB991FE3
+:1004A00061F09F3F79F087950895121613061406A0
+:1004B000551FF2CF4695F1DF08C01616170618062D
+:1004C000991FF1CF86957105610508940895E89408
+:1004D000BB2766277727CB0197F908950BD0C4CFA8
+:1004E000B5DF28F0BADF18F0952309F0A6CFABCF1F
+:1004F0001124EECFCADFA0F3959FD1F3950F50E002
+:10050000551F629FF001729FBB27F00DB11D639FC5
+:10051000AA27F00DB11DAA1F649F6627B00DA11D6B
+:10052000661F829F2227B00DA11D621F739FB00D11
+:10053000A11D621F839FA00D611D221F749F332781
+:10054000A00D611D231F849F600D211D822F762F1A
+:100550006A2F11249F5750408AF0E1F088234AF017
+:10056000EE0FFF1FBB1F661F771F881F9150504063
+:10057000A9F79E3F510570F060CFAACF5F3FECF323
+:10058000983EDCF3869577956795B795F795E7954F
+:100590009F5FC1F7FE2B880F911D9695879597F960
+:0605A0000895F894FFCF5E
+:1005A6000000000000006F12033B00000000000086
+:0205B600000043
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.sh
new file mode 100755
index 0000000..a8c1413
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_servo_init.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_servo_init.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections servo_init_main.c -o servo_init -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom servo_init servo_init.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:servo_init.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init_main.c
new file mode 100755
index 0000000..b10d9af
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_init_main.c
@@ -0,0 +1,213 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct servo_init_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct servo_init_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[4];
+} servo_init_fmi2Component;
+
+servo_init_fmi2Component servo_init_component = {
+ .fmi2IntegerVars = {
+ 0 /*integerExpression1._y*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component servo_init_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &servo_init_component;
+}
+
+fmi2Status servo_init_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status servo_init_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status servo_init_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status servo_init_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status servo_init_functionOutputs(fmi2Component comp)
+{
+ Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, 30);
+}
+
+fmi2Status servo_init_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ servo_init_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = servo_init_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ servo_init_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ servo_init_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ servo_init_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = servo_init_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop.sh
new file mode 100755
index 0000000..4be3b84
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_servo_loop.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_servo_loop.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections servo_loop_main.c -o servo_loop -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom servo_loop servo_loop.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:servo_loop.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop_main.c
new file mode 100755
index 0000000..2eb1630
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_loop_main.c
@@ -0,0 +1,235 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct servo_loop_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct servo_loop_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[3];
+ fmi2Boolean fmi2BooleanVars[3];
+ fmi2Real fmi2RealParameter[1];
+ fmi2Integer fmi2IntegerParameter[1];
+ fmi2Boolean fmi2BooleanParameter[2];
+ fmi2String fmi2StringParameter[1];
+ void* extObjs[4];
+} servo_loop_fmi2Component;
+
+servo_loop_fmi2Component servo_loop_component = {
+ .fmi2IntegerVars = {
+ 0 /*integerExpression1._y*/,
+ 0 /*triggeredAdd1._local_set*/,
+ 0 /*triggeredAdd1._y*/,
+ },
+ .fmi2BooleanVars = {
+ fmi2False /*$whenCondition1*/,
+ fmi2False /*booleanExpression1._y*/,
+ fmi2False /*triggeredAdd1._local_reset*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+ .fmi2IntegerParameter = {
+ 0 /*triggeredAdd1._y_start*/,
+ },
+ .fmi2BooleanParameter = {
+ fmi2False /*triggeredAdd1._use_reset*/,
+ fmi2False /*triggeredAdd1._use_set*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component servo_loop_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &servo_loop_component;
+}
+
+fmi2Status servo_loop_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status servo_loop_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status servo_loop_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status servo_loop_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status servo_loop_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2BooleanVars[0] /* $whenCondition1 DISCRETE */ = (om_mod(comp->currentTime,0.2))>(0.1); /* equation 9 */
+
+ #error "[CodegenEmbeddedC.tpl:346:14-346:14] Unsupported equation: ..."
+
+ comp->fmi2BooleanVars[1] /* booleanExpression1._y DISCRETE */ = comp->fmi2BooleanVars[0] /* $whenCondition1 DISCRETE */; /* equation 11 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[2] /* triggeredAdd1._y DISCRETE */);
+}
+
+fmi2Status servo_loop_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ servo_loop_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = servo_loop_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ servo_loop_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ servo_loop_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ servo_loop_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = servo_loop_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh
new file mode 100755
index 0000000..41f9d90
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_servo_pot.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_servo_pot.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections servo_pot_main.c -o servo_pot -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom servo_pot servo_pot.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:servo_pot.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot_main.c
new file mode 100755
index 0000000..4cb1705
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot_main.c
@@ -0,0 +1,244 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct servo_pot_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct servo_pot_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Real fmi2RealVars[1];
+ fmi2Integer fmi2IntegerVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[5];
+} servo_pot_fmi2Component;
+
+servo_pot_fmi2Component servo_pot_component = {
+ .fmi2RealVars = {
+ 0.0 /*adc._y*/,
+ },
+ .fmi2IntegerVars = {
+ 0 /*pwm._u[1]*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+static const char * const OMCLIT0 = "ElectricPotential";
+static const char * const OMCLIT1 = "V";
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution)
+{
+ fmi2Real om_value;
+ om_value = MDD_avr_analog_read(om_analogPort, om_vref, om_voltageResolution);
+ return om_value;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage)
+{
+ void* om_avr;
+ om_avr = MDD_avr_analog_init(om_divisionFactor, om_referenceVoltage);
+ return om_avr;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr)
+{
+ MDD_avr_analog_close(om_avr);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component servo_pot_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &servo_pot_component;
+}
+
+fmi2Status servo_pot_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status servo_pot_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[2] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[1] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[0] /* adc._analog EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Analog.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(comp, 7, 4);
+ comp->extObjs[3] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[4] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[3] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status servo_pot_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status servo_pot_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status servo_pot_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2RealVars[0] /* adc._y variable */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(comp, 3, 180.0, 10); /* equation 4 */
+ comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */ = ((comp->fmi2RealVars[0] /* adc._y variable */)>(0.0)) ? (((int)
+ #error "[CodegenEmbeddedC.tpl:490:28-490:28] daeExpCallBuiltin: Not supported: floor(0.5 + adc.y, 1)"
+ )) : (((int)
+ #error "[CodegenEmbeddedC.tpl:490:28-490:28] daeExpCallBuiltin: Not supported: ceil(-0.5 + adc.y, 3)"
+ )); /* equation 5 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[4] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[2] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */);
+}
+
+fmi2Status servo_pot_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ servo_pot_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = servo_pot_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ servo_pot_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ servo_pot_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ servo_pot_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = servo_pot_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse
new file mode 100755
index 0000000..67359ad
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.hex
new file mode 100755
index 0000000..565bd99
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.hex
@@ -0,0 +1,101 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94E50088
+:100020000C9451000C9451000C9451000C94B400A9
+:100030000C9451000C9451000C9483000C945100CA
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0ECE1F6E002C0F0
+:1000800005900D92A231B107D9F711E0A2E1B1E0DC
+:1000900001C01D92A731B107E1F70E9445010C9400
+:1000A0000C030C9400008230910561F083309105BF
+:1000B00099F00197C9F416BC80916E00826080931C
+:1000C0006E0016C0109285001092840080916F001F
+:1000D000826080936F000CC01092B200809170001B
+:1000E00082608093700004C081E090E00E940C0365
+:1000F00078949FB7F894809114019FBF8823C9F327
+:100100001092140108951F920F920FB60F921124AE
+:100110002F933F938F939F9380911201909113019E
+:100120000196909313018093120180911401813004
+:1001300091F020911201309113018091150190915D
+:1001400016012817390738F081E0809314011092C6
+:100150001301109212019F918F913F912F910F9057
+:100160000FBE0F901F9018951F920F920FB60F920F
+:1001700011242F933F938F939F938091120190911D
+:100180001301019690931301809312018091140141
+:10019000813091F02091120130911301809115016D
+:1001A000909116012817390738F081E080931401E7
+:1001B00010921301109212019F918F913F912F91F4
+:1001C0000F900FBE0F901F9018951F920F920FB6B1
+:1001D0000F9211242F933F938F939F93809112013D
+:1001E00090911301019690931301809312018091D5
+:1001F0001401813091F0209112013091130180910E
+:100200001501909116012817390738F081E0809385
+:10021000140110921301109212019F918F913F913E
+:100220002F910F900FBE0F901F901895FC01A1E821
+:10023000B0E08C918D608C9382E090E09387828710
+:10024000219AA0E8B0E08C9181688C93A8E8B0E096
+:1002500011961C921E921C92B587A48785B5836067
+:1002600085BD81E090E0978786872AE030E0309373
+:1002700016012093150124B5226024BD29EF27BD66
+:10028000918B808B80E090E00895CF92DF92EF9287
+:10029000FF9280E091E00E941601C12CD12C7601E2
+:1002A00060E070E0CB0160930001709301018093E6
+:1002B0000201909303012DEC3CEC4CE45EE30E94C0
+:1002C000F30187FF03C086E190E002C08FE090E079
+:1002D0009093050180930401809110019091110188
+:1002E0000E945300E0910C01F0910D0180910401F6
+:1002F00080838FEFC81AD80AE80AF80AC701B60146
+:100300000E94F7012FE632E143E05BE30E94A9027D
+:1003100020E030E0A9010E948F01C5CF5058BB27D3
+:10032000AA270ED0DCC0CDD030F0D2D020F031F4EE
+:100330009F3F11F41EF4C2C00EF4E095E7FBB8C075
+:10034000E92FDED080F3BA17620773078407950799
+:1003500018F071F49EF5F6C00EF4E0950B2EBA2F4E
+:10036000A02D0B01B90190010C01CA01A0011124BB
+:10037000FF27591B99F0593F50F4503E68F11A1667
+:10038000F040A22F232F342F4427585FF3CF4695F8
+:1003900037952795A795F0405395C9F77EF41F161A
+:1003A000BA0B620B730B840BBAF09150A1F0FF0FE4
+:1003B000BB1F661F771F881FC2F70EC0BA0F621FD0
+:1003C000731F841F48F4879577956795B795F795C0
+:1003D0009E3F08F0B3CF9395880F08F09927EE0F52
+:1003E00097958795089540D008F481E00895E894A2
+:1003F00009C097FB3EF490958095709561957F4F6D
+:100400008F4F9F4F9923A9F0F92F96E9BB2793951A
+:10041000F695879577956795B795F111F8CFFAF42A
+:10042000BB0F11F460FF1BC06F5F7F4F8F4F9F4F5B
+:1004300016C0882311F096E911C0772321F09EE8B9
+:10044000872F762F05C0662371F096E8862F70E01F
+:1004500060E02AF09A95660F771F881FDAF7880FF9
+:100460009695879597F90895990F0008550FAA0B4F
+:10047000E0E8FEEF16161706E807F907C0F01216B7
+:100480001306E407F50798F0621B730B840B950BBA
+:1004900039F40A2661F0232B242B252B21F408950F
+:1004A0000A2609F4A140A6958FEF811D811D0895AC
+:1004B00097F99F6780E870E060E008959FEF80EC17
+:1004C000089500240A9416161706180609060895BA
+:1004D00000240A9412161306140605060895092E20
+:1004E0000394000C11F4882352F0BB0F40F4BF2B8F
+:1004F00011F460FF04C06F5F7F4F8F4F9F4F0895CF
+:1005000057FD9058440F551F59F05F3F71F04795C4
+:10051000880F97FB991F61F09F3F79F087950895A9
+:10052000121613061406551FF2CF4695F1DF08C0C8
+:10053000161617061806991FF1CF869571056105E5
+:1005400008940895E894BB2766277727CB0197F98D
+:1005500008950BD0C4CFB5DF28F0BADF18F095238B
+:1005600009F0A6CFABCF1124EECFCADFA0F3959F41
+:10057000D1F3950F50E0551F629FF001729FBB278A
+:10058000F00DB11D639FAA27F00DB11DAA1F649F36
+:100590006627B00DA11D661F829F2227B00DA11DE9
+:1005A000621F739FB00DA11D621F839FA00D611D6F
+:1005B000221F749F3327A00D611D231F849F600D90
+:1005C000211D822F762F6A2F11249F5750408AF0C9
+:1005D000E1F088234AF0EE0FFF1FBB1F661F771F55
+:1005E000881F91505040A9F79E3F510570F060CF91
+:1005F000AACF5F3FECF3983EDCF38695779567953D
+:10060000B795F795E7959F5FC1F7FE2B880F911D72
+:0C0610009695879597F90895F894FFCF10
+:10061C000000000016000AD7233C00000000000078
+:02062C000000CC
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.sh
new file mode 100755
index 0000000..9c5927d
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_servo_reverse.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_servo_reverse.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections servo_reverse_main.c -o servo_reverse -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom servo_reverse servo_reverse.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:servo_reverse.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse_main.c
new file mode 100755
index 0000000..5382666
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_reverse_main.c
@@ -0,0 +1,213 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct servo_reverse_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct servo_reverse_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Integer fmi2IntegerVars[1];
+ fmi2Real fmi2RealParameter[1];
+ void* extObjs[4];
+} servo_reverse_fmi2Component;
+
+servo_reverse_fmi2Component servo_reverse_component = {
+ .fmi2IntegerVars = {
+ 22 /*pwm._u[1]*/,
+ },
+ .fmi2RealParameter = {
+ 0.01 /*synchronizeRealtime1._actualInterval*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(fmi2Component comp, void* om_pwm, fmi2Integer om_value)
+{
+ MDD_avr_pwm_set(om_pwm, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_pin, fmi2Integer om_initialValue, fmi2Boolean om_inverted)
+{
+ void* om_pwm;
+ om_pwm = MDD_avr_pwm_init(om_timer, om_pin, om_initialValue, om_inverted);
+ return om_pwm;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_destructor(fmi2Component comp, void* om_pwm)
+{
+ MDD_avr_pwm_close(om_pwm);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component servo_reverse_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &servo_reverse_component;
+}
+
+fmi2Status servo_reverse_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status servo_reverse_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 2, 7, fmi2True);
+ comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_Init_constructor(comp, comp->extObjs[0] /* pwm._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 1, 0, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 10);
+ return fmi2OK;
+}
+
+fmi2Status servo_reverse_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status servo_reverse_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status servo_reverse_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */ = ((comp->currentTime)<(0.2)) ? (22) : (15); /* equation 3 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_PWM_set(comp, comp->extObjs[1] /* pwm._pwm[1] EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.PWM.Init */, comp->fmi2IntegerVars[0] /* pwm._u[1] DISCRETE */);
+}
+
+fmi2Status servo_reverse_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ servo_reverse_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = servo_reverse_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ servo_reverse_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ servo_reverse_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ servo_reverse_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = servo_reverse_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_buzzer.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_buzzer.mos
new file mode 100755
index 0000000..8164089
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_buzzer.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/souradip/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/souradip/OpenModelica/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_thermistor.MDD_therm_buzzer, fileNamePrefix="therm_buzzer");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_read.mos b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_read.mos
new file mode 100755
index 0000000..41b3c3a
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/runMDD_therm_read.mos
@@ -0,0 +1,11 @@
+loadModel(Modelica);
+getErrorString();
+
+loadFile("/home/siddharth/Modelica_DeviceDrivers/Modelica_DeviceDrivers/package.mo");
+getErrorString();
+
+loadFile("/home/siddharth/OpenModelica_Tasks/OpenModelica-Arduino-MDD_Arduino_Revised/Arduino.mo");
+getErrorString();
+
+translateModel(Arduino.SerialCommunication.MDD_Examples.MDD_thermistor.MDD_therm_read, fileNamePrefix="therm_read");
+getErrorString();
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer
new file mode 100755
index 0000000..4c841f2
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.hex
new file mode 100755
index 0000000..2517195
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.hex
@@ -0,0 +1,121 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C9431013B
+:100020000C9451000C9451000C9451000C9400015C
+:100030000C9451000C9451000C94CF000C9451007E
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E2E4F7E002C0F6
+:1000800005900D92A832B107D9F711E0A8E2B1E0CE
+:1000900001C01D92AD32B107E1F70E948A010C94B4
+:1000A0009F030C9400000F931F93CF93DF93EC01F9
+:1000B00080917C00857E846080937C0080917A00B2
+:1000C000806480937A0080917A0086FDFCCF6091F5
+:1000D00078007091790080E090E00E94860220E034
+:1000E00030E040E854E40E94180320E030EC4FE791
+:1000F00054E40E941E026C837D838E839F8301E003
+:1001000010E02A893B894C895D890E94140387FF8E
+:1001100002C000E010E0198B088B8EA19FA18230F5
+:10012000910561F08330910599F00197C9F416BCEF
+:1001300080916E00826080936E0016C010928500E0
+:100140001092840080916F00826080936F000CC0D9
+:100150001092B2008091700082608093700004C0A1
+:1001600081E090E00E949F0378949FB7F89480917B
+:100170002A019FBF8823C9F310922A01EAA1FBA19B
+:1001800088899989892B19F08081886002C08081D3
+:10019000877F8083DF91CF911F910F9108951F92E8
+:1001A0000F920FB60F9211242F933F938F939F932B
+:1001B00080912801909129010196909329018093C3
+:1001C000280180912A01813091F0209128013091FD
+:1001D000290180912B0190912C012817390738F0C3
+:1001E00081E080932A0110922901109228019F91A9
+:1001F0008F913F912F910F900FBE0F901F901895E8
+:100200001F920F920FB60F9211242F933F938F934B
+:100210009F93809128019091290101969093290143
+:100220008093280180912A01813091F0209128014A
+:100230003091290180912B0190912C0128173907C9
+:1002400038F081E080932A01109229011092280150
+:100250009F918F913F912F910F900FBE0F901F9004
+:1002600018951F920F920FB60F9211242F933F9360
+:100270008F939F93809128019091290101969093EB
+:1002800029018093280180912A01813091F02091E9
+:1002900028013091290180912B0190912C01281780
+:1002A000390738F081E080932A01109229011092D9
+:1002B00028019F918F913F912F910F900FBE0F902A
+:1002C0001F901895FC01539A8BE290E093A382A3B0
+:1002D00085B5836085BD81E090E095A384A32AE085
+:1002E00030E030932C0120932B0124B5226024BDF3
+:1002F00029EF27BD97A386A3ACE7B0E08C918C9340
+:10030000AAE7B0E08C9187688C9311A210A280E0DC
+:1003100090E00895CF92DF92EF92FF9280E091E01B
+:100320000E946201C12CD12C760160E070E0CB010B
+:100330006093000170930101809302019093030187
+:1003400080E091E00E9453008FEFC81AD80AE80AB3
+:10035000F80AC701B6010E9486022FE632E143E0A7
+:100360005BE30E94180320E030E0A9010E94BA017B
+:10037000DFCF5058BB27AA270ED01CC10DD130F0BB
+:1003800012D120F031F49F3F11F41EF402C10EF49B
+:10039000E095E7FBF8C0E92F1ED180F3BA1762079A
+:1003A00073078407950718F071F49EF536C10EF4B3
+:1003B000E0950B2EBA2FA02D0B01B90190010C0175
+:1003C000CA01A0011124FF27591B99F0593F50F48D
+:1003D000503E68F11A16F040A22F232F342F4427E5
+:1003E000585FF3CF469537952795A795F0405395DD
+:1003F000C9F77EF41F16BA0B620B730B840BBAF0AD
+:100400009150A1F0FF0FBB1F661F771F881FC2F717
+:100410000EC0BA0F621F731F841F48F4879577952B
+:100420006795B795F7959E3F08F0B3CF9395880FE2
+:1004300008F09927EE0F9795879508950CD0BAC0CC
+:10044000B2D040F0A9D030F021F45F3F19F09BC04A
+:100450005111E4C09EC0BFD098F39923C9F355232E
+:10046000B1F3951B550BBB27AA27621773078407A7
+:1004700038F09F5F5F4F220F331F441FAA1FA9F35D
+:1004800033D00E2E3AF0E0E830D091505040E6954F
+:10049000001CCAF729D0FE2F27D0660F771F881FB0
+:1004A000BB1F261737074807AB07B0E809F0BB0B9F
+:1004B000802DBF01FF2793585F4F2AF09E3F5105C3
+:1004C00068F061C0ABC05F3FECF3983EDCF386950B
+:1004D00077956795B795F7959F5FC9F7880F911D39
+:1004E0009695879597F90895E1E0660F771F881F25
+:1004F000BB1F621773078407BA0720F0621B730BD8
+:10050000840BBA0BEE1F88F7E0950895E89409C0B4
+:1005100097FB3EF490958095709561957F4F8F4F36
+:100520009F4F9923A9F0F92F96E9BB279395F6954C
+:10053000879577956795B795F111F8CFFAF4BB0FCA
+:1005400011F460FF1BC06F5F7F4F8F4F9F4F16C02E
+:10055000882311F096E911C0772321F09EE8872FB8
+:10056000762F05C0662371F096E8862F70E060E074
+:100570002AF09A95660F771F881FDAF7880F9695ED
+:10058000879597F9089597F99F6780E870E060E094
+:1005900008959FEF80EC089500240A94161617061C
+:1005A00018060906089500240A9412161306140664
+:1005B00005060895092E0394000C11F4882352F0C7
+:1005C000BB0F40F4BF2B11F460FF04C06F5F7F4F7F
+:1005D0008F4F9F4F089557FD9058440F551F59F066
+:1005E0005F3F71F04795880F97FB991F61F09F3F20
+:1005F00079F087950895121613061406551FF2CF49
+:100600004695F1DF08C0161617061806991FF1CF98
+:1006100086957105610508940895E894BB276627BF
+:100620007727CB0197F9089566D008F48FEF0895E6
+:100630000BD0C0CFB1DF28F0B6DF18F0952309F05A
+:10064000A2CFA7CF1124EACFC6DFA0F3959FD1F3A5
+:10065000950F50E0551F629FF001729FBB27F00D70
+:10066000B11D639FAA27F00DB11DAA1F649F6627C5
+:10067000B00DA11D661F829F2227B00DA11D621F14
+:10068000739FB00DA11D621F839FA00D611D221FCE
+:10069000749F3327A00D611D231F849F600D211DB2
+:1006A000822F762F6A2F11249F5750408AF0E1F055
+:1006B00088234AF0EE0FFF1FBB1F661F771F881F9E
+:1006C00091505040A9F79E3F510570F05CCFA6CFE6
+:1006D0005F3FECF3983EDCF3869577956795B79589
+:1006E000F795E7959F5FC1F7FE2B880F911D9695B3
+:1006F000879597F90895990F0008550FAA0BE0E820
+:10070000FEEF16161706E807F907C0F012161306D3
+:10071000E407F50798F0621B730B840B950B39F413
+:100720000A2661F0232B242B252B21F408950A2679
+:1007300009F4A140A6958FEF811D811D0895F894BD
+:02074000FFCFE9
+:1007420000000000000000000000000000000000A7
+:10075200000000806D440AD7233C02000100000023
+:0807620000000000000000008F
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.sh
new file mode 100755
index 0000000..b6782eb
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_therm_buzzer.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_therm_buzzer.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections therm_buzzer_main.c -o therm_buzzer -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom therm_buzzer therm_buzzer.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:therm_buzzer.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer_main.c
new file mode 100755
index 0000000..d729be2
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_buzzer_main.c
@@ -0,0 +1,253 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct therm_buzzer_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct therm_buzzer_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Real fmi2RealVars[2];
+ fmi2Boolean fmi2BooleanVars[3];
+ fmi2Real fmi2RealParameter[2];
+ fmi2Integer fmi2IntegerParameter[1];
+ fmi2Boolean fmi2BooleanParameter[1];
+ fmi2String fmi2StringParameter[1];
+ void* extObjs[4];
+} therm_buzzer_fmi2Component;
+
+therm_buzzer_fmi2Component therm_buzzer_component = {
+ .fmi2RealVars = {
+ 0.0 /*adc._y*/,
+ 0.0 /*realValue1._number*/,
+ },
+ .fmi2BooleanVars = {
+ fmi2False /*booleanExpression1._y*/,
+ fmi2False /*booleanExpression2._y*/,
+ fmi2False /*digitalWriteBoolean1._u*/,
+ },
+ .fmi2RealParameter = {
+ 950.0 /*greaterEqualThreshold1._threshold*/,
+ 0.01 /*synchronizeRealtime1._actualInterval*/,
+ },
+ .fmi2IntegerParameter = {
+ 2 /*realValue1._significantDigits*/,
+ },
+ .fmi2BooleanParameter = {
+ fmi2True /*realValue1._use_numberPort*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+static const char * const OMCLIT0 = "ElectricPotential";
+static const char * const OMCLIT1 = "V";
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRDigital.h"
+#include "MDDAVRAnalog.h"
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution)
+{
+ fmi2Real om_value;
+ om_value = MDD_avr_analog_read(om_analogPort, om_vref, om_voltageResolution);
+ return om_value;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage)
+{
+ void* om_avr;
+ om_avr = MDD_avr_analog_init(om_divisionFactor, om_referenceVoltage);
+ return om_avr;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr)
+{
+ MDD_avr_analog_close(om_avr);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(fmi2Component comp, void* om_port, fmi2Integer om_pin, fmi2Boolean om_value)
+{
+ MDD_avr_digital_pin_write(om_port, om_pin, om_value);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(fmi2Component comp, fmi2Integer om_port, fmi2Integer om_pin)
+{
+ void* om_dig;
+ om_dig = MDD_avr_digital_pin_init(om_port, om_pin, fmi2True);
+ return om_dig;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_destructor(fmi2Component comp, void* om_digital)
+{
+ MDD_avr_digital_pin_close(om_digital);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component therm_buzzer_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &therm_buzzer_component;
+}
+
+fmi2Status therm_buzzer_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status therm_buzzer_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_InitWrite_constructor(comp, 4, 4);
+ comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[2] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 10);
+ comp->extObjs[0] /* adc._analog EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Analog.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(comp, 7, 1);
+ return fmi2OK;
+}
+
+fmi2Status therm_buzzer_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status therm_buzzer_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status therm_buzzer_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2RealVars[0] /* adc._y variable */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(comp, 5, 1024.0, 10); /* equation 7 */
+ comp->fmi2BooleanVars[2] /* digitalWriteBoolean1._u DISCRETE */ = (comp->fmi2RealVars[0] /* adc._y variable */)>=(comp->fmi2RealParameter[0] /* greaterEqualThreshold1._threshold PARAM */); /* equation 8 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[3] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Digital_write(comp, comp->extObjs[1] /* digitalWriteBoolean1._digital EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Digital.InitWrite */, 4, comp->fmi2BooleanVars[2] /* digitalWriteBoolean1._u DISCRETE */);
+}
+
+fmi2Status therm_buzzer_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ therm_buzzer_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = therm_buzzer_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ therm_buzzer_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ therm_buzzer_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ therm_buzzer_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = therm_buzzer_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read
new file mode 100755
index 0000000..a70feab
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read
Binary files differ
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.hex b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.hex
new file mode 100755
index 0000000..c10a513
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.hex
@@ -0,0 +1,114 @@
+:100000000C9434000C9451000C9451000C94510049
+:100010000C9451000C9451000C9451000C94130159
+:100020000C9451000C9451000C9451000C94E2007B
+:100030000C9451000C9451000C94B1000C9451009C
+:100040000C9451000C9451000C9451000C945100EC
+:100050000C9451000C9451000C9451000C945100DC
+:100060000C9451000C94510011241FBECFEFD8E026
+:10007000DEBFCDBF11E0A0E0B1E0E6EEF6E002C0E9
+:1000800005900D92AC31B107D9F721E0ACE1B1E0B8
+:1000900001C01D92A132B207E1F70E9468010C94E1
+:1000A00071030C940000CF93DF93EC0190917C00DE
+:1000B000957E956090937C0080917A008064809317
+:1000C0007A0080917A0086FDFCCF60917800709173
+:1000D000790080E090E00E94760220E030E040E885
+:1000E00054E40E94040320E030EC4FE754E40E9403
+:1000F00004026C837D838E839F838A8D9B8D8230E7
+:10010000910561F08330910599F00197C9F416BC0F
+:1001100080916E00826080936E0016C01092850000
+:100120001092840080916F00826080936F000CC0F9
+:100130001092B2008091700082608093700004C0C1
+:1001400081E090E00E94710378949FB7F8948091C9
+:100150001E019FBF8823C9F310921E01DF91CF912A
+:1001600008951F920F920FB60F9211242F933F9371
+:100170008F939F9380911C0190911D010196909304
+:100180001D0180931C0180911E01813091F020910E
+:100190001C0130911D0180911F01909120012817B1
+:1001A000390738F081E080931E0110921D011092F2
+:1001B0001C019F918F913F912F910F900FBE0F9037
+:1001C0001F9018951F920F920FB60F9211242F9324
+:1001D0003F938F939F9380911C0190911D010196F5
+:1001E00090931D0180931C0180911E01813091F03C
+:1001F00020911C0130911D0180911F0190912001DF
+:100200002817390738F081E080931E0110921D01F4
+:1002100010921C019F918F913F912F910F900FBED3
+:100220000F901F9018951F920F920FB60F921124E6
+:100230002F933F938F939F9380911C0190911D0169
+:10024000019690931D0180931C0180911E018130C5
+:1002500091F020911C0130911D0180911F0190911E
+:1002600020012817390738F081E080931E01109291
+:100270001D0110921C019F918F913F912F910F9022
+:100280000FBE0F901F901895FC01ACE7B0E08C9169
+:10029000806C8C93AAE7B0E08C9187688C93178A66
+:1002A000168A85B5836085BD21E030E0318F208FCF
+:1002B00082E090E09093200180931F0184B58260DA
+:1002C00084BD89EF87BD338F228F80E090E0089551
+:1002D000CF92DF92EF92FF9280E091E00E94440182
+:1002E000C12CD12C760160E070E0CB01609300015D
+:1002F00070930101809302019093030180E091E0EB
+:100300000E9453008FEFC81AD80AE80AF80AC701FA
+:10031000B6010E9476022FE632E143E05BE30E94E1
+:10032000040320E030E0A9010E949801DFCF50587B
+:10033000BB27AA270E94AF010C94CA020E94BC02EC
+:1003400038F00E94C30220F039F49F3F19F426F4DC
+:100350000C94B9020EF4E095E7FB0C94B302E92F7C
+:100360000E94DB0258F3BA176207730784079507E8
+:1003700020F079F4A6F50C94FD020EF4E0950B2E16
+:10038000BA2FA02D0B01B90190010C01CA01A001E7
+:100390001124FF27591B99F0593F50F4503E68F142
+:1003A0001A16F040A22F232F342F4427585FF3CF83
+:1003B000469537952795A795F0405395C9F77EF454
+:1003C0001F16BA0B620B730B840BBAF09150A1F09D
+:1003D000FF0FBB1F661F771F881FC2F70EC0BA0F23
+:1003E000621F731F841F48F4879577956795B795AB
+:1003F000F7959E3F08F0B0CF9395880F08F09927A6
+:10040000EE0F9795879508950E9418020C94CA02E2
+:100410000E94C30258F00E94BC0240F029F45F3FE2
+:1004200029F00C94B30251110C94FE020C94B90201
+:100430000E94DB0268F39923B1F3552391F3951BD6
+:10044000550BBB27AA2762177307840738F09F5FF5
+:100450005F4F220F331F441FAA1FA9F335D00E2E62
+:100460003AF0E0E832D091505040E695001CCAF7CF
+:100470002BD0FE2F29D0660F771F881FBB1F261792
+:1004800037074807AB07B0E809F0BB0B802DBF0169
+:10049000FF2793585F4F3AF09E3F510578F00C9438
+:1004A000B3020C94FE025F3FE4F3983ED4F38695CA
+:1004B00077956795B795F7959F5FC9F7880F911D59
+:1004C0009695879597F90895E1E0660F771F881F45
+:1004D000BB1F621773078407BA0720F0621B730BF8
+:1004E000840BBA0BEE1F88F7E0950895E89409C0D5
+:1004F00097FB3EF490958095709561957F4F8F4F57
+:100500009F4F9923A9F0F92F96E9BB279395F6956C
+:10051000879577956795B795F111F8CFFAF4BB0FEA
+:1005200011F460FF1BC06F5F7F4F8F4F9F4F16C04E
+:10053000882311F096E911C0772321F09EE8872FD8
+:10054000762F05C0662371F096E8862F70E060E094
+:100550002AF09A95660F771F881FDAF7880F96950D
+:10056000879597F9089597F99F6780E870E060E0B4
+:1005700008959FEF80EC089500240A94161617063C
+:1005800018060906089500240A9412161306140684
+:1005900005060895092E0394000C11F4882352F0E7
+:1005A000BB0F40F4BF2B11F460FF04C06F5F7F4F9F
+:1005B0008F4F9F4F089557FD9058440F551F59F086
+:1005C0005F3F71F04795880F97FB991F61F09F3F40
+:1005D00079F087950895121613061406551FF2CF69
+:1005E0004695F1DF08C0161617061806991FF1CFB9
+:1005F00086957105610508940895E894BB276627E0
+:100600007727CB0197F908950E9417030C94CA022B
+:100610000E94BC0238F00E94C30220F0952311F022
+:100620000C94B3020C94B90211240C94FE020E94A3
+:10063000DB0270F3959FC1F3950F50E0551F629F49
+:10064000F001729FBB27F00DB11D639FAA27F00D2B
+:10065000B11DAA1F649F6627B00DA11D661F829F52
+:100660002227B00DA11D621F739FB00DA11D621F37
+:10067000839FA00D611D221F749F3327A00D611D54
+:10068000231F849F600D211D822F762F6A2F112436
+:100690009F5750409AF0F1F088234AF0EE0FFF1F69
+:1006A000BB1F661F771F881F91505040A9F79E3FC0
+:1006B000510580F00C94B3020C94FE025F3FE4F30A
+:1006C000983ED4F3869577956795B795F795E79516
+:1006D0009F5FC1F7FE2B880F911D9695879597F91F
+:0606E0000895F894FFCF1D
+:1006E6000000000000000000000000006F12033B45
+:0C06F600020001000000000000000000F5
+:00000001FF
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.sh
new file mode 100755
index 0000000..2a02704
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_therm_read.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_therm_read.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections therm_read_main.c -o therm_read -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom therm_read therm_read.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -D -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:therm_read.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read_main.c b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read_main.c
new file mode 100755
index 0000000..2b38516
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/thermistor/therm_read_main.c
@@ -0,0 +1,226 @@
+#define fmi2TypesPlatform_h
+
+#define fmi2TypesPlatform "default" /* Compatible */
+
+typedef struct therm_read_fmi2Component_s* fmi2Component;
+typedef void* fmi2ComponentEnvironment; /* Pointer to FMU environment */
+typedef void* fmi2FMUstate; /* Pointer to internal FMU state */
+typedef unsigned int fmi2ValueReference;
+typedef double fmi2Real;
+typedef int fmi2Integer;
+typedef int fmi2Boolean;
+typedef char fmi2Char;
+typedef const fmi2Char* fmi2String;
+typedef char fmi2Byte;
+
+#define fmi2True 1
+#define fmi2False 0
+
+#include "fmi2/fmi2Functions.h"
+
+#include <stdint.h>
+#include <stdio.h>
+
+void ModelicaFormatMessage(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
+
+typedef struct therm_read_fmi2Component_s {
+ fmi2Real currentTime;
+ fmi2Real fmi2RealVars[2];
+ fmi2Real fmi2RealParameter[1];
+ fmi2Integer fmi2IntegerParameter[1];
+ fmi2Boolean fmi2BooleanParameter[1];
+ fmi2String fmi2StringParameter[1];
+ void* extObjs[3];
+} therm_read_fmi2Component;
+
+therm_read_fmi2Component therm_read_component = {
+ .fmi2RealVars = {
+ 0.0 /*adc._y*/,
+ 0.0 /*realValue1._number*/,
+ },
+ .fmi2RealParameter = {
+ 0.002 /*synchronizeRealtime1._actualInterval*/,
+ },
+ .fmi2IntegerParameter = {
+ 2 /*realValue1._significantDigits*/,
+ },
+ .fmi2BooleanParameter = {
+ fmi2True /*realValue1._use_numberPort*/,
+ },
+};
+
+#include <math.h>
+/* TODO: Generate used builtin functions before SimCode */
+static inline double om_mod(double x, double y)
+{
+ return x-floor(x/y)*y;
+}
+
+static const char * const OMCLIT0 = "ElectricPotential";
+static const char * const OMCLIT1 = "V";
+#include "MDDAVRTimer.h"
+#include "MDDAVRRealTime.h"
+#include "MDDAVRAnalog.h"
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt);
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch);
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer);
+
+static inline fmi2Real Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(fmi2Component comp, fmi2Integer om_analogPort, fmi2Real om_vref, fmi2Integer om_voltageResolution)
+{
+ fmi2Real om_value;
+ om_value = MDD_avr_analog_read(om_analogPort, om_vref, om_voltageResolution);
+ return om_value;
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(fmi2Component comp, fmi2Integer om_divisionFactor, fmi2Integer om_referenceVoltage)
+{
+ void* om_avr;
+ om_avr = MDD_avr_analog_init(om_divisionFactor, om_referenceVoltage);
+ return om_avr;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_destructor(fmi2Component comp, void* om_avr)
+{
+ MDD_avr_analog_close(om_avr);
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_wait(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(fmi2Component comp, void* om_timer, fmi2Integer om_timerValue, fmi2Integer om_numTimerInterruptsPerCycle)
+{
+ void* om_rt;
+ om_rt = MDD_avr_rt_init(om_timer, om_timerValue, om_numTimerInterruptsPerCycle);
+ return om_rt;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_destructor(fmi2Component comp, void* om_rt)
+{
+ MDD_avr_rt_close(om_rt);
+}
+static inline void* Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(fmi2Component comp, fmi2Integer om_timerSelect, fmi2Integer om_clockSelect, fmi2Boolean om_clearTimerOnMatch)
+{
+ void* om_timer;
+ om_timer = MDD_avr_timer_init(om_timerSelect, om_clockSelect, om_clearTimerOnMatch);
+ return om_timer;
+}
+static inline void Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_destructor(fmi2Component comp, void* om_timer)
+{
+ MDD_avr_timer_close(om_timer);
+}
+
+fmi2Component therm_read_fmi2Instantiate(fmi2String name, fmi2Type ty, fmi2String GUID, fmi2String resources, const fmi2CallbackFunctions* functions, fmi2Boolean visible, fmi2Boolean loggingOn)
+{
+ static int initDone=0;
+ if (initDone) {
+ return NULL;
+ }
+ return &therm_read_component;
+}
+
+fmi2Status therm_read_fmi2SetupExperiment(fmi2Component comp, fmi2Boolean toleranceDefined, fmi2Real tolerance, fmi2Real startTime, fmi2Boolean stopTimeDefined, fmi2Real stopTime)
+{
+ return fmi2OK;
+}
+
+fmi2Status therm_read_fmi2EnterInitializationMode(fmi2Component comp)
+{
+ comp->extObjs[0] /* adc._analog EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Analog.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_Init_constructor(comp, 7, 4);
+ comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Timers_Timer_constructor(comp, 1, 4, fmi2False);
+ comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_Init_constructor(comp, comp->extObjs[1] /* synchronizeRealtime1._clock EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.Timers.Timer */, 249, 2);
+ return fmi2OK;
+}
+
+fmi2Status therm_read_fmi2ExitInitializationMode(fmi2Component comp)
+{
+ return fmi2OK;
+}
+
+static fmi2Status therm_read_functionODE(fmi2Component comp)
+{
+}
+
+static fmi2Status therm_read_functionOutputs(fmi2Component comp)
+{
+ comp->fmi2RealVars[0] /* adc._y variable */ = Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_Analog_read__voltage(comp, 6, 1024.0, 10); /* equation 4 */Modelica__DeviceDrivers_EmbeddedTargets_AVR_Functions_RealTimeSynchronization_wait(comp, comp->extObjs[2] /* synchronizeRealtime1._sync EXTOBJ: Modelica_DeviceDrivers.EmbeddedTargets.AVR.Functions.RealTimeSynchronization.Init */);
+}
+
+fmi2Status therm_read_fmi2DoStep(fmi2Component comp, fmi2Real currentCommunicationPoint, fmi2Real communicationStepSize, fmi2Boolean noSetFMUStatePriorToCurrentPoint)
+{
+ comp->currentTime = currentCommunicationPoint;
+ /* TODO: Calculate time/state-dependent variables here... */
+ therm_read_functionOutputs(comp);
+ return fmi2OK;
+}
+
+int main(int argc, char **argv)
+{
+ int terminateSimulation = 0;
+ fmi2Status status = fmi2OK;
+ fmi2CallbackFunctions cbf = {
+ .logger = NULL,
+ .allocateMemory = NULL /*calloc*/,
+ .freeMemory = NULL /*free*/,
+ .stepFinished = NULL, //synchronous execution
+ .componentEnvironment = NULL
+ };
+
+ fmi2Component comp = therm_read_fmi2Instantiate("", fmi2CoSimulation, "", "", &cbf, fmi2False, fmi2False);
+ if (comp==NULL) {
+ return 1;
+ }
+ therm_read_fmi2SetupExperiment(comp, fmi2False, 0.0, 0.0, fmi2False, 1.0);
+ therm_read_fmi2EnterInitializationMode(comp);
+ // Set start-values? Nah...
+ therm_read_fmi2ExitInitializationMode(comp);
+
+ double currentTime = 0.0;
+ double h = 0.002;
+ uint32_t i = 0;
+
+ while (status == fmi2OK) {
+ //retrieve outputs
+ // fmi2GetReal(m, ..., 1, &y1);
+ //set inputs
+ // fmi2SetReal(m, ..., 1, &y2);
+
+ //call slave and check status
+ status = therm_read_fmi2DoStep(comp, currentTime, h, fmi2True);
+ switch (status) {
+ case fmi2Discard:
+ case fmi2Error:
+ case fmi2Fatal:
+ case fmi2Pending /* Cannot happen */:
+ terminateSimulation = 1;
+ break;
+ case fmi2OK:
+ case fmi2Warning:
+ break;
+ }
+ if (terminateSimulation) {
+ break;
+ }
+ i++;
+ /* increment master time */
+ currentTime = 0.0 + h*i;
+ }
+
+#if 0
+ if ((status != fmi2Error) && (status != fmi2Fatal)) {
+ fmi2Terminate(m);
+ }
+ if (status != fmi2Fatal) {
+ fmi2FreeInstance(m);
+ }
+#endif
+}
+