blob: 2a0270465df2cd5f0b097cd6060640f8d1b96c44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
|