summaryrefslogtreecommitdiff
path: root/robot
diff options
context:
space:
mode:
Diffstat (limited to 'robot')
-rw-r--r--robot/main.c20
-rw-r--r--robot/makefile42
-rw-r--r--robot/readme.md10
3 files changed, 72 insertions, 0 deletions
diff --git a/robot/main.c b/robot/main.c
new file mode 100644
index 0000000..dfc8d68
--- /dev/null
+++ b/robot/main.c
@@ -0,0 +1,20 @@
+#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/robot/makefile b/robot/makefile
new file mode 100644
index 0000000..d01ad30
--- /dev/null
+++ b/robot/makefile
@@ -0,0 +1,42 @@
+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/ttyACM1
+
+SOURCES := $(wildcard *.c)
+HEADERS := $(wildcard *.h)
+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) $(CFLAGS) $(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:
+ clang-format -i $(SOURCES) $(HEADERS)
+
+compile_commands: clean
+ bear -- make
diff --git a/robot/readme.md b/robot/readme.md
new file mode 100644
index 0000000..5c2aa13
--- /dev/null
+++ b/robot/readme.md
@@ -0,0 +1,10 @@
+# robot code
+
+dit is de submap voor alle code die op de robot zelf draait
+
+## make gedoe
+
+om de code te uploaden naar de robot moet je de juiste com-poort instellen in de
+makefile in deze map (regel waar `PORT ?= /dev/ttyACM0` staat). deze kun je
+waarschijnlijk vinden in apparaatbeheer op windows. daarna kun je `make flash`
+uitvoeren om de code te uploaden