summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-06-04 19:09:07 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-06-04 19:09:07 +0200
commit27321e05de35b494c2b282652e1c40a18435b68b (patch)
tree517ac03ec78902c608e6522ba1f58aebfff41d84 /Makefile
parent3ead2db8d979bab8fd8848d24de430979698b16f (diff)
downloadanalog_instruments-27321e05de35b494c2b282652e1c40a18435b68b.tar.gz
implement uart
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile19
1 files changed, 16 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 38f5292..386814d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,18 @@
MCU = atmega8
-CPUFREQ = 160000000
PROGRAMMER = dragon_isp
+CPUFREQ = 8000000 #8MHz
+BAUD = 9600
+
+# https://www.engbedded.com/fusecalc/
+# Int. RC Osc. 8MHz
+# No WD
+# No BOD
+LFUSE = 0xc4
+HFUSE = 0xd9
+
CC = avr-gcc
-CFLAGS = -std=c89 -Wall -mmcu=$(MCU) -DF_CPU=$(CPUFREQ)
+CFLAGS = -std=c89 -Wall -mmcu=$(MCU) -DF_CPU=$(CPUFREQ) -DBAUD=$(BAUD)
LDFLAGS = -mmcu=$(MCU)
BUILDDIR = build
SOURCEDIR = src
@@ -19,6 +28,7 @@ build: dir $(OBJ)
@echo LD $(OBJ)
@$(CC) $(CFLAGS) -o $(BUILDDIR)/$(OUTPUT) $(OBJ) $(LDFLAGS)
@avr-objcopy -O ihex $(BUILDDIR)/$(OUTPUT) $(BUILDDIR)/$(OUTPUT).hex
+ @avr-size --mcu=$(MCU) --format=avr $(BUILDDIR)/$(OUTPUT)
debug: -D _DEBUG
debug: build;
@@ -41,7 +51,10 @@ clean:
all: clean build
flash: build
- @avrdude -p $(MCU) -c $(PROGRAMMER) -U flash:w:$(BUILDDIR)/$(OUTPUT).hex:i
+ @sudo avrdude -p $(MCU) -c $(PROGRAMMER) -U flash:w:$(BUILDDIR)/$(OUTPUT).hex:i
+
+fuse:
+ @sudo avrdude -p $(MCU) -c $(PROGRAMMER) -U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m
devsetup:
@echo "--target=avr -isystem /usr/avr/include/ $(CFLAGS)" | tr ' ' '\n' > compile_flags.txt