init attiny25 setup
authorRobin Krens <robin@robinkrens.nl>
Tue, 17 May 2022 15:53:54 +0000 (17:53 +0200)
committerRobin Krens <robin@robinkrens.nl>
Tue, 17 May 2022 15:53:54 +0000 (17:53 +0200)
Makefile [new file with mode: 0644]
hbc.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..27dfb39
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+# ATmega328P, shitty Chinese arduino clone (just an atmega328p with arduino bootloader/flasher)
+
+MCU = attiny25
+F_CPU = 8000000UL
+BAUD = 57600
+
+PROGRAMMER_TYPE = arduino
+
+CC = avr-gcc
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+AVRSIZE = avr-size
+AVRDUDE = avrdude
+
+CPPFLAGS = -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) -I.
+CFLAGS = -Os -g -Wall
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
+
+LDFLAGS = -Wl,-Map,hbc.map
+TARGET_ARCH = -mmcu=$(MCU)
+
+DEPS = 
+
+ODIR = obj
+_OBJ = hbc.o
+OBJ = $(patsubst %, $(ODIR)/%,$(_OBJ))
+
+$(ODIR)/%.o: %.c $(DEPS)
+       @mkdir -p $(@D)
+       $(CC) -c $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $< -o $@
+
+%.elf: $(OBJ)
+       $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ -o $@
+
+%.hex: %.elf
+       $(OBJCOPY) -j .text -j .data -O ihex $< $@
+
+all: hbc.hex
+
+.PHONY: clean
+
+clean: 
+       rm -rf $(ODIR)/*.o *.hex *.elf *.map
+
+
+check-dev: 
+               $(AVRDUDE) -p m328p -c $(PROGRAMMER_TYPE) -b $(BAUD) -P /dev/ttyUSB0
+
+flash:
+       $(AVRDUDE) -p m328p -c $(PROGRAMMER_TYPE) -b $(BAUD) -P /dev/ttyUSB0 -U flash:w:flash.hex:i
+
+read-flash-bin:        
+               $(AVRDUDE) -p m328p -c $(PROGRAMMER_TYPE) -b $(BAUD) -P /dev/ttyUSB0 -U flash:r:flash.bin:r
+
diff --git a/hbc.c b/hbc.c
new file mode 100644 (file)
index 0000000..e2c06d9
--- /dev/null
+++ b/hbc.c
@@ -0,0 +1,19 @@
+#include <avr/io.h>
+#include <avr/interrupt.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <util/delay.h>
+
+int main(void) {
+       
+       DDRB |= (1 << PB0);
+
+       while(1) {
+               //
+       }
+
+       return 0;
+
+}