diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a8ac54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +.vscode/ diff --git a/makefile b/makefile new file mode 100644 index 0000000..665f8ab --- /dev/null +++ b/makefile @@ -0,0 +1,31 @@ +MCU=atmega32 +F_CPU=8000000 +PROG=dragon_jtag +DEBUGGER = dragon +PORT=/dev/ttyUSB0 + +CC=avr-g++ +OBJCOPY=avr-objcopy +CFLAGS=-Wall -g -mmcu=${MCU} -DF_CPU=${F_CPU} -I. +TARGET=main +SRCS=src/*.cpp + +default: build flash + +build: + ${CC} ${CFLAGS} -o bin/${TARGET}.bin ${SRCS} + ${CC} ${CFLAGS} -o bin/${TARGET}.elf ${SRCS} + ${OBJCOPY} -j .text -j .data -O ihex bin/${TARGET}.bin bin/${TARGET}.hex + +flash: + avrdude -p ${MCU} -c ${PROG} -U flash:w:bin/main.hex + +clean: + rm -f bin/* + +debug: flash avarice + sleep 1 + avr-gdb -ex "target remote :4242" bin/main.elf + +avarice: + avarice --file bin/main.elf --part ${MCU} --${DEBUGGER} :4242 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..4137c04 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,24 @@ +#define F_CPU 8000000UL +#include +#include +#include +#include "photointerrupter.h" + + +int main() +{ + photointerrupter::init(); + DDRD |= (1< +#include +#include +#include "photointerrupter.h" + +namespace photointerrupter { + void init() { + TCCR2 |= (1< 600) { + TCCR2 |= (1<