-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_project.sh
More file actions
executable file
·75 lines (59 loc) · 1.08 KB
/
new_project.sh
File metadata and controls
executable file
·75 lines (59 loc) · 1.08 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
NAME="test"
CPU_F="16000000"
MMCU="atmega328p"
PROJECT="Test"
echo "************ Making a makefile ************"
echo ""
echo "Project name: (default=$PROJECT) "
read
if [ ! -z $REPLY ]; then
PROJECT=$REPLY
fi
REPLY=""
echo "Program name: (default=$NAME) "
read
if [ ! -z $REPLY ]; then
NAME=$REPLY
fi
REPLY=""
echo "CPU Clock: (default=$CPU_F) "
read
if [ ! -z $REPLY ]; then
CPU_F=$REPLY
fi
REPLY=""
echo "MMCU: (default=$MMCU) "
read
if [ ! -z $REPLY ]; then
MMCU=$REPLY
fi
REPLY=""
mkdir $PROJECT
cd $PROJECT
cat > Makefile << EOF
NAME=$NAME
CPU_F=$CPU_F
MMCU=$MMCU
all: hex
hex: exe
avr-objcopy -O ihex -R .eeprom \$(NAME) \$(NAME).hex
exe: obj
avr-gcc -mmcu=\$(MMCU) \$(NAME).o -o \$(NAME)
obj: \$(NAME).c
avr-gcc -Os -DF_CPU=\$(CPU_F) -mmcu=\$(MMCU) -c -o \$(NAME).o \$(NAME).c
clear:
rm \$(NAME)
rm \$(NAME).o
rm \$(NAME).hex
upload: hex
sudo chmod 777 /dev/ttyACM0
avrdude -c avrisp -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:\$(NAME).hex
EOF
cat > "$NAME.c" << EOF
#include <avr/io.h>
#include <util/delay.h>
int main() {
return 0 ;
}
EOF