From 4a013690c68e0665fa18c983f7a610a90f19b426 Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Tue, 17 May 2022 17:53:54 +0200 Subject: [PATCH] init attiny25 setup --- Makefile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ hbc.c | 19 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 Makefile create mode 100644 hbc.c diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..e2c06d9 --- /dev/null +++ b/hbc.c @@ -0,0 +1,19 @@ +#include +#include + +#include +#include + +#include + +int main(void) { + + DDRB |= (1 << PB0); + + while(1) { + // + } + + return 0; + +} -- 2.7.4