aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-04-25 13:42:06 +0200
committerlonkaars <loek@pipeframe.xyz>2022-04-25 13:42:06 +0200
commit559736432356e2bb4ce805e60c32353a5582a568 (patch)
tree2f9c24e4099d5e86f7b90dfead5aba521e48dc2c
parent9421fb8c7a7ec8082ada2eaa583acea4bdc12ed1 (diff)
working makefile for 3pi robot
-rw-r--r--.gitignore5
-rw-r--r--main.c21
-rw-r--r--makefile41
-rw-r--r--readme.md15
4 files changed, 82 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e62153
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+compile_commands.json
+*.o
+out.hex
+a.out
+.cache
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..1dae142
--- /dev/null
+++ b/main.c
@@ -0,0 +1,21 @@
+#include <pololu/orangutan.h>
+
+int main() {
+ print("Hello!");
+ play("L16 ceg>c");
+
+ while(1) {
+ red_led(0);
+ green_led(1);
+
+ delay_ms(100);
+
+ red_led(1);
+ green_led(0);
+
+ delay_ms(100);
+ }
+
+ return 0;
+}
+
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..0f00eaf
--- /dev/null
+++ b/makefile
@@ -0,0 +1,41 @@
+DEVICE = atmega328p
+MCU = atmega328p
+AVRDUDE_DEVICE = m328p
+DEVICE ?= atmega168
+MCU ?= atmega168
+AVRDUDE_DEVICE ?= m168
+
+CFLAGS=-g -Wall -mcall-prologues -mmcu=$(MCU) $(DEVICE_SPECIFIC_CFLAGS) -Os
+LDFLAGS=-Wl,-gc-sections -lpololu_$(DEVICE) -Wl,-relax
+
+PORT ?= /dev/ttyACM0
+
+SOURCES := $(wildcard *.c)
+OBJECTS := $(patsubst %.c,%.o, $(SOURCES))
+
+AVRDUDE=avrdude
+CC=avr-gcc
+OBJ2HEX=avr-objcopy
+
+all: out.hex
+
+clean:
+ rm -f *.o out.hex a.out compile_commands.json
+
+a.out: $(OBJECTS)
+ $(CC) $(OBJECTS) $(LDFLAGS)
+
+.o:
+ $(CC) -c $(CFLAGS) $<
+
+out.hex: a.out
+ $(OBJ2HEX) -R .eeprom -O ihex $< $@
+
+flash: out.hex
+ $(AVRDUDE) -p $(AVRDUDE_DEVICE) -c avrisp2 -P $(PORT) -U flash:w:out.hex
+
+format:
+ find . -name '*.c' -o -name '*.h' | clang-format -i
+
+compile_commands: clean
+ bear -- make
diff --git a/readme.md b/readme.md
index adcbe9f..3a7fe07 100644
--- a/readme.md
+++ b/readme.md
@@ -1,3 +1,18 @@
# project robotrun software
yeah
+
+## make gedoe
+
+deze commando's kun je uitvoeren op de command-line als je alle build tools
+goed geïnstalleerd hebt. er hoort ook een configuratie te zijn voor visual
+studio code.
+
+```sh
+make # build
+make flash # upload executable to robot
+make clean # clean working directory
+make format # format source and header files
+make compile_commands # generate compile_commands.json (clangd)
+```
+